feat(agent): Release agent SDK (#1396)

This commit is contained in:
Fangyin Cheng
2024-04-10 22:44:53 +08:00
committed by GitHub
parent 37e7c0151b
commit df80bc2079
152 changed files with 5680 additions and 6114 deletions

View File

@@ -16,27 +16,23 @@
import asyncio
import os
from dbgpt.agent.agents.agent import AgentContext
from dbgpt.agent.agents.expand.code_assistant_agent import CodeAssistantAgent
from dbgpt.agent.agents.llm.llm import LLMConfig
from dbgpt.agent.agents.user_proxy_agent import UserProxyAgent
from dbgpt.agent.memory.gpts_memory import GptsMemory
from dbgpt.agent.resource.resource_api import AgentResource, ResourceType
from dbgpt.agent.resource.resource_loader import ResourceLoader
from dbgpt.agent.resource.resource_plugin_api import PluginFileLoadClient
from dbgpt.core.interface.llm import ModelMetadata
from dbgpt.serve.agent.team.plan.team_auto_plan import AutoPlanChatManager
from dbgpt.agent import (
AgentContext,
GptsMemory,
LLMConfig,
ResourceLoader,
UserProxyAgent,
)
from dbgpt.agent.expand.code_assistant_agent import CodeAssistantAgent
from dbgpt.agent.plan import AutoPlanChatManager
async def main():
from dbgpt.model import OpenAILLMClient
from dbgpt.model.proxy import OpenAILLMClient
llm_client = OpenAILLMClient(model_alias="gpt-3.5-turbo")
context: AgentContext = AgentContext(
conv_id="test456", team_mode=Team, gpts_app_name="代码分析助手"
)
llm_client = OpenAILLMClient(model_alias="gpt-4")
context: AgentContext = AgentContext(conv_id="test456", gpts_app_name="代码分析助手")
default_memory = GptsMemory()
@@ -62,7 +58,7 @@ async def main():
user_proxy = await UserProxyAgent().bind(context).bind(default_memory).build()
await user_proxy.a_initiate_chat(
await user_proxy.initiate_chat(
recipient=manager,
reviewer=user_proxy,
message="Obtain simple information about issues in the repository 'eosphoros-ai/DB-GPT' in the past three days and analyze the data. Create a Markdown table grouped by day and status.",
@@ -70,7 +66,7 @@ async def main():
# message="find papers on LLM applications from arxiv in the last month, create a markdown table of different domains.",
)
print(await default_memory.one_chat_competions("test456"))
print(await default_memory.one_chat_completions("test456"))
if __name__ == "__main__":

View File

@@ -11,31 +11,32 @@
run example.
..code-block:: shell
python examples/agents/auto_plan_agent_dialogue_example.py
python examples/agents/awel_layout_agents_chat_examples.py
"""
import asyncio
import os
from dbgpt.agent.agents.agent import AgentContext
from dbgpt.agent.agents.expand.plugin_assistant_agent import PluginAssistantAgent
from dbgpt.agent.agents.expand.summary_assistant_agent import SummaryAssistantAgent
from dbgpt.agent.agents.llm.llm import LLMConfig
from dbgpt.agent.agents.user_proxy_agent import UserProxyAgent
from dbgpt.agent.memory.gpts_memory import GptsMemory
from dbgpt.agent.resource.resource_api import AgentResource, ResourceType
from dbgpt.agent.resource.resource_loader import ResourceLoader
from dbgpt.agent.resource.resource_plugin_api import PluginFileLoadClient
from dbgpt.core.interface.llm import ModelMetadata
from dbgpt.serve.agent.team.layout.team_awel_layout import AwelLayoutChatManager
from dbgpt.agent import (
AgentContext,
AgentResource,
GptsMemory,
LLMConfig,
ResourceLoader,
ResourceType,
UserProxyAgent,
)
from dbgpt.agent.expand.plugin_assistant_agent import PluginAssistantAgent
from dbgpt.agent.expand.summary_assistant_agent import SummaryAssistantAgent
from dbgpt.agent.plan import WrappedAWELLayoutManager
from dbgpt.agent.resource import PluginFileLoadClient
from dbgpt.configs.model_config import ROOT_PATH
current_dir = os.getcwd()
parent_dir = os.path.dirname(current_dir)
test_plugin_dir = os.path.join(parent_dir, "test_files/plugins")
test_plugin_dir = os.path.join(ROOT_PATH, "examples/test_files/plugins")
async def main():
from dbgpt.model import OpenAILLMClient
from dbgpt.model.proxy import OpenAILLMClient
llm_client = OpenAILLMClient(model_alias="gpt-3.5-turbo")
context: AgentContext = AgentContext(conv_id="test456", gpts_app_name="信息析助手")
@@ -44,7 +45,7 @@ async def main():
resource_loader = ResourceLoader()
plugin_file_loader = PluginFileLoadClient()
resource_loader.register_resesource_api(plugin_file_loader)
resource_loader.register_resource_api(plugin_file_loader)
plugin_resource = AgentResource(
type=ResourceType.Plugin,
@@ -52,7 +53,7 @@ async def main():
value=test_plugin_dir,
)
tool_enginer = (
tool_engineer = (
await PluginAssistantAgent()
.bind(context)
.bind(LLMConfig(llm_client=llm_client))
@@ -70,17 +71,17 @@ async def main():
)
manager = (
await AwelLayoutChatManager()
await WrappedAWELLayoutManager()
.bind(context)
.bind(default_memory)
.bind(LLMConfig(llm_client=llm_client))
.build()
)
manager.hire([tool_enginer, summarizer])
manager.hire([tool_engineer, summarizer])
user_proxy = await UserProxyAgent().bind(context).bind(default_memory).build()
await user_proxy.a_initiate_chat(
await user_proxy.initiate_chat(
recipient=manager,
reviewer=user_proxy,
message="查询成都今天天气",
@@ -89,7 +90,7 @@ async def main():
# message="find papers on LLM applications from arxiv in the last month, create a markdown table of different domains.",
)
print(await default_memory.one_chat_competions("test456"))
print(await default_memory.one_chat_completions("test456"))
if __name__ == "__main__":

View File

@@ -11,22 +11,23 @@
run example.
..code-block:: shell
python examples/agents/single_agent_dialogue_example.py
python examples/agents/plugin_agent_dialogue_example.py
"""
import asyncio
import os
from dbgpt.agent.actions.plugin_action import PluginAction
from dbgpt.agent.agents.agent import AgentContext
from dbgpt.agent.agents.expand.plugin_assistant_agent import PluginAssistantAgent
from dbgpt.agent.agents.llm.llm import LLMConfig
from dbgpt.agent.agents.user_proxy_agent import UserProxyAgent
from dbgpt.agent.memory.gpts_memory import GptsMemory
from dbgpt.agent.resource.resource_api import AgentResource, ResourceType
from dbgpt.agent.resource.resource_loader import ResourceLoader
from dbgpt.agent.resource.resource_plugin_api import PluginFileLoadClient
from dbgpt.core.interface.llm import ModelMetadata
from dbgpt.agent import (
AgentContext,
AgentResource,
GptsMemory,
LLMConfig,
ResourceLoader,
ResourceType,
UserProxyAgent,
)
from dbgpt.agent.expand.plugin_assistant_agent import PluginAssistantAgent
from dbgpt.agent.resource import PluginFileLoadClient
current_dir = os.getcwd()
parent_dir = os.path.dirname(current_dir)
@@ -34,7 +35,7 @@ test_plugin_dir = os.path.join(parent_dir, "test_files/plugins")
async def main():
from dbgpt.model import OpenAILLMClient
from dbgpt.model.proxy import OpenAILLMClient
llm_client = OpenAILLMClient(model_alias="gpt-3.5-turbo")
context: AgentContext = AgentContext(conv_id="test456")
@@ -49,11 +50,11 @@ async def main():
resource_loader = ResourceLoader()
plugin_file_loader = PluginFileLoadClient()
resource_loader.register_resesource_api(plugin_file_loader)
resource_loader.register_resource_api(plugin_file_loader)
user_proxy = await UserProxyAgent().bind(default_memory).bind(context).build()
tool_enginer = (
tool_engineer = (
await PluginAssistantAgent()
.bind(context)
.bind(LLMConfig(llm_client=llm_client))
@@ -63,14 +64,14 @@ async def main():
.build()
)
await user_proxy.a_initiate_chat(
recipient=tool_enginer,
await user_proxy.initiate_chat(
recipient=tool_engineer,
reviewer=user_proxy,
message="查询今天成都的天气",
)
## dbgpt-vis message infos
print(await default_memory.one_chat_competions("test456"))
print(await default_memory.one_chat_completions("test456"))
if __name__ == "__main__":

View File

@@ -17,50 +17,50 @@
import asyncio
import os
from dbgpt.agent.agents.agent import AgentContext
from dbgpt.agent.agents.expand.retrieve_summary_assistant_agent import (
from dbgpt.agent import AgentContext, GptsMemory, LLMConfig, UserProxyAgent
from dbgpt.agent.expand.retrieve_summary_assistant_agent import (
RetrieveSummaryAssistantAgent,
)
from dbgpt.agent.agents.user_proxy_agent import UserProxyAgent
from dbgpt.agent.memory.gpts_memory import GptsMemory
from dbgpt.core.interface.llm import ModelMetadata
from dbgpt.configs.model_config import ROOT_PATH
def summary_example_with_success():
async def summary_example_with_success():
from dbgpt.model.proxy import OpenAILLMClient
llm_client = OpenAILLMClient()
context: AgentContext = AgentContext(
conv_id="retrieve_summarize", llm_provider=llm_client
)
context.llm_models = [ModelMetadata(model="gpt-3.5-turbo-16k")]
llm_client = OpenAILLMClient(model_alias="gpt-3.5-turbo-16k")
context: AgentContext = AgentContext(conv_id="retrieve_summarize")
default_memory = GptsMemory()
summarizer = RetrieveSummaryAssistantAgent(
memory=default_memory, agent_context=context
summarizer = (
await RetrieveSummaryAssistantAgent()
.bind(context)
.bind(LLMConfig(llm_client=llm_client))
.bind(default_memory)
.build()
)
user_proxy = UserProxyAgent(memory=default_memory, agent_context=context)
asyncio.run(
user_proxy.a_initiate_chat(
recipient=summarizer,
reviewer=user_proxy,
message="""I want to summarize advantages of Nuclear Power.
You can refer the following file pathes and URLs: ['/home/ubuntu/DB-GPT/examples/Nuclear_power.pdf', 'https://en.wikipedia.org/wiki/Modern_Family', '/home/ubuntu/DB-GPT/examples/Taylor_Swift.pdf', 'https://en.wikipedia.org/wiki/Chernobyl_disaster']
""",
)
paths_urls = [
os.path.join(ROOT_PATH, "examples/agents/example_files/Nuclear_power.pdf"),
os.path.join(ROOT_PATH, "examples/agents/example_files/Taylor_Swift.pdf"),
"https://en.wikipedia.org/wiki/Modern_Family",
"https://en.wikipedia.org/wiki/Chernobyl_disaster",
]
await user_proxy.initiate_chat(
recipient=summarizer,
reviewer=user_proxy,
message=f"I want to summarize advantages of Nuclear Power. You can refer the "
f"following file paths and URLs: {paths_urls}",
)
## dbgpt-vis message infos
print(asyncio.run(default_memory.one_plan_chat_competions("retrieve_summarize")))
# dbgpt-vis message infos
print(await default_memory.one_chat_completions("retrieve_summarize"))
if __name__ == "__main__":
print(
"\033[92m=======================Start The Summary Assistant with Successful Results==================\033[0m"
)
summary_example_with_success()
asyncio.run(summary_example_with_success())
print(
"\033[92m=======================The Summary Assistant with Successful Results Ended==================\n\n\033[91m"
)

View File

@@ -15,17 +15,13 @@
"""
import asyncio
import os
from dbgpt.agent.agents.agent import AgentContext
from dbgpt.agent.agents.expand.code_assistant_agent import CodeAssistantAgent
from dbgpt.agent.agents.llm.llm import LLMConfig
from dbgpt.agent.agents.user_proxy_agent import UserProxyAgent
from dbgpt.agent.memory.gpts_memory import GptsMemory
from dbgpt.agent import AgentContext, GptsMemory, LLMConfig, UserProxyAgent
from dbgpt.agent.expand.code_assistant_agent import CodeAssistantAgent
async def main():
from dbgpt.model import OpenAILLMClient
from dbgpt.model.proxy import OpenAILLMClient
llm_client = OpenAILLMClient(model_alias="gpt-3.5-turbo")
context: AgentContext = AgentContext(conv_id="test123")
@@ -41,14 +37,14 @@ async def main():
user_proxy = await UserProxyAgent().bind(context).bind(default_memory).build()
await user_proxy.a_initiate_chat(
await user_proxy.initiate_chat(
recipient=coder,
reviewer=user_proxy,
message="式计算下321 * 123等于多少", # 用python代码的方式计算下321 * 123等于多少
# message="download data from https://raw.githubusercontent.com/uwdata/draco/master/data/cars.csv and plot a visualization that tells us about the relationship between weight and horsepower. Save the plot to a file. Print the fields in a dataset before visualizing it.",
)
## dbgpt-vis message infos
print(await default_memory.one_chat_competions("test123"))
print(await default_memory.one_chat_completions("test123"))
if __name__ == "__main__":

View File

@@ -15,17 +15,13 @@
"""
import asyncio
import os
from dbgpt.agent.agents.agent import AgentContext
from dbgpt.agent.agents.expand.summary_assistant_agent import SummaryAssistantAgent
from dbgpt.agent.agents.llm.llm import LLMConfig
from dbgpt.agent.agents.user_proxy_agent import UserProxyAgent
from dbgpt.agent.memory.gpts_memory import GptsMemory
from dbgpt.agent import AgentContext, GptsMemory, LLMConfig, UserProxyAgent
from dbgpt.agent.expand.summary_assistant_agent import SummaryAssistantAgent
async def summary_example_with_success():
from dbgpt.model import OpenAILLMClient
from dbgpt.model.proxy import OpenAILLMClient
llm_client = OpenAILLMClient(model_alias="gpt-3.5-turbo")
context: AgentContext = AgentContext(conv_id="summarize")
@@ -42,7 +38,7 @@ async def summary_example_with_success():
user_proxy = await UserProxyAgent().bind(default_memory).bind(context).build()
await user_proxy.a_initiate_chat(
await user_proxy.initiate_chat(
recipient=summarizer,
reviewer=user_proxy,
message="""I want to summarize advantages of Nuclear Power according to the following content.
@@ -76,11 +72,11 @@ async def summary_example_with_success():
)
## dbgpt-vis message infos
print(await default_memory.one_chat_competions("summarize"))
print(await default_memory.one_chat_completions("summarize"))
async def summary_example_with_faliure():
from dbgpt.model import OpenAILLMClient
from dbgpt.model.proxy import OpenAILLMClient
llm_client = OpenAILLMClient(model_alias="gpt-3.5-turbo")
context: AgentContext = AgentContext(conv_id="summarize")
@@ -99,7 +95,7 @@ async def summary_example_with_faliure():
# Test the failure example
await user_proxy.a_initiate_chat(
await user_proxy.initiate_chat(
recipient=summarizer,
reviewer=user_proxy,
message="""I want to summarize advantages of Nuclear Power according to the following content.
@@ -116,7 +112,7 @@ async def summary_example_with_faliure():
""",
)
print(await default_memory.one_chat_competions("summarize"))
print(await default_memory.one_chat_completions("summarize"))
if __name__ == "__main__":

View File

@@ -17,14 +17,17 @@
import asyncio
import os
from dbgpt.agent.agents.agent import AgentContext
from dbgpt.agent.agents.expand.data_scientist_agent import DataScientistAgent
from dbgpt.agent.agents.llm.llm import LLMConfig
from dbgpt.agent.agents.user_proxy_agent import UserProxyAgent
from dbgpt.agent.memory.gpts_memory import GptsMemory
from dbgpt.agent.resource.resource_api import AgentResource, ResourceType
from dbgpt.agent.resource.resource_db_api import SqliteLoadClient
from dbgpt.agent.resource.resource_loader import ResourceLoader
from dbgpt.agent import (
AgentContext,
AgentResource,
GptsMemory,
LLMConfig,
ResourceLoader,
ResourceType,
UserProxyAgent,
)
from dbgpt.agent.expand.data_scientist_agent import DataScientistAgent
from dbgpt.agent.resource import SqliteLoadClient
current_dir = os.getcwd()
parent_dir = os.path.dirname(current_dir)
@@ -47,7 +50,7 @@ async def main():
resource_loader = ResourceLoader()
sqlite_file_loader = SqliteLoadClient()
resource_loader.register_resesource_api(sqlite_file_loader)
resource_loader.register_resource_api(sqlite_file_loader)
user_proxy = await UserProxyAgent().bind(default_memory).bind(context).build()
@@ -61,14 +64,14 @@ async def main():
.build()
)
await user_proxy.a_initiate_chat(
await user_proxy.initiate_chat(
recipient=sql_boy,
reviewer=user_proxy,
message="当前库有那些表",
)
## dbgpt-vis message infos
print(await default_memory.one_chat_competions("test456"))
print(await default_memory.one_chat_completions("test456"))
if __name__ == "__main__":

View File

@@ -2,8 +2,8 @@ import os
from typing import Any, Dict, Optional
from pandas import DataFrame
from pydantic import BaseModel, Field
from dbgpt._private.pydantic import BaseModel, Field
from dbgpt.configs.model_config import MODEL_PATH, PILOT_PATH
from dbgpt.core import LLMClient, ModelMessage, ModelMessageRoleType, ModelRequest
from dbgpt.core.awel import DAG, HttpTrigger, JoinOperator, MapOperator

File diff suppressed because one or more lines are too long

View File

@@ -2,162 +2,162 @@
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"id": "6de2e0bb",
"metadata": {},
"outputs": [],
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-10T04:37:21.832993Z",
"start_time": "2024-04-10T04:37:21.828221Z"
}
},
"source": [
"\"\"\"Agents: auto plan agents example?\n",
"\n",
" Examples:\n",
"\n",
" Execute the following command in the terminal:\n",
" Set env params.\n",
" .. code-block:: shell\n",
"\n",
" export OPENAI_API_KEY=sk-xx\n",
" export OPENAI_API_BASE=https://xx:80/v1\n",
"\n",
" run example.\n",
" ..code-block:: shell\n",
" python examples/agents/auto_plan_agent_dialogue_example.py\n",
"\"\"\"\n",
"\n",
"import os\n",
"from dbgpt.agent.agents.user_proxy_agent import UserProxyAgent\n",
"from dbgpt.serve.agent.team.layout.team_awel_layout import AwelLayoutChatManger\n",
"from dbgpt.agent.agents.expand.plugin_assistant_agent import PluginAssistantAgent\n",
"from dbgpt.agent.agents.expand.summary_assistant_agent import SummaryAssistantAgent\n",
"import nest_asyncio\n",
"from dbgpt.agent import (\n",
" AgentContext,\n",
" AgentResource,\n",
" GptsMemory,\n",
" LLMConfig,\n",
" ResourceLoader,\n",
" ResourceType,\n",
" UserProxyAgent,\n",
")\n",
"from dbgpt.agent.expand.plugin_assistant_agent import PluginAssistantAgent\n",
"from dbgpt.agent.expand.summary_assistant_agent import SummaryAssistantAgent\n",
"from dbgpt.agent.plan import WrappedAWELLayoutManager\n",
"from dbgpt.agent.resource import PluginFileLoadClient\n",
"from dbgpt.configs.model_config import ROOT_PATH\n",
"from dbgpt.model.proxy import OpenAILLMClient\n",
"\n",
"from dbgpt.agent.agents.agent import AgentContext\n",
"from dbgpt.agent.memory.gpts_memory import GptsMemory\n",
"from dbgpt.core.interface.llm import ModelMetadata\n",
"\n",
"import asyncio\n",
"\n",
"from dbgpt.model import OpenAILLMClient"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "153c9e0e",
"metadata": {},
"nest_asyncio.apply()\n",
"test_plugin_dir = os.path.join(ROOT_PATH, \"examples/test_files/plugins\")"
],
"outputs": [],
"source": [
"current_dir = os.getcwd()\n",
"parent_dir = os.path.dirname(current_dir)\n",
"test_plugin_dir = os.path.join(parent_dir, \"test_files\")"
]
"execution_count": 11
},
{
"cell_type": "code",
"execution_count": 8,
"id": "437b9c40",
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2024-04-10T04:37:27.592117Z",
"start_time": "2024-04-10T04:37:23.569538Z"
}
},
"source": [
"# os.environ['OPENAI_API_KEY']=\"sk-x\"\n",
"# os.environ['OPENAI_API_BASE']=\"https://proxy_url/v1\"\n",
"# os.environ['SEARCH_ENGINE']=\"baidu\"\n",
"# os.environ['BAIDU_COOKIE']=\"\"\"your baidu cookie\"\"\"\n",
"\n",
"llm_client = OpenAILLMClient(model_alias=\"gpt-3.5-turbo\")\n",
"context: AgentContext = AgentContext(conv_id=\"test456\", gpts_app_name=\"信息析助手\")\n",
"\n",
"default_memory = GptsMemory()\n",
"\n",
"resource_loader = ResourceLoader()\n",
"plugin_file_loader = PluginFileLoadClient()\n",
"resource_loader.register_resource_api(plugin_file_loader)\n",
"\n",
"plugin_resource = AgentResource(\n",
" type=ResourceType.Plugin,\n",
" name=\"test\",\n",
" value=test_plugin_dir,\n",
")\n",
"\n",
"tool_engineer = (\n",
" await PluginAssistantAgent()\n",
" .bind(context)\n",
" .bind(LLMConfig(llm_client=llm_client))\n",
" .bind(default_memory)\n",
" .bind([plugin_resource])\n",
" .bind(resource_loader)\n",
" .build()\n",
")\n",
"summarizer = (\n",
" await SummaryAssistantAgent()\n",
" .bind(context)\n",
" .bind(default_memory)\n",
" .bind(LLMConfig(llm_client=llm_client))\n",
" .build()\n",
")\n",
"\n",
"manager = (\n",
" await WrappedAWELLayoutManager()\n",
" .bind(context)\n",
" .bind(default_memory)\n",
" .bind(LLMConfig(llm_client=llm_client))\n",
" .build()\n",
")\n",
"manager.hire([tool_engineer, summarizer])\n",
"\n",
"user_proxy = await UserProxyAgent().bind(context).bind(default_memory).build()\n",
"\n",
"await user_proxy.initiate_chat(\n",
" recipient=manager,\n",
" reviewer=user_proxy,\n",
" message=\"查询成都今天天气\",\n",
" # message=\"查询今天的最新热点财经新闻\",\n",
")"
],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[33mUser\u001b[0m (to layout_manager)-[]:\n",
"\n",
"\"查询成都今天天气\"\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33mlayout_manager\u001b[0m (to ToolScientist)-[]:\n",
"\u001B[33mWrappedAWELLayoutManager\u001B[0m (to LuBan)-[]:\n",
"\n",
"\"查询成都今天天气\"\n",
"\n",
"--------------------------------------------------------------------------------\n",
"un_stream ai response: {\n",
" \"tool_name\": \"google_search\",\n",
" \"tool_name\": \"baidu_search\",\n",
" \"args\": {\n",
" \"query\": \"成都今天天气\"\n",
" },\n",
" \"thought\": \"I will use the google-search tool to search for the weather in Chengdu today.\"\n",
" \"thought\": \"I have selected the 'baidu_search' tool with the query parameter set to '成都今天天气' to search for the weather in Chengdu today.\"\n",
"}\n",
"{'query': '成都今天天气'}\n",
"_google_search:成都今天天气\n",
"\u001b[33mToolScientist\u001b[0m (to Summarizer)-[gpt-3.5-turbo]:\n",
"\n",
"\"{\\n \\\"tool_name\\\": \\\"google_search\\\",\\n \\\"args\\\": {\\n \\\"query\\\": \\\"成都今天天气\\\"\\n },\\n \\\"thought\\\": \\\"I will use the google-search tool to search for the weather in Chengdu today.\\\"\\n}\"\n",
"\u001b[32m>>>>>>>>ToolScientist Review info: \n",
" Pass.None\u001b[0m\n",
"\u001b[34m>>>>>>>>ToolScientist Action report: \n",
"execution succeeded,\n",
"Error: Please configure GOOGLE_API_KEY and GOOGLE_API_CX in .env first!\u001b[0m\n",
"\n",
"--------------------------------------------------------------------------------\n",
"un_stream ai response: The User's Question: 查询成都今天天气\n",
"\u001B[33mLuBan\u001B[0m (to Aristotle)-[gpt-3.5-turbo]:\n",
"\n",
"今天成都的天气预报是晴天最高温度约为28摄氏度最低温度约为16摄氏度。\n",
"\u001b[33mSummarizer\u001b[0m (to layout_manager)-[gpt-3.5-turbo]:\n",
"\n",
"\"The User's Question: 查询成都今天天气\\n\\n今天成都的天气预报是晴天最高温度约为28摄氏度最低温度约为16摄氏度。\"\n",
"\u001b[32m>>>>>>>>Summarizer Review info: \n",
" Pass.None\u001b[0m\n",
"\u001b[34m>>>>>>>>Summarizer Action report: \n",
"\"{\\n \\\"tool_name\\\": \\\"baidu_search\\\",\\n \\\"args\\\": {\\n \\\"query\\\": \\\"成都今天天气\\\"\\n },\\n \\\"thought\\\": \\\"I have selected the 'baidu_search' tool with the query parameter set to '成都今天天气' to search for the weather in Chengdu today.\\\"\\n}\"\n",
"\u001B[32m>>>>>>>>LuBan Review info: \n",
"Pass(None)\u001B[0m\n",
"\u001B[34m>>>>>>>>LuBan Action report: \n",
"execution succeeded,\n",
"The User's Question: 查询成都今天天气\n",
"\n",
"今天成都天气预报是晴天最高温度约为28摄氏度最低温度约为16摄氏度。\u001b[0m\n",
"### [...天气预报一周_成都天气预报7天、15天、40天天查询_中国...](http://www.baidu.com/link?url=nSNTTnrxEUFL7oMRAYqg98BfeXkWtwHUaYN7WrTjaxBpSy0blKc4jIZ9m34mP97fFARfXJStjbRoBN6U0s0BDq) \n",
" \n",
"### [成都天气_成都天气预报一周_成都天气预报15天](http://www.baidu.com/link?url=Fmp4cnf8Cqqd8N06PpAe3Mn6Esp5q39Scfsnfr7ALxqB5XfoWu9-wY5UjS4n-95Y) \n",
" \n",
"### [【成都天气】成都天气预报,蓝天,蓝天预报,雾霾,雾霾消散,...](http://www.baidu.com/link?url=BQF3cexr1Z6hqkdOjRO2pq8YnOuruBV8nBFY0LE7FJJl8_TCcO806skK-aWkmC8UAZ23K-v3SvoXO58Ayze7Da) \n",
" \n",
"### [...天气预报一周_成都天气预报7天、15天、40天天查询_中国...](http://www.baidu.com/link?url=rt26_NNSBBWHLr0rAX2RPUbBhVjfr4m3Cd21RG7MOe4gsirRquQyp5fMLbSfeU1iC2b1ZhNVjUzlex39iYN_wq) \n",
" \n",
"### [【成都天气预报15天_成都天气预报15天查询】-中国天气网](http://www.baidu.com/link?url=vnZ3GlUxqllZ7Lenc94cImrur2AixgD6dkSOxfNc63PTewisg-RXg3sKzLpBEuPgCWXLr9VnR9gsSZetfPA_94HdTG0It_uAvZpLdUiGmY_) \n",
" \n",
"\u001B[0m\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001b[33mlayout_manager\u001b[0m (to User)-[None]:\n",
"un_stream ai response: Did not find the information you want.\n",
"\n",
"--------------------------------------------------------------------------------\n",
"\u001B[33mWrappedAWELLayoutManager\u001B[0m (to User)-[]:\n",
"\n",
"\"查询成都今天天气\"\n",
"\u001b[32m>>>>>>>>layout_manager Review info: \n",
" Pass.None\u001b[0m\n",
"\u001b[34m>>>>>>>>layout_manager Action report: \n",
"\u001B[32m>>>>>>>>WrappedAWELLayoutManager Review info: \n",
"Pass(None)\u001B[0m\n",
"\u001B[34m>>>>>>>>WrappedAWELLayoutManager Action report: \n",
"execution succeeded,\n",
"The User's Question: 查询成都今天天气\n",
"\n",
"今天成都的天气预报是晴天最高温度约为28摄氏度最低温度约为16摄氏度。\u001b[0m\n",
"Did not find the information you want.\u001B[0m\n",
"\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"source": [
"os.environ['OPENAI_API_KEY']=\"sk-x\"\n",
"os.environ['OPENAI_API_BASE']=\"https://proxy_url/v1\"\n",
"os.environ['BAIDU_COOKIE']=\"\"\"your baidu cookie\"\"\"\n",
"\n",
"llm_client = OpenAILLMClient()\n",
"context: AgentContext = AgentContext(conv_id=\"test456\", llm_provider=llm_client)\n",
"context.llm_models = [ModelMetadata(model=\"gpt-3.5-turbo\")]\n",
"context.gpts_name = \"信息析助手\"\n",
"\n",
"default_memory = GptsMemory()\n",
"manager = AwelLayoutChatManger(\n",
" agent_context=context,\n",
" memory=default_memory,\n",
")\n",
"\n",
"### agents\n",
"tool_enginer = PluginAssistantAgent(\n",
" agent_context=context,\n",
" memory=default_memory,\n",
" plugin_path=test_plugin_dir,\n",
")\n",
"summarizer = SummaryAssistantAgent(\n",
" agent_context=context,\n",
" memory=default_memory,\n",
")\n",
"\n",
"manager.hire([tool_enginer, summarizer])\n",
"\n",
"user_proxy = UserProxyAgent(memory=default_memory, agent_context=context)\n",
"\n",
"\n",
"await user_proxy.a_initiate_chat(\n",
" recipient=manager,\n",
" reviewer=user_proxy,\n",
" message=\"查询成都今天天气\",\n",
")\n",
"\n"
]
"execution_count": 12
},
{
"cell_type": "code",

View File

@@ -25,9 +25,8 @@
import os
from typing import Dict, List
from pydantic import BaseModel, Field
from dbgpt._private.config import Config
from dbgpt._private.pydantic import BaseModel, Field
from dbgpt.configs.model_config import EMBEDDING_MODEL_CONFIG, PILOT_PATH
from dbgpt.core import Chunk
from dbgpt.core.awel import DAG, HttpTrigger, InputOperator, JoinOperator, MapOperator

View File

@@ -14,9 +14,8 @@
import os
from typing import Dict, List
from pydantic import BaseModel, Field
from dbgpt._private.config import Config
from dbgpt._private.pydantic import BaseModel, Field
from dbgpt.configs.model_config import EMBEDDING_MODEL_CONFIG, PILOT_PATH
from dbgpt.core.awel import DAG, HttpTrigger, MapOperator
from dbgpt.rag.embedding import DefaultEmbeddingFactory

View File

@@ -29,9 +29,8 @@
import os
from typing import Dict, List
from pydantic import BaseModel, Field
from dbgpt._private.config import Config
from dbgpt._private.pydantic import BaseModel, Field
from dbgpt.configs.model_config import EMBEDDING_MODEL_CONFIG, PILOT_PATH
from dbgpt.core import Chunk
from dbgpt.core.awel import DAG, HttpTrigger, JoinOperator, MapOperator