// CangjieMagic Agent DSL — 研究助手 (多智能体协同)
// 来源: https://blog.csdn.net/gitblog_00020/article/details/150225071

@agent[
    model: "deepseek:deepseek-chat",
    executor: "react:10"
]
class ResearchAssistant {
    @prompt[pattern: CRISPE](
        capacity: "你是一个学术研究助手",
        insight: "能够快速检索和分析学术论文",
        statement: "请提供全面、准确的研究综述",
        personality: "严谨、客观",
        experiment: "尝试从多个数据库交叉验证"
    )

    @execution(
        divide |> each(think |> action) |> summary |> answer
    )

    @tool[description: "网络搜索工具"]
    func webSearch(query: String): String {
        return WebSearch.search(query)
    }

    @tool[description: "文献分析工具"]
    func paperAnalysis(url: String): String {
        return PaperParser.analyze(url)
    }

    @tool[description: "数据库查询"]
    func dbQuery(sql: String): String {
        return Database.query(sql)
    }
}

// 使用
let researcher = ResearchAssistant()
let review = researcher.chat("综述2024年大模型在代码生成领域的最新进展")
print(review)
