mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-14 05:31:40 +00:00
feat(agent): Multi agent sdk (#976)
Co-authored-by: xtyuns <xtyuns@163.com> Co-authored-by: Fangyin Cheng <staneyffer@gmail.com> Co-authored-by: csunny <cfqsunny@163.com> Co-authored-by: qidanrui <qidanrui@gmail.com>
This commit is contained in:
@@ -32,7 +32,7 @@ def async_db_summary(system_app: SystemApp):
|
||||
|
||||
|
||||
def server_init(param: "WebServerParameters", system_app: SystemApp):
|
||||
from dbgpt.agent.commands.command_mange import CommandRegistry
|
||||
from dbgpt.agent.plugin.commands.command_mange import CommandRegistry
|
||||
|
||||
# logger.info(f"args: {args}")
|
||||
|
||||
@@ -47,8 +47,8 @@ def server_init(param: "WebServerParameters", system_app: SystemApp):
|
||||
|
||||
# Loader plugins and commands
|
||||
command_categories = [
|
||||
"dbgpt.agent.commands.built_in.audio_text",
|
||||
"dbgpt.agent.commands.built_in.image_gen",
|
||||
"dbgpt.agent.plugin.commands.built_in.audio_text",
|
||||
"dbgpt.agent.plugin.commands.built_in.image_gen",
|
||||
]
|
||||
# exclude commands
|
||||
command_categories = [
|
||||
@@ -61,9 +61,9 @@ def server_init(param: "WebServerParameters", system_app: SystemApp):
|
||||
cfg.command_registry = command_registry
|
||||
|
||||
command_disply_commands = [
|
||||
"dbgpt.agent.commands.disply_type.show_chart_gen",
|
||||
"dbgpt.agent.commands.disply_type.show_table_gen",
|
||||
"dbgpt.agent.commands.disply_type.show_text_gen",
|
||||
"dbgpt.agent.plugin.commands.built_in.disply_type.show_chart_gen",
|
||||
"dbgpt.agent.plugin.commands.built_in.disply_type.show_table_gen",
|
||||
"dbgpt.agent.plugin.commands.built_in.disply_type.show_text_gen",
|
||||
]
|
||||
command_disply_registry = CommandRegistry()
|
||||
for command in command_disply_commands:
|
||||
@@ -133,7 +133,7 @@ def _initialize_db(try_to_create_db: Optional[bool] = False) -> str:
|
||||
f"{urlquote(CFG.LOCAL_DB_PASSWORD)}@"
|
||||
f"{CFG.LOCAL_DB_HOST}:"
|
||||
f"{str(CFG.LOCAL_DB_PORT)}/"
|
||||
f"{db_name}?charset=utf8mb4&collation=utf8mb4_unicode_ci"
|
||||
f"{db_name}?charset=utf8mb4"
|
||||
)
|
||||
# Try to create database, if failed, will raise exception
|
||||
_create_mysql_database(db_name, db_url, try_to_create_db)
|
||||
|
@@ -34,10 +34,14 @@ def initialize_components(
|
||||
|
||||
# system_app.register(DefaultRAGGraphFactory)
|
||||
|
||||
from dbgpt.agent.controller import module_agent
|
||||
from dbgpt.serve.agent.hub.controller import module_agent
|
||||
|
||||
system_app.register_instance(module_agent)
|
||||
|
||||
from dbgpt.serve.agent.agents.controller import multi_agents
|
||||
|
||||
system_app.register_instance(multi_agents)
|
||||
|
||||
_initialize_embedding_model(
|
||||
param, system_app, embedding_model_name, embedding_model_path
|
||||
)
|
||||
|
@@ -26,8 +26,7 @@ from dbgpt.app.component_configs import initialize_components
|
||||
|
||||
# fastapi import time cost about 0.05s
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi import FastAPI, applications
|
||||
from fastapi.openapi.docs import get_swagger_ui_html
|
||||
from fastapi import FastAPI
|
||||
from fastapi.exceptions import RequestValidationError
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
@@ -46,18 +45,13 @@ static_file_path = os.path.join(ROOT_PATH, "dbgpt", "app/static")
|
||||
|
||||
CFG = Config()
|
||||
|
||||
|
||||
def swagger_monkey_patch(*args, **kwargs):
|
||||
return get_swagger_ui_html(
|
||||
*args,
|
||||
**kwargs,
|
||||
swagger_js_url="https://cdn.bootcdn.net/ajax/libs/swagger-ui/4.10.3/swagger-ui-bundle.js",
|
||||
swagger_css_url="https://cdn.bootcdn.net/ajax/libs/swagger-ui/4.10.3/swagger-ui.css",
|
||||
)
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
applications.get_swagger_ui_html = swagger_monkey_patch
|
||||
app = FastAPI(
|
||||
title="DBGPT OPEN API",
|
||||
description="This is dbgpt, with auto docs for the API and everything",
|
||||
version="0.5.0",
|
||||
openapi_tags=[],
|
||||
)
|
||||
# applications.get_swagger_ui_html = swagger_monkey_patch
|
||||
|
||||
system_app = SystemApp(app)
|
||||
|
||||
@@ -94,7 +88,7 @@ def mount_routers(app: FastAPI):
|
||||
|
||||
|
||||
def mount_static_files(app: FastAPI):
|
||||
from dbgpt.agent.commands.disply_type.show_chart_gen import (
|
||||
from dbgpt.agent.plugin.commands.built_in.disply_type import (
|
||||
static_message_img_path,
|
||||
)
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
"""Import all models to make sure they are registered with SQLAlchemy.
|
||||
"""
|
||||
from dbgpt.agent.db.my_plugin_db import MyPluginEntity
|
||||
from dbgpt.agent.db.plugin_hub_db import PluginHubEntity
|
||||
from dbgpt.serve.agent.db.my_plugin_db import MyPluginEntity
|
||||
from dbgpt.serve.agent.db.plugin_hub_db import PluginHubEntity
|
||||
from dbgpt.app.knowledge.chunk_db import DocumentChunkEntity
|
||||
from dbgpt.app.knowledge.document_db import KnowledgeDocumentEntity
|
||||
from dbgpt.app.knowledge.space_db import KnowledgeSpaceEntity
|
||||
|
@@ -45,6 +45,7 @@ from dbgpt.util.executor_utils import (
|
||||
DefaultExecutorFactory,
|
||||
)
|
||||
|
||||
|
||||
router = APIRouter()
|
||||
CFG = Config()
|
||||
CHAT_FACTORY = ChatFactory()
|
||||
|
@@ -3,10 +3,10 @@ import logging
|
||||
|
||||
from dbgpt.app.scene import BaseChat, ChatScene
|
||||
from dbgpt._private.config import Config
|
||||
from dbgpt.agent.commands.command_mange import ApiCall
|
||||
from dbgpt.agent import PluginPromptGenerator
|
||||
from dbgpt.agent.plugin.commands.command_mange import ApiCall
|
||||
from dbgpt.agent.plugin.generator import PluginPromptGenerator
|
||||
from dbgpt.component import ComponentType
|
||||
from dbgpt.agent.controller import ModuleAgent
|
||||
from dbgpt.serve.agent.hub.controller import ModuleAgent
|
||||
from dbgpt.util.tracer import root_tracer, trace
|
||||
|
||||
CFG = Config()
|
||||
|
@@ -4,7 +4,7 @@ import logging
|
||||
from typing import Dict
|
||||
from dbgpt.app.scene import BaseChat, ChatScene
|
||||
from dbgpt._private.config import Config
|
||||
from dbgpt.agent.commands.command_mange import ApiCall
|
||||
from dbgpt.agent.plugin.commands.command_mange import ApiCall
|
||||
from dbgpt.app.scene.chat_data.chat_excel.excel_reader import ExcelReader
|
||||
from dbgpt.app.scene.chat_data.chat_excel.excel_learning.chat import ExcelLearning
|
||||
from dbgpt.util.path_utils import has_path
|
||||
|
@@ -3,7 +3,7 @@ from typing import Any, Dict
|
||||
|
||||
from dbgpt.core.interface.message import ViewMessage, AIMessage
|
||||
from dbgpt.app.scene import BaseChat, ChatScene
|
||||
from dbgpt.util.json_utils import DateTimeEncoder
|
||||
from dbgpt.util.json_utils import EnhancedJSONEncoder
|
||||
from dbgpt.util.executor_utils import blocking_func_to_async
|
||||
from dbgpt.util.tracer import trace
|
||||
|
||||
@@ -45,7 +45,7 @@ class ExcelLearning(BaseChat):
|
||||
datas.insert(0, colunms)
|
||||
|
||||
input_values = {
|
||||
"data_example": json.dumps(datas, cls=DateTimeEncoder),
|
||||
"data_example": json.dumps(datas, cls=EnhancedJSONEncoder),
|
||||
"file_name": self.excel_reader.excel_file_name,
|
||||
}
|
||||
return input_values
|
||||
|
@@ -1,6 +1,6 @@
|
||||
from typing import Dict
|
||||
|
||||
from dbgpt.agent.commands.command_mange import ApiCall
|
||||
from dbgpt.agent.plugin.commands.command_mange import ApiCall
|
||||
from dbgpt.app.scene import BaseChat, ChatScene
|
||||
from dbgpt._private.config import Config
|
||||
from dbgpt.util.executor_utils import blocking_func_to_async
|
||||
|
@@ -2,8 +2,8 @@ from typing import List, Dict
|
||||
|
||||
from dbgpt.app.scene import BaseChat, ChatScene
|
||||
from dbgpt._private.config import Config
|
||||
from dbgpt.agent.commands.command import execute_command
|
||||
from dbgpt.agent import PluginPromptGenerator
|
||||
from dbgpt.agent.plugin.commands.command import execute_command
|
||||
from dbgpt.agent.plugin.generator import PluginPromptGenerator
|
||||
from dbgpt.util.tracer import trace
|
||||
|
||||
CFG = Config()
|
||||
|
Reference in New Issue
Block a user