Skip to content

Commit

Permalink
docs: Add agents notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
fangyinc committed Apr 10, 2024
1 parent 9a91ed4 commit 5188b32
Show file tree
Hide file tree
Showing 10 changed files with 688 additions and 596 deletions.
2 changes: 2 additions & 0 deletions dbgpt/agent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
AgentGenerateContext,
AgentMessage,
)
from .core.base_agent import ConversableAgent # noqa: F401
from .core.llm.llm import LLMConfig # noqa: F401
from .core.schema import PluginStorageType # noqa: F401
from .core.user_proxy_agent import UserProxyAgent # noqa: F401
Expand All @@ -19,6 +20,7 @@
"AgentContext",
"AgentGenerateContext",
"AgentMessage",
"ConversableAgent",
"Action",
"ActionOutput",
"LLMConfig",
Expand Down
12 changes: 6 additions & 6 deletions dbgpt/agent/core/agent_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ def list_agents(self):
return result


agent_manage = AgentManager()
agent_manager = AgentManager()

agent_manage.register_agent(CodeAssistantAgent)
agent_manage.register_agent(DashboardAssistantAgent)
agent_manage.register_agent(DataScientistAgent)
agent_manage.register_agent(SummaryAssistantAgent)
agent_manage.register_agent(PluginAssistantAgent)
agent_manager.register_agent(CodeAssistantAgent)
agent_manager.register_agent(DashboardAssistantAgent)
agent_manager.register_agent(DataScientistAgent)
agent_manager.register_agent(SummaryAssistantAgent)
agent_manager.register_agent(PluginAssistantAgent)
2 changes: 1 addition & 1 deletion dbgpt/agent/core/llm/llm_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ async def _completions_create(self, llm_model, params) -> str:
model_request = _build_model_request(payload)
model_output = await self._llm_client.generate(model_request.copy())
parsed_output = self._output_parser.parse_model_nostream_resp(
model_output, "###"
model_output, "#########################"
)
return parsed_output
except Exception as e:
Expand Down
4 changes: 2 additions & 2 deletions dbgpt/agent/plan/awel/agent_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from dbgpt.model.operators.llm_operator import MixinLLMOperator

from ...core.agent import Agent, AgentGenerateContext, AgentMessage
from ...core.agent_manage import agent_manage
from ...core.agent_manage import agent_manager
from ...core.base_agent import ConversableAgent
from ...core.llm.llm import LLMConfig
from .agent_operator_resource import AWELAgent
Expand Down Expand Up @@ -244,7 +244,7 @@ async def get_agent(
) -> ConversableAgent:
"""Build the agent."""
# agent build
agent_cls: Type[ConversableAgent] = agent_manage.get_by_name( # type: ignore
agent_cls: Type[ConversableAgent] = agent_manager.get_by_name( # type: ignore
self.awel_agent.agent_profile
)
llm_config = self.awel_agent.llm_config
Expand Down
4 changes: 2 additions & 2 deletions dbgpt/agent/plan/awel/agent_operator_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
register_resource,
)

from ...core.agent_manage import agent_manage
from ...core.agent_manage import agent_manager
from ...core.llm.llm import LLMConfig, LLMStrategyType
from ...resource.resource_api import AgentResource, ResourceType

Expand Down Expand Up @@ -118,7 +118,7 @@ def pre_fill(cls, values: Dict[str, Any]) -> Dict[str, Any]:
def _agent_resource_option_values() -> List[OptionValue]:
return [
OptionValue(label=item["name"], name=item["name"], value=item["name"])
for item in agent_manage.list_agents()
for item in agent_manager.list_agents()
]


Expand Down
6 changes: 3 additions & 3 deletions dbgpt/serve/agent/agents/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from dbgpt._private.config import Config
from dbgpt.agent.core.agent import Agent, AgentContext
from dbgpt.agent.core.agent_manage import agent_manage
from dbgpt.agent.core.agent_manage import agent_manager
from dbgpt.agent.core.base_agent import ConversableAgent
from dbgpt.agent.core.llm.llm import LLMConfig, LLMStrategyType
from dbgpt.agent.core.schema import Status
Expand Down Expand Up @@ -222,7 +222,7 @@ async def agent_team_chat_new(
self.llm_provider = DefaultLLMClient(worker_manager, auto_convert_message=True)

for record in gpts_app.details:
cls: Type[ConversableAgent] = agent_manage.get_by_name(record.agent_name)
cls: Type[ConversableAgent] = agent_manager.get_by_name(record.agent_name)
llm_config = LLMConfig(
llm_client=self.llm_provider,
llm_strategy=LLMStrategyType(record.llm_strategy),
Expand Down Expand Up @@ -340,7 +340,7 @@ def gpts_conv_list(self, user_code: str = None, system_app: str = None):
async def agents_list():
logger.info("agents_list!")
try:
agents = agent_manage.all_agents()
agents = agent_manager.all_agents()
return Result.succ(agents)
except Exception as e:
return Result.failed(code="E30001", msg=str(e))
Expand Down
4 changes: 2 additions & 2 deletions dbgpt/serve/agent/app/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from fastapi import APIRouter

from dbgpt._private.config import Config
from dbgpt.agent.core.agent_manage import agent_manage
from dbgpt.agent.core.agent_manage import agent_manager
from dbgpt.agent.core.llm.llm import LLMStrategyType
from dbgpt.agent.resource.resource_api import ResourceType
from dbgpt.app.knowledge.api import knowledge_space_service
Expand Down Expand Up @@ -63,7 +63,7 @@ async def edit(gpts_app: GptsApp):
@router.get("/v1/agents/list")
async def all_agents():
try:
return Result.succ(agent_manage.list_agents())
return Result.succ(agent_manager.list_agents())
except Exception as ex:
return Result.failed(code="E000X", msg=f"query agents error: {ex}")

Expand Down
2 changes: 0 additions & 2 deletions examples/agents/awel_layout_agents_chat_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
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(ROOT_PATH, "examples/test_files/plugins")


Expand Down
Loading

0 comments on commit 5188b32

Please sign in to comment.