feature: add productization capabilities for agentUniverse.

This commit is contained in:
wangchongshi
2024-08-08 18:03:35 +08:00
parent bab32dcebb
commit 9218100cc6
20 changed files with 54 additions and 7 deletions

View File

@@ -7,10 +7,12 @@
# @FileName: stream_callback.py
import asyncio
from typing import Optional, Dict, Any
from typing import Optional, Dict, Any, Union
from uuid import UUID
from langchain_core.agents import AgentAction, AgentFinish
from langchain_core.callbacks import BaseCallbackHandler
from langchain_core.outputs import GenerationChunk, ChatGenerationChunk
class StreamOutPutCallbackHandler(BaseCallbackHandler):
@@ -43,6 +45,23 @@ class StreamOutPutCallbackHandler(BaseCallbackHandler):
}
})
def on_llm_new_token(
self,
token: str,
*,
chunk: Optional[Union[GenerationChunk, ChatGenerationChunk]] = None,
run_id: UUID,
parent_run_id: Optional[UUID] = None,
**kwargs: Any,
) -> Any:
self.queueStream.put_nowait({
"type": "token",
"data": {
"chunk": chunk.text,
"agent_info": self.agent_info
}
})
def on_tool_end(
self,
output: str,

View File

@@ -1,7 +1,12 @@
id: host_agent
nickname: 多智能体讨论组
opening_speech: 您好,欢迎使用多智能体讨论组,讨论组包含一名主持人和若干讨论组成员,根据您提出的问题,进行多轮组内讨论,最终由主持人总结讨论组的讨论结果,提供给您最终答案。
opening_speech: |
您好,欢迎使用多智能体讨论组,讨论组包含一名主持人和若干讨论组成员,根据您提出的问题,进行多轮组内讨论,最终由主持人总结讨论组的讨论结果,提供给您最终答案。
你可以这样问我:
问题1: 甜粽子好吃还是咸粽子好吃
问题2: 可口可乐好喝还是百事可乐好喝
type: AGENT
avatar: ../../../resources/discussion_group_logo.png
metadata:
class: AgentProduct
module: agentuniverse_product.base.agent_product

View File

@@ -1,7 +1,12 @@
id: law_rag_agent
nickname: 法律顾问智能体
opening_speech: 您好,欢迎使用法律顾问智能体,我将根据您给出的法律事件,以及提供的背景知识做出客观的司法判断。
opening_speech: |
您好,欢迎使用法律顾问智能体,我将根据您给出的法律事件,以及提供的背景知识做出客观的司法判断。
你可以这样问我:
问题1: 张三在景区拍摄景区风景,李四闯入了镜头并被拍下。李四能否起诉张三侵犯肖像权,能否要求删除照片
问题2: 入室抢劫和入室盗窃,哪个罪名更大
type: AGENT
avatar: ../../../resources/law_agent_logo.png
metadata:
class: AgentProduct
module: agentuniverse_product.base.agent_product

View File

@@ -1,7 +1,12 @@
id: demo_peer_agent
nickname: peer多智能体组
opening_speech: 您好欢迎使用PEER多智能体协同范式根据您提出的问题我将通过Planning智能体拆解问题Executing智能体逐个执行子问题Expressing智能体总结任务执行结果Reviewing智能体评估及反馈最终给您提供满意的答案。
opening_speech: |
您好欢迎使用PEER多智能体协同范式根据您提出的问题我将通过Planning智能体拆解问题Executing智能体逐个执行子问题Expressing智能体总结任务执行结果Reviewing智能体评估及反馈最终给您提供满意的答案。
你可以这样问我:
问题1: 英伟达股票还能买吗
问题2: 巴菲特为什么减持苹果股票
type: AGENT
avatar: ../../../resources/peer_agent_logo.png
metadata:
class: AgentProduct
module: agentuniverse_product.base.agent_product

View File

@@ -1,7 +1,12 @@
id: demo_rag_agent
nickname: rag智能体
type: AGENT
opening_speech: 欢迎使用rag chatbot根据您的提问我将结合实时信息及我个人掌握的知识给您提供合理的解答。
opening_speech: |
欢迎使用rag chatbot根据您的提问我将结合实时信息及我个人掌握的知识给您提供合理的解答。
你可以这样问我:
问题1: 巴黎奥运会美国男篮队员都有谁
问题2: 巴菲特为什么减持苹果股票
avatar: /Users/edwinwang/Work/agentUniverse/sample_standard_app/app/resources/rag_agent_logo.png
metadata:
class: AgentProduct
module: agentuniverse_product.base.agent_product

View File

@@ -1,7 +1,11 @@
id: demo_react_agent
nickname: ReAct智能体
opening_speech: 欢迎使用ReAct智能体根据您预先配置好的工具集结合您的提问我将进行自治的推理并采取行动最终给您提供满意的答案。
opening_speech: |
欢迎使用ReAct智能体根据您预先配置好的工具集结合您的提问我将进行自治的推理并采取行动最终给您提供满意的答案。
你可以这样问我:
问题: 请给出一段python代码可以计算三数之和给出之前必须验证代码是否可以运行最少验证1次
type: AGENT
avatar: ../../../resources/react_agent_logo.png
metadata:
class: AgentProduct
module: agentuniverse_product.base.agent_product

View File

@@ -1,6 +1,7 @@
id: search_api_baidu_tool
nickname: 百度web搜索工具
type: TOOL
avatar: ../../../resources/baidu_search.png
metadata:
type: 'PRODUCT'
module: 'agentuniverse_product.base.product'

View File

@@ -1,6 +1,7 @@
id: search_api_bing_tool
nickname: 必应web搜索工具
type: TOOL
avatar: ../../../resources/bing_search.jpg
metadata:
type: 'PRODUCT'
module: 'agentuniverse_product.base.product'

View File

@@ -1,6 +1,7 @@
id: google_search_tool
nickname: 谷歌web搜索工具
type: TOOL
avatar: ../../../resources/google_search.png
metadata:
type: 'PRODUCT'
module: 'agentuniverse_product.base.product'

View File

@@ -1,6 +1,7 @@
id: python_runner
nickname: 执行python代码工具输入为一段有效的python代码输出结果为python print打印出的response内容
type: TOOL
avatar: ../../../resources/python_tool.png
metadata:
type: 'PRODUCT'
module: 'agentuniverse_product.base.product'

View File

@@ -3,7 +3,7 @@ description: '百度(必应)搜索工具,输入为一个要搜索内容的字
tool_type: 'api'
input_keys: ['input']
engine: 'baidu'
search_type: 'json'
search_type: 'common'
search_params:
num: 10
metadata:

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 KiB