feature: add productization capabilities for agentUniverse.
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -3,7 +3,7 @@ description: '百度(必应)搜索工具,输入为一个要搜索内容的字
|
||||
tool_type: 'api'
|
||||
input_keys: ['input']
|
||||
engine: 'baidu'
|
||||
search_type: 'json'
|
||||
search_type: 'common'
|
||||
search_params:
|
||||
num: 10
|
||||
metadata:
|
||||
|
||||
BIN
sample_standard_app/app/resources/baidu_search.png
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
sample_standard_app/app/resources/bing_search.jpg
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
sample_standard_app/app/resources/discussion_group_logo.png
Normal file
|
After Width: | Height: | Size: 57 KiB |
BIN
sample_standard_app/app/resources/google_search.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
sample_standard_app/app/resources/law_agent_logo.png
Normal file
|
After Width: | Height: | Size: 98 KiB |
BIN
sample_standard_app/app/resources/peer_agent_logo.png
Normal file
|
After Width: | Height: | Size: 59 KiB |
BIN
sample_standard_app/app/resources/python_tool.png
Normal file
|
After Width: | Height: | Size: 6.8 KiB |
BIN
sample_standard_app/app/resources/rag_agent_logo.png
Normal file
|
After Width: | Height: | Size: 93 KiB |
BIN
sample_standard_app/app/resources/react_agent_logo.png
Normal file
|
After Width: | Height: | Size: 311 KiB |