fix: clean extra file & fix agents use zhipu (#1079)
Before Width: | Height: | Size: 447 KiB |
@ -10,7 +10,7 @@ CREATE TABLE IF NOT EXISTS `alembic_version`
|
|||||||
(
|
(
|
||||||
version_num VARCHAR(32) NOT NULL,
|
version_num VARCHAR(32) NOT NULL,
|
||||||
CONSTRAINT alembic_version_pkc PRIMARY KEY (version_num)
|
CONSTRAINT alembic_version_pkc PRIMARY KEY (version_num)
|
||||||
);
|
) DEFAULT CHARSET=utf8mb4 ;
|
||||||
|
|
||||||
CREATE TABLE IF NOT EXISTS `knowledge_space`
|
CREATE TABLE IF NOT EXISTS `knowledge_space`
|
||||||
(
|
(
|
||||||
@ -185,7 +185,82 @@ CREATE TABLE IF NOT EXISTS `prompt_manage`
|
|||||||
KEY `gmt_created_idx` (`gmt_created`)
|
KEY `gmt_created_idx` (`gmt_created`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Prompt management table';
|
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Prompt management table';
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `gpts_conversations` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'autoincrement id',
|
||||||
|
`conv_id` varchar(255) NOT NULL COMMENT 'The unique id of the conversation record',
|
||||||
|
`user_goal` text NOT NULL COMMENT 'User''s goals content',
|
||||||
|
`gpts_name` varchar(255) NOT NULL COMMENT 'The gpts name',
|
||||||
|
`state` varchar(255) DEFAULT NULL COMMENT 'The gpts state',
|
||||||
|
`max_auto_reply_round` int(11) NOT NULL COMMENT 'max auto reply round',
|
||||||
|
`auto_reply_count` int(11) NOT NULL COMMENT 'auto reply count',
|
||||||
|
`user_code` varchar(255) DEFAULT NULL COMMENT 'user code',
|
||||||
|
`sys_code` varchar(255) DEFAULT NULL COMMENT 'system app ',
|
||||||
|
`created_at` datetime DEFAULT NULL COMMENT 'create time',
|
||||||
|
`updated_at` datetime DEFAULT NULL COMMENT 'last update time',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `uk_gpts_conversations` (`conv_id`),
|
||||||
|
KEY `idx_gpts_name` (`gpts_name`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COMMENT="gpt conversations";
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `gpts_instance` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'autoincrement id',
|
||||||
|
`gpts_name` varchar(255) NOT NULL COMMENT 'Current AI assistant name',
|
||||||
|
`gpts_describe` varchar(2255) NOT NULL COMMENT 'Current AI assistant describe',
|
||||||
|
`resource_db` text COMMENT 'List of structured database names contained in the current gpts',
|
||||||
|
`resource_internet` text COMMENT 'Is it possible to retrieve information from the internet',
|
||||||
|
`resource_knowledge` text COMMENT 'List of unstructured database names contained in the current gpts',
|
||||||
|
`gpts_agents` varchar(1000) DEFAULT NULL COMMENT 'List of agents names contained in the current gpts',
|
||||||
|
`gpts_models` varchar(1000) DEFAULT NULL COMMENT 'List of llm model names contained in the current gpts',
|
||||||
|
`language` varchar(100) DEFAULT NULL COMMENT 'gpts language',
|
||||||
|
`user_code` varchar(255) NOT NULL COMMENT 'user code',
|
||||||
|
`sys_code` varchar(255) DEFAULT NULL COMMENT 'system app code',
|
||||||
|
`created_at` datetime DEFAULT NULL COMMENT 'create time',
|
||||||
|
`updated_at` datetime DEFAULT NULL COMMENT 'last update time',
|
||||||
|
`team_mode` varchar(255) NOT NULL COMMENT 'Team work mode',
|
||||||
|
`is_sustainable` tinyint(1) NOT NULL COMMENT 'Applications for sustainable dialogue',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `uk_gpts` (`gpts_name`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COMMENT="gpts instance";
|
||||||
|
|
||||||
|
CREATE TABLE `gpts_messages` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'autoincrement id',
|
||||||
|
`conv_id` varchar(255) NOT NULL COMMENT 'The unique id of the conversation record',
|
||||||
|
`sender` varchar(255) NOT NULL COMMENT 'Who speaking in the current conversation turn',
|
||||||
|
`receiver` varchar(255) NOT NULL COMMENT 'Who receive message in the current conversation turn',
|
||||||
|
`model_name` varchar(255) DEFAULT NULL COMMENT 'message generate model',
|
||||||
|
`rounds` int(11) NOT NULL COMMENT 'dialogue turns',
|
||||||
|
`content` text COMMENT 'Content of the speech',
|
||||||
|
`current_gogal` text COMMENT 'The target corresponding to the current message',
|
||||||
|
`context` text COMMENT 'Current conversation context',
|
||||||
|
`review_info` text COMMENT 'Current conversation review info',
|
||||||
|
`action_report` text COMMENT 'Current conversation action report',
|
||||||
|
`role` varchar(255) DEFAULT NULL COMMENT 'The role of the current message content',
|
||||||
|
`created_at` datetime DEFAULT NULL COMMENT 'create time',
|
||||||
|
`updated_at` datetime DEFAULT NULL COMMENT 'last update time',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `idx_q_messages` (`conv_id`,`rounds`,`sender`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8mb4 COMMENT="gpts message";
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE `gpts_plans` (
|
||||||
|
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'autoincrement id',
|
||||||
|
`conv_id` varchar(255) NOT NULL COMMENT 'The unique id of the conversation record',
|
||||||
|
`sub_task_num` int(11) NOT NULL COMMENT 'Subtask number',
|
||||||
|
`sub_task_title` varchar(255) NOT NULL COMMENT 'subtask title',
|
||||||
|
`sub_task_content` text NOT NULL COMMENT 'subtask content',
|
||||||
|
`sub_task_agent` varchar(255) DEFAULT NULL COMMENT 'Available agents corresponding to subtasks',
|
||||||
|
`resource_name` varchar(255) DEFAULT NULL COMMENT 'resource name',
|
||||||
|
`rely` varchar(255) DEFAULT NULL COMMENT 'Subtask dependencies,like: 1,2,3',
|
||||||
|
`agent_model` varchar(255) DEFAULT NULL COMMENT 'LLM model used by subtask processing agents',
|
||||||
|
`retry_times` int(11) DEFAULT NULL COMMENT 'number of retries',
|
||||||
|
`max_retry_times` int(11) DEFAULT NULL COMMENT 'Maximum number of retries',
|
||||||
|
`state` varchar(255) DEFAULT NULL COMMENT 'subtask status',
|
||||||
|
`result` longtext COMMENT 'subtask result',
|
||||||
|
`created_at` datetime DEFAULT NULL COMMENT 'create time',
|
||||||
|
`updated_at` datetime DEFAULT NULL COMMENT 'last update time',
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
UNIQUE KEY `uk_sub_task` (`conv_id`,`sub_task_num`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COMMENT="gpt plan";
|
||||||
|
|
||||||
CREATE
|
CREATE
|
||||||
DATABASE IF NOT EXISTS EXAMPLE_1;
|
DATABASE IF NOT EXISTS EXAMPLE_1;
|
@ -1,92 +0,0 @@
|
|||||||
import logging
|
|
||||||
import re
|
|
||||||
from collections import defaultdict
|
|
||||||
from typing import Dict, List, Optional, Type
|
|
||||||
|
|
||||||
from .agent import Agent
|
|
||||||
from .expand.code_assistant_agent import CodeAssistantAgent
|
|
||||||
from .expand.dashboard_assistant_agent import DashboardAssistantAgent
|
|
||||||
from .expand.data_scientist_agent import DataScientistAgent
|
|
||||||
from .expand.plugin_assistant_agent import PluginAssistantAgent
|
|
||||||
from .expand.retrieve_summary_assistant_agent import RetrieveSummaryAssistantAgent
|
|
||||||
from .expand.sql_assistant_agent import SQLAssistantAgent
|
|
||||||
from .expand.summary_assistant_agent import SummaryAssistantAgent
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def get_all_subclasses(cls):
|
|
||||||
all_subclasses = []
|
|
||||||
direct_subclasses = cls.__subclasses__()
|
|
||||||
all_subclasses.extend(direct_subclasses)
|
|
||||||
|
|
||||||
for subclass in direct_subclasses:
|
|
||||||
all_subclasses.extend(get_all_subclasses(subclass))
|
|
||||||
return all_subclasses
|
|
||||||
|
|
||||||
|
|
||||||
def participant_roles(agents: List[Agent] = None) -> str:
|
|
||||||
# Default to all agents registered
|
|
||||||
if agents is None:
|
|
||||||
agents = agents
|
|
||||||
|
|
||||||
roles = []
|
|
||||||
for agent in agents:
|
|
||||||
if agent.system_message.strip() == "":
|
|
||||||
logger.warning(
|
|
||||||
f"The agent '{agent.name}' has an empty system_message, and may not work well with GroupChat."
|
|
||||||
)
|
|
||||||
roles.append(f"{agent.name}: {agent.describe}")
|
|
||||||
return "\n".join(roles)
|
|
||||||
|
|
||||||
|
|
||||||
def mentioned_agents(message_content: str, agents: List[Agent]) -> Dict:
|
|
||||||
"""
|
|
||||||
Finds and counts agent mentions in the string message_content, taking word boundaries into account.
|
|
||||||
|
|
||||||
Returns: A dictionary mapping agent names to mention counts (to be included, at least one mention must occur)
|
|
||||||
"""
|
|
||||||
mentions = dict()
|
|
||||||
for agent in agents:
|
|
||||||
regex = (
|
|
||||||
r"(?<=\W)" + re.escape(agent.name) + r"(?=\W)"
|
|
||||||
) # Finds agent mentions, taking word boundaries into account
|
|
||||||
count = len(
|
|
||||||
re.findall(regex, " " + message_content + " ")
|
|
||||||
) # Pad the message to help with matching
|
|
||||||
if count > 0:
|
|
||||||
mentions[agent.name] = count
|
|
||||||
return mentions
|
|
||||||
|
|
||||||
|
|
||||||
class AgentsMange:
|
|
||||||
def __init__(self):
|
|
||||||
self._agents = defaultdict()
|
|
||||||
|
|
||||||
def register_agent(self, cls):
|
|
||||||
self._agents[cls.NAME] = cls
|
|
||||||
|
|
||||||
def get_by_name(self, name: str) -> Optional[Type[Agent]]:
|
|
||||||
if name not in self._agents:
|
|
||||||
raise ValueError(f"Agent:{name} not register!")
|
|
||||||
return self._agents[name]
|
|
||||||
|
|
||||||
def get_describe_by_name(self, name: str) -> Optional[Type[Agent]]:
|
|
||||||
return self._agents[name].DEFAULT_DESCRIBE
|
|
||||||
|
|
||||||
def all_agents(self):
|
|
||||||
result = {}
|
|
||||||
for name, cls in self._agents.items():
|
|
||||||
result[name] = cls.DEFAULT_DESCRIBE
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
agent_mange = AgentsMange()
|
|
||||||
|
|
||||||
agent_mange.register_agent(CodeAssistantAgent)
|
|
||||||
agent_mange.register_agent(DashboardAssistantAgent)
|
|
||||||
agent_mange.register_agent(DataScientistAgent)
|
|
||||||
agent_mange.register_agent(SQLAssistantAgent)
|
|
||||||
agent_mange.register_agent(SummaryAssistantAgent)
|
|
||||||
agent_mange.register_agent(PluginAssistantAgent)
|
|
||||||
agent_mange.register_agent(RetrieveSummaryAssistantAgent)
|
|
@ -180,7 +180,7 @@ class AIWrapper:
|
|||||||
payload["model_cache_enable"] = self.model_cache_enable
|
payload["model_cache_enable"] = self.model_cache_enable
|
||||||
try:
|
try:
|
||||||
model_request = _build_model_request(payload)
|
model_request = _build_model_request(payload)
|
||||||
model_output = await self._llm_client.generate(model_request)
|
model_output = await self._llm_client.generate(model_request.copy())
|
||||||
parsed_output = self._output_parser.parse_model_nostream_resp(
|
parsed_output = self._output_parser.parse_model_nostream_resp(
|
||||||
model_output, "###"
|
model_output, "###"
|
||||||
)
|
)
|
||||||
|
@ -110,7 +110,7 @@ class MultiAgents(BaseComponent, ABC):
|
|||||||
worker_manager = CFG.SYSTEM_APP.get_component(
|
worker_manager = CFG.SYSTEM_APP.get_component(
|
||||||
ComponentType.WORKER_MANAGER_FACTORY, WorkerManagerFactory
|
ComponentType.WORKER_MANAGER_FACTORY, WorkerManagerFactory
|
||||||
).create()
|
).create()
|
||||||
llm_task = DefaultLLMClient(worker_manager)
|
llm_task = DefaultLLMClient(worker_manager, auto_convert_message=True)
|
||||||
context: AgentContext = AgentContext(conv_id=conv_id, llm_provider=llm_task)
|
context: AgentContext = AgentContext(conv_id=conv_id, llm_provider=llm_task)
|
||||||
context.gpts_name = gpts_instance.gpts_name
|
context.gpts_name = gpts_instance.gpts_name
|
||||||
context.resource_db = resource_db
|
context.resource_db = resource_db
|
||||||
|
0
tools/__init__.py
Normal file
@ -1,7 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
raise Exception(
|
|
||||||
"The functionality of this script has been moved to the command line tool `dbgpt`. For details on usage, please execute the command `dbgpt --help`."
|
|
||||||
)
|
|
@ -1,7 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
raise Exception(
|
|
||||||
"The functionality of this script has been moved to the command line tool `dbgpt`. For details on usage, please execute the command `dbgpt --help`."
|
|
||||||
)
|
|
Before Width: | Height: | Size: 1003 KiB |
Before Width: | Height: | Size: 1.7 MiB |
Before Width: | Height: | Size: 4.3 MiB |
Before Width: | Height: | Size: 3.1 MiB |
Before Width: | Height: | Size: 2.4 MiB |
Before Width: | Height: | Size: 13 MiB |