Voice et bot modif

This commit is contained in:
pi 2026-06-16 17:09:34 +00:00
parent 189d56026b
commit 7333a22bcd
10774 changed files with 634644 additions and 933308 deletions

View file

@ -150,7 +150,7 @@ async def run_agent(
config["apiKey"] = substituted_api_key
# Main agent loop
async with Agent(
provider=config.get("provider"), # type: ignore[arg-type]
provider=config.get("provider"), # type: ignore
model=config.get("model"),
base_url=config.get("endpointUrl"), # type: ignore[arg-type]
api_key=config.get("apiKey"),

View file

@ -47,7 +47,7 @@ problem and think insightfully.
MAX_NUM_TURNS = 10
TASK_COMPLETE_TOOL: ChatCompletionInputTool = ChatCompletionInputTool.parse_obj( # type: ignore[assignment]
TASK_COMPLETE_TOOL: ChatCompletionInputTool = ChatCompletionInputTool.parse_obj( # type: ignore
{
"type": "function",
"function": {
@ -61,7 +61,7 @@ TASK_COMPLETE_TOOL: ChatCompletionInputTool = ChatCompletionInputTool.parse_obj(
}
)
ASK_QUESTION_TOOL: ChatCompletionInputTool = ChatCompletionInputTool.parse_obj( # type: ignore[assignment]
ASK_QUESTION_TOOL: ChatCompletionInputTool = ChatCompletionInputTool.parse_obj( # type: ignore
{
"type": "function",
"function": {

View file

@ -39,33 +39,35 @@ def format_result(result: "mcp_types.CallToolResult") -> str:
formatted_parts: list[str] = []
for item in content:
if item.type == "text":
formatted_parts.append(item.text)
match item.type:
case "text":
formatted_parts.append(item.text)
elif item.type == "image":
formatted_parts.append(
f"[Binary Content: Image {item.mimeType}, {_get_base64_size(item.data)} bytes]\n"
f"The task is complete and the content accessible to the User"
)
elif item.type == "audio":
formatted_parts.append(
f"[Binary Content: Audio {item.mimeType}, {_get_base64_size(item.data)} bytes]\n"
f"The task is complete and the content accessible to the User"
)
elif item.type == "resource":
resource = item.resource
if hasattr(resource, "text") and isinstance(resource.text, str):
formatted_parts.append(resource.text)
elif hasattr(resource, "blob") and isinstance(resource.blob, str):
case "image":
formatted_parts.append(
f"[Binary Content ({resource.uri}): {resource.mimeType}, {_get_base64_size(resource.blob)} bytes]\n"
f"[Binary Content: Image {item.mimeType}, {_get_base64_size(item.data)} bytes]\n"
f"The task is complete and the content accessible to the User"
)
case "audio":
formatted_parts.append(
f"[Binary Content: Audio {item.mimeType}, {_get_base64_size(item.data)} bytes]\n"
f"The task is complete and the content accessible to the User"
)
case "resource":
resource = item.resource
if hasattr(resource, "text") and isinstance(resource.text, str):
formatted_parts.append(resource.text)
elif hasattr(resource, "blob") and isinstance(resource.blob, str):
formatted_parts.append(
f"[Binary Content ({resource.uri}): {resource.mimeType},"
f" {_get_base64_size(resource.blob)} bytes]\n"
f"The task is complete and the content accessible to the User"
)
return "\n".join(formatted_parts)
@ -102,7 +104,7 @@ def _load_agent_config(agent_path: Optional[str]) -> tuple[AgentConfig, Optional
return config, prompt
if agent_path is None:
return DEFAULT_AGENT, None # type: ignore[return-value]
return DEFAULT_AGENT, None # type: ignore
path = Path(agent_path).expanduser()