Commit 396700dd authored by chenzk's avatar chenzk
Browse files

v1.0

parents
Pipeline #2603 failed with stages
in 0 seconds
window.onload = function() {
if (window.location.pathname == '/' || window.location.pathname == "") {
window.location.href = '/docs/overview';
}
};
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
# TODO add example run code here
import asyncio
# Agents examples
from .agents.auto_plan_agent_dialogue_example import main as auto_plan_main
from .agents.awel_layout_agents_chat_examples import main as awel_layout_main
from .agents.custom_tool_agent_example import main as custom_tool_main
from .agents.plugin_agent_dialogue_example import main as plugin_main
from .agents.retrieve_summary_agent_dialogue_example import (
main as retrieve_summary_main,
)
from .agents.sandbox_code_agent_example import main as sandbox_code_main
from .agents.single_agent_dialogue_example import main as single_agent_main
from .agents.sql_agent_dialogue_example import main as sql_main
if __name__ == "__main__":
# Run the examples
## Agent examples
asyncio.run(auto_plan_main())
asyncio.run(awel_layout_main())
asyncio.run(custom_tool_main())
asyncio.run(retrieve_summary_main())
asyncio.run(plugin_main())
asyncio.run(sandbox_code_main())
asyncio.run(single_agent_main())
asyncio.run(sql_main())
## awel examples
print("hello world!")
"""Agents: auto plan agents example?
Examples:
Execute the following command in the terminal:
Set env params.
.. code-block:: shell
export SILICONFLOW_API_KEY=sk-xx
export SILICONFLOW_API_BASE=https://xx:80/v1
run example.
..code-block:: shell
python examples/agents/auto_plan_agent_dialogue_example.py
"""
import asyncio
import os
from dbgpt.agent import (
AgentContext,
AgentMemory,
AutoPlanChatManager,
LLMConfig,
UserProxyAgent,
)
from dbgpt.agent.expand.code_assistant_agent import CodeAssistantAgent
from dbgpt.util.tracer import initialize_tracer
initialize_tracer(
"/tmp/agent_auto_plan_agent_dialogue_example_trace.jsonl", create_system_app=True
)
async def main():
from dbgpt.model.proxy.llms.siliconflow import SiliconFlowLLMClient
agent_memory = AgentMemory()
llm_client = SiliconFlowLLMClient(
model_alias=os.getenv(
"SILICONFLOW_MODEL_VERSION", "Qwen/Qwen2.5-Coder-32B-Instruct"
),
)
context: AgentContext = AgentContext(
conv_id="test456", gpts_app_name="代码分析助手", max_new_tokens=2048
)
agent_memory = AgentMemory()
agent_memory.gpts_memory.init(conv_id="test456")
try:
coder = (
await CodeAssistantAgent()
.bind(context)
.bind(LLMConfig(llm_client=llm_client))
.bind(agent_memory)
.build()
)
manager = (
await AutoPlanChatManager()
.bind(context)
.bind(agent_memory)
.bind(LLMConfig(llm_client=llm_client))
.build()
)
manager.hire([coder])
user_proxy = await UserProxyAgent().bind(context).bind(agent_memory).build()
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.",
# message="Find papers on gpt-4 in the past three weeks on arxiv, and organize their titles, authors, and links into a markdown table",
# message="find papers on LLM applications from arxiv in the last month, create a markdown table of different domains.",
)
finally:
agent_memory.gpts_memory.clear(conv_id="test456")
if __name__ == "__main__":
## dbgpt-vis message infos
asyncio.run(main())
"""Agents: auto plan agents example?
Examples:
Execute the following command in the terminal:
Set env params.
.. code-block:: shell
export SILICONFLOW_API_KEY=sk-xx
export SILICONFLOW_API_BASE=https://xx:80/v1
run example.
..code-block:: shell
python examples/agents/awel_layout_agents_chat_examples.py
"""
import asyncio
import os
from dbgpt.agent import (
AgentContext,
AgentMemory,
LLMConfig,
UserProxyAgent,
WrappedAWELLayoutManager,
)
from dbgpt.agent.expand.resources.search_tool import baidu_search
from dbgpt.agent.expand.summary_assistant_agent import SummaryAssistantAgent
from dbgpt.agent.expand.tool_assistant_agent import ToolAssistantAgent
from dbgpt.agent.resource import ToolPack
from dbgpt.util.tracer import initialize_tracer
initialize_tracer("/tmp/agent_trace.jsonl", create_system_app=True)
async def main():
agent_memory = AgentMemory()
agent_memory.gpts_memory.init(conv_id="test456")
try:
from dbgpt.model.proxy.llms.siliconflow import SiliconFlowLLMClient
llm_client = SiliconFlowLLMClient(
model_alias=os.getenv(
"SILICONFLOW_MODEL_VERSION", "Qwen/Qwen2.5-Coder-32B-Instruct"
),
)
context: AgentContext = AgentContext(
conv_id="test456", gpts_app_name="信息析助手"
)
tools = ToolPack([baidu_search])
tool_engineer = (
await ToolAssistantAgent()
.bind(context)
.bind(LLMConfig(llm_client=llm_client))
.bind(agent_memory)
.bind(tools)
.build()
)
summarizer = (
await SummaryAssistantAgent()
.bind(context)
.bind(agent_memory)
.bind(LLMConfig(llm_client=llm_client))
.build()
)
manager = (
await WrappedAWELLayoutManager()
.bind(context)
.bind(agent_memory)
.bind(LLMConfig(llm_client=llm_client))
.build()
)
manager.hire([tool_engineer, summarizer])
user_proxy = await UserProxyAgent().bind(context).bind(agent_memory).build()
await user_proxy.initiate_chat(
recipient=manager,
reviewer=user_proxy,
message="查询北京今天天气",
# message="查询今天的最新热点财经新闻",
# message="Find papers on gpt-4 in the past three weeks on arxiv, and organize their titles, authors, and links into a markdown table",
# message="find papers on LLM applications from arxiv in the last month, create a markdown table of different domains.",
)
finally:
agent_memory.gpts_memory.clear(conv_id="test456")
if __name__ == "__main__":
## dbgpt-vis message infos
asyncio.run(main())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment