mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-13 21:21:08 +00:00
feat: AWEL flow supports dynamic parameters (#1251)
This commit is contained in:
@@ -4,21 +4,16 @@ from pydantic import BaseModel, Field
|
||||
|
||||
from dbgpt._private.pydantic import root_validator
|
||||
from dbgpt.agent.agents.agents_manage import agent_manage
|
||||
from dbgpt.agent.agents.base_agent_new import ConversableAgent
|
||||
from dbgpt.agent.agents.llm.llm import LLMConfig, LLMStrategyType
|
||||
from dbgpt.agent.resource.resource_api import AgentResource, ResourceType
|
||||
from dbgpt.core import LLMClient
|
||||
from dbgpt.core.awel.flow import (
|
||||
IOField,
|
||||
OperatorCategory,
|
||||
OperatorType,
|
||||
FunctionDynamicOptions,
|
||||
OptionValue,
|
||||
Parameter,
|
||||
ResourceCategory,
|
||||
ViewMetadata,
|
||||
register_resource,
|
||||
)
|
||||
from dbgpt.core.interface.operators.prompt_operator import CommonChatPromptTemplate
|
||||
|
||||
|
||||
@register_resource(
|
||||
@@ -115,6 +110,13 @@ class AwelAgentConfig(LLMConfig):
|
||||
return values
|
||||
|
||||
|
||||
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()
|
||||
]
|
||||
|
||||
|
||||
@register_resource(
|
||||
label="Awel Layout Agent",
|
||||
name="agent_operator_agent",
|
||||
@@ -126,10 +128,7 @@ class AwelAgentConfig(LLMConfig):
|
||||
name="agent_profile",
|
||||
type=str,
|
||||
description="Which agent want use.",
|
||||
options=[
|
||||
OptionValue(label=item["name"], name=item["name"], value=item["name"])
|
||||
for item in agent_manage.list_agents()
|
||||
],
|
||||
options=FunctionDynamicOptions(func=_agent_resource_option_values),
|
||||
),
|
||||
Parameter.build_from(
|
||||
label="Role Name",
|
||||
|
@@ -13,6 +13,7 @@ from dbgpt.core import (
|
||||
)
|
||||
from dbgpt.core.awel import JoinOperator, MapOperator
|
||||
from dbgpt.core.awel.flow import (
|
||||
FunctionDynamicOptions,
|
||||
IOField,
|
||||
OperatorCategory,
|
||||
OperatorType,
|
||||
@@ -29,6 +30,15 @@ from dbgpt.storage.vector_store.connector import VectorStoreConnector
|
||||
from dbgpt.util.function_utils import rearrange_args_by_type
|
||||
|
||||
|
||||
def _load_space_name() -> List[OptionValue]:
|
||||
return [
|
||||
OptionValue(label=space.name, name=space.name, value=space.name)
|
||||
for space in knowledge_space_service.get_knowledge_space(
|
||||
KnowledgeSpaceRequest()
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
class SpaceRetrieverOperator(MapOperator[IN, OUT]):
|
||||
"""knowledge space retriever operator."""
|
||||
|
||||
@@ -51,12 +61,7 @@ class SpaceRetrieverOperator(MapOperator[IN, OUT]):
|
||||
"Space Name",
|
||||
"space_name",
|
||||
str,
|
||||
options=[
|
||||
OptionValue(label=space.name, name=space.name, value=space.name)
|
||||
for space in knowledge_space_service.get_knowledge_space(
|
||||
KnowledgeSpaceRequest()
|
||||
)
|
||||
],
|
||||
options=FunctionDynamicOptions(func=_load_space_name),
|
||||
optional=False,
|
||||
default=None,
|
||||
description="space name.",
|
||||
|
Reference in New Issue
Block a user