CoolFace
Apppublic

Pamudu13/gemma-3-chat

sourceHugging Faceupdated 25d agoView on Hugging Face
0likes
a2a_tool.py40 linesDownload Raw Back to py
1import json2from python_a2a import A2AClient3 4async def get_a2a_tool(settings):5    a2a_agent_list = []6    for a2a_agent_url,a2a_agent_config in settings["a2aServers"].items():7        if a2a_agent_config["enabled"]:8            a2a_agent_list.append({"agent_url": a2a_agent_url, "agent_description": a2a_agent_config["description"], "agent_skills": a2a_agent_config["skills"]})9    if len(a2a_agent_list) > 0:10        a2a_agent_list = json.dumps(a2a_agent_list, ensure_ascii=False, indent=4)11        agent_tool = {12            "type": "function",13            "function": {14                "name": "a2a_tool_call",15                "description": f"参考A2A智能体中的配置信息调用指定A2A服务,返回结果。当前可用的A2A服务器有:{a2a_agent_list}",16                "parameters": {17                    "type": "object",18                    "properties": {19                        "agent_url": {20                            "type": "string",21                            "description": "需要调用的A2A智能体URL",22                        },23                        "query": {24                            "type": "string",25                            "description": "需要向A2A智能体发送的问题",26                        }27                    },28                    "required": ["agent_url", "query"]29                }30            }31        }32        return agent_tool33    else:34        return None35 36async def a2a_tool_call(agent_url, query):37    client = A2AClient(agent_url)38    response = client.ask(query)39    return response40