MCPcopy
hub / github.com/karpathy/llm-council / query_models_parallel

Function query_models_parallel

backend/openrouter.py:56–79  ·  view source on GitHub ↗

Query multiple models in parallel. Args: models: List of OpenRouter model identifiers messages: List of message dicts to send to each model Returns: Dict mapping model identifier to response dict (or None if failed)

(
    models: List[str],
    messages: List[Dict[str, str]]
)

Source from the content-addressed store, hash-verified

54
55
56async def query_models_parallel(
57 models: List[str],
58 messages: List[Dict[str, str]]
59) -> Dict[str, Optional[Dict[str, Any]]]:
60 """
61 Query multiple models in parallel.
62
63 Args:
64 models: List of OpenRouter model identifiers
65 messages: List of message dicts to send to each model
66
67 Returns:
68 Dict mapping model identifier to response dict (or None if failed)
69 """
70 import asyncio
71
72 # Create tasks for all models
73 tasks = [query_model(model, messages) for model in models]
74
75 # Wait for all to complete
76 responses = await asyncio.gather(*tasks)
77
78 # Map models to their responses
79 return {model: response for model, response in zip(models, responses)}

Callers 2

stage1_collect_responsesFunction · 0.85
stage2_collect_rankingsFunction · 0.85

Calls 1

query_modelFunction · 0.85

Tested by

no test coverage detected