Skip to content

Commit 672998c

Browse files
committed
fix(models): simplify working model logic
1 parent acd38f0 commit 672998c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

tests/working_models.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ async def filter_working_models(
8686
Asynchronously tests each model in free_models with the given test
8787
prompt and API endpoint returning only those models that respond
8888
without an error.
89-
9089
:param client: An instance of AsyncOpenRouterClient.
9190
:param free_models: A list of model dictionaries.
9291
:param test_prompt: The prompt to test.
@@ -98,13 +97,16 @@ async def filter_working_models(
9897
for i, model in enumerate(free_models)
9998
]
10099
results = await asyncio.gather(*tasks, return_exceptions=True)
101-
# Filter out any exceptions and only keep models where works is True.
102-
return [
103-
model
104-
for result in results
105-
if not isinstance(result, Exception) and result[1]
106-
for model in [result[0]]
107-
]
100+
101+
working_models = []
102+
for result in results:
103+
if isinstance(result, Exception):
104+
continue
105+
model, works = result # pyright: ignore [reportGeneralTypeIssues]
106+
if works:
107+
working_models.append(model)
108+
109+
return working_models
108110

109111

110112
async def main() -> None:

0 commit comments

Comments
 (0)