mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-01 01:04:43 +00:00
Solve the problem of resource duplication and solve the problem of slow recall of table structure (#1381)
Co-authored-by: ChenXinye <chenxinye@weihaizixun.com>
This commit is contained in:
@@ -4,7 +4,7 @@ from pydantic import Field
|
|||||||
|
|
||||||
from dbgpt._private.config import Config
|
from dbgpt._private.config import Config
|
||||||
from dbgpt.agent.agents.base_agent_new import ConversableAgent
|
from dbgpt.agent.agents.base_agent_new import ConversableAgent
|
||||||
|
from dbgpt.agent.resource.resource_api import AgentResource
|
||||||
from .plan_action import PlanAction
|
from .plan_action import PlanAction
|
||||||
|
|
||||||
CFG = Config()
|
CFG = Config()
|
||||||
@@ -70,11 +70,19 @@ class PlannerAgent(ConversableAgent):
|
|||||||
}
|
}
|
||||||
return reply_message
|
return reply_message
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_unique_resources_codes(resource: AgentResource) -> str:
|
||||||
|
return resource.name + "_" + resource.type.value + "_" + resource.value
|
||||||
|
|
||||||
def bind_agents(self, agents: List[ConversableAgent]) -> ConversableAgent:
|
def bind_agents(self, agents: List[ConversableAgent]) -> ConversableAgent:
|
||||||
self.agents = agents
|
self.agents = agents
|
||||||
|
unique_resources = set()
|
||||||
for agent in self.agents:
|
for agent in self.agents:
|
||||||
if agent.resources and len(agent.resources) > 0:
|
if agent.resources and len(agent.resources) > 0:
|
||||||
self.resources.extend(agent.resources)
|
for resource in agent.resources:
|
||||||
|
if self.get_unique_resources_codes(resource) not in unique_resources:
|
||||||
|
unique_resources.add(self.get_unique_resources_codes(resource))
|
||||||
|
self.resources.append(resource)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def prepare_act_param(self) -> Optional[Dict]:
|
def prepare_act_param(self) -> Optional[Dict]:
|
||||||
|
Reference in New Issue
Block a user