[AI Agent Application Development Framework] - 🚀 Build AI agent native application in very few code 💬 Easy to interact with AI agent in code using structure data and chained-calls syntax 🧩 Enhance AI Agent using plugins instead of rebuild a whole new agent
我这里一共使用了三个agent:
``from agent_factory_api import agent_factory_zhipu from agent_tool.milvus_tool import get_search_result
路由模型-对用户问题进行基础判断-分发至正确的其他agent
def route_agent(user_input,history): route = ( agent_factory_zhipu.create_agent('rout') .set_settings("model.ZhipuAI.options", {"model": "glm-4"}) .set_role("role", "你是一个路由助手,您的工作是结合上下文帮助用户找到合适的Agent代理来回答用户的问题") .input(user_input) .chat_history(history) .output({ "intention": ("制度流程查询 | 绘图 | 闲聊 | 一般提问", "从'制度流程查询','绘图','闲聊','一般提问'中选择一项作为你对{user_input}的意图的判断结果") }).start() ) print('__') print(route) print('__') print('路由判断',route['intention']) return route['intention']
闲聊Agent
def get_agent_response_chatting(question:str,history): agent_standard_senior = ( agent_factory_zhipu.create_agent('standard_role') .set_settings("model.ZhipuAI.options", {"model": "glm-4"})
制度流程查询Agent
def get_agent_response_processSystem(question,history): def print_streaming_content(data: str): print(data, end="") tool_info = { "tool_name": "流程制度查询工具", "desc": "从知识库文档中查询公司流程及制度", "args": { "context": ( "str", "要查询的相关制度流程内容,使用中文字符串" ) }, "func": get_search_result }
创建该生命周期智能体:考虑到文档查询用量,使用便宜的模型--穷啊
def ai_response(question,history): if route_agent(question,history)=='制度流程查询': print('流程查询') return get_agent_response_processSystem(question,history) else: print('定位失败') return get_agent_response_chatting(question,history)
if name == 'main':
print(get_agent_response_processSystem('信息系统建设管理办法有哪些内容'))