// CangjieMagic Agent DSL — 天气助手
// 来源: https://blog.csdn.net/gitblog_00020/article/details/150225071

@agent[
    model: "ollama:phi3",
    executor: "react:5",
    tools: [weatherTool, searchTool],
    memory: true,
    temperature: 0.7,
    enableToolFilter: true
]
class WeatherAssistant {
    @prompt[pattern: APE](
        action: "提供精准的天气查询与出行建议",
        purpose: "帮助用户规划行程并避免天气影响",
        expectation: "输出包含温度、降水概率和建议的结构化回复"
    )

    @tool[description: "获取指定城市的天气数据",
          parameters: { city: "城市名称" }]
    private func queryWeather(city: String): String {
        // 调用天气 API
        return WeatherAPI.query(city)
    }

    @tool[description: "搜索相关旅行信息"]
    func searchTravel(query: String): String {
        return SearchEngine.search(query)
    }
}

// 使用
let assistant = WeatherAssistant()
let result = assistant.chat("北京明天天气怎么样？适合出游吗？")
print(result)
