Use this skill when the user wants real-time information or general web search. Triggers when user asks "天气怎么样", "查一下XX", "搜索XX", "机场到市区怎么走", "哪些区域适合入住". This skill uses InformationQueryAgent (weather via WeatherAPI.com, web search via DDGS). For policy, standards, reimbursement, or internal rules use ask-question (RAG) instead.
查询天气(WeatherAPI.com)和网络搜索(DDGS),使用 InformationQueryAgent。差旅标准、报销政策、审批流程等由 ask-question(RAG)处理。
.claude/skills/query-info/script/agent.py 加载)reply() 为 async,需 awaitpip install ddgs),带摘要import asyncio
from agentscope.message import Msg
from agentscope.model import OpenAIChatModel
from config_agentscope import init_agentscope
from config import LLM_CONFIG
from agents.lazy_agent_registry import LazyAgentRegistry
import json
async def query_info(user_query: str):
init_agentscope()
model = OpenAIChatModel(
model_name=LLM_CONFIG["model_name"],
api_key=LLM_CONFIG["api_key"],
client_kwargs={"base_url": LLM_CONFIG["base_url"], "timeout": 60},
temperature=LLM_CONFIG.get("temperature", 0.7),
max_tokens=LLM_CONFIG.get("max_tokens", 2000),
)
registry = LazyAgentRegistry(model=model, cache={})
agent = registry["information_query"]
user_msg = Msg(name="user", content=user_query, role="user")
result = await agent.reply(user_msg)
return json.loads(result.content) if isinstance(result.content, str) else result.content
# 使用
data = asyncio.run(query_info("北京明天天气怎么样?"))
# data: {"query_type": "天气查询"|"网络搜索", "query_success": bool, "results": {"summary": "...", "sources": [...]}}
query_type: "天气查询" 或 "网络搜索"query_success: 是否成功results: 含 summary、sources 等(天气无 sources 时可能仅有 summary)pip install ddgs(或 duckduckgo-search)。【要求】