mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-11 12:17:45 +02:00
working tools for api key
This commit is contained in:
@@ -43,16 +43,24 @@ NINE_ROUTER_MODEL_MAP: dict[str, str] = {
|
||||
"haiku": "cc/claude-haiku-4-5-20251001",
|
||||
}
|
||||
|
||||
CANONICAL_MODEL_MAP: dict[str, str] = {
|
||||
alias: mid.removeprefix("cc/")
|
||||
for alias, mid in NINE_ROUTER_MODEL_MAP.items()
|
||||
}
|
||||
|
||||
def _resolve_nine_router_model(model: str, has_api_key: bool) -> str:
|
||||
"""Resolve a model name for the active connection mode.
|
||||
|
||||
When using a direct API key the model passes through unchanged.
|
||||
When using a direct API key, any ``cc/`` prefix is stripped (the model
|
||||
may have come from 9Router's model list) and short aliases are mapped
|
||||
to their canonical Anthropic model IDs.
|
||||
When routing through 9Router, short aliases are mapped to their
|
||||
``cc/``-prefixed canonical IDs; models that already carry the prefix
|
||||
are returned as-is to avoid double-prefixing.
|
||||
"""
|
||||
if has_api_key:
|
||||
return model
|
||||
clean = model.removeprefix("cc/")
|
||||
return CANONICAL_MODEL_MAP.get(clean, clean)
|
||||
if model.startswith("cc/"):
|
||||
return model
|
||||
return NINE_ROUTER_MODEL_MAP.get(model, f"cc/{model}")
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ def make_create_agent_handler(parent: Agent):
|
||||
if child.task:
|
||||
await child.task
|
||||
last_response = "No response from sub-agent."
|
||||
for m in reversed[AnyMessage](child.messages.messages):
|
||||
for m in reversed(child.messages.messages):
|
||||
if isinstance(m, AssistantMessage):
|
||||
last_response = m.content
|
||||
break
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ def make_invoke_agent_handler(agent_registry: Dict[str, Agent]):
|
||||
await fork.task
|
||||
|
||||
last_response = "No response from invoked agent."
|
||||
for m in reversed[AnyMessage](fork.messages.messages):
|
||||
for m in reversed(fork.messages.messages):
|
||||
if isinstance(m, AssistantMessage):
|
||||
last_response = m.content
|
||||
break
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ async def run_browser_agent(
|
||||
if child.task:
|
||||
await child.task
|
||||
|
||||
for m in reversed[AnyMessage](child.messages.messages):
|
||||
for m in reversed(child.messages.messages):
|
||||
if isinstance(m, AssistantMessage):
|
||||
return m.content
|
||||
|
||||
|
||||
Reference in New Issue
Block a user