《董鑫-CangjieMagic:基于仓颉语言的Agent开发框架实践.pdf》由会员分享,可在线阅读,更多相关《董鑫-CangjieMagic:基于仓颉语言的Agent开发框架实践.pdf(34页珍藏版)》请在三个皮匠报告上搜索。
1、01基于 CangjieMagic 构建 Agent 应用示例02框架能力拆解:Cangjie Magic 如何支持高效 Agent 构建03技术基础:仓颉语言对 Agent 开发的原生支撑04仓颉语言在其他 AI 方向上的探索01agentmodel:deepseek:deepseek-chat,executor:plan-react,mcp:stdio(node$MARKDOWNIFY_DIR/dist/index.js),stdio(docker run mcp/filesystem.)class FileAssistant promptpattern:ERA(expectation:F
2、ollow遵从指导逐步完成任务,role:嘿,伙计!你是一个文件小助理,action:对用户问题,仔细规划,然后使用工具,例如.)Markdownify MCP Server Filesystem MCP Server 添加 MCP 服务器let agent=FileAssistant()for(data in agent.asyncChat(input)print(data)“PlanDivide subtasksReasonSelect toolSummarizeInvoke toolExecution“,PC class ConsolePrinter:TagStreamVisitor o
3、verride protected func onTag(tag:String)Console.stdOut.writeln(tag)override protected func onChunk(chunk:String)Console.stdOut.write(chunk)“agentmodel:deepseek:deepseek-chat,executor:naive,rag:source:./docs/tutorial.md,mode:staticclass QABot promptpattern:ERA(expectation:代码段使用cangjie 和 修饰,role:你是 QA
4、 小能手,action:检索文档并回复问题 )let agent=QABot()for(data in agent.asyncChat(input)print(data)let group=DispatchAgent()ag2|ag3let leaderGroup:LeaderGroup=ag1 act)CoT ReActThinkActRAG:embeddingAgentAgentconversationagent:FooAgent()(明天上海天气-weatherprintln(weather)给我出行建议-suggestionprintln(suggestion)agentmemory:
5、trueclass FooAgent.let agent=FooAgent()let weather=agent.chat(“明天上海天气)agentmodel:“myModel”,executor:“myExecutor”,retriever:“myRetriever”class Foo chatModelname:“myModel”,class MyModel func chat(request:ChatRequest)executorlname:“myExecutor”,class MyExecutor func execute(agent:Agent,request:AgentRequ
6、est retrievername:“myRetriever”,class MyRetriever func search(query:String):Array 03LLM Powered Autonomous Agents|LilLog(lilianweng.github.io)Memory Tools!TypeInfo.of(Cangjie)!=“Chinese PL.”enum SupportedOS|HarmonyOS|Linux/Run|Windows|MacOS/Develop|NextOne/(TB