[fix] multi agent run bug
This commit is contained in:
@@ -109,7 +109,7 @@ class MultiAgentConfigSchema(BaseModel):
|
|||||||
|
|
||||||
id: uuid.UUID
|
id: uuid.UUID
|
||||||
app_id: uuid.UUID
|
app_id: uuid.UUID
|
||||||
master_agent_id: uuid.UUID
|
master_agent_id: uuid.UUID | None
|
||||||
master_agent_name: Optional[str]
|
master_agent_name: Optional[str]
|
||||||
default_model_config_id : uuid.UUID | None = Field(description="默认模型配置ID")
|
default_model_config_id : uuid.UUID | None = Field(description="默认模型配置ID")
|
||||||
model_parameters: ModelParameters | None = Field(
|
model_parameters: ModelParameters | None = Field(
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ from app.schemas import app_schema
|
|||||||
from app.schemas.workflow_schema import WorkflowConfigUpdate
|
from app.schemas.workflow_schema import WorkflowConfigUpdate
|
||||||
from app.services.agent_config_converter import AgentConfigConverter
|
from app.services.agent_config_converter import AgentConfigConverter
|
||||||
from app.models import AppShare, Workspace
|
from app.models import AppShare, Workspace
|
||||||
|
from app.services.model_service import ModelApiKeyService
|
||||||
|
|
||||||
# 获取业务日志器
|
# 获取业务日志器
|
||||||
logger = get_business_logger()
|
logger = get_business_logger()
|
||||||
@@ -200,34 +201,28 @@ class AppService:
|
|||||||
"多智能体配置未激活,无法运行",
|
"多智能体配置未激活,无法运行",
|
||||||
BizCode.AGENT_CONFIG_MISSING
|
BizCode.AGENT_CONFIG_MISSING
|
||||||
)
|
)
|
||||||
|
if not multi_agent_config.default_model_config_id:
|
||||||
# 2. 检查主 Agent 配置
|
# # 2. 检查主 Agent 配置
|
||||||
if not multi_agent_config.master_agent_id:
|
if not multi_agent_config.master_agent_id:
|
||||||
raise BusinessException(
|
|
||||||
"未配置主 Agent,无法运行",
|
|
||||||
BizCode.AGENT_CONFIG_MISSING
|
|
||||||
)
|
|
||||||
|
|
||||||
master_agent_release = self.db.get(AppRelease, multi_agent_config.master_agent_id)
|
|
||||||
if not master_agent_release:
|
|
||||||
raise BusinessException(
|
|
||||||
f"主 Agent 配置不存在: {multi_agent_config.master_agent_id}",
|
|
||||||
BizCode.AGENT_CONFIG_MISSING
|
|
||||||
)
|
|
||||||
|
|
||||||
# 检查主 Agent 的模型配置
|
|
||||||
if master_agent_release.default_model_config_id:
|
|
||||||
master_model = self.db.get(ModelConfig, master_agent_release.default_model_config_id)
|
|
||||||
if not master_model:
|
|
||||||
raise BusinessException(
|
raise BusinessException(
|
||||||
f"主 Agent 的模型配置不存在: {master_agent_release.default_model_config_id}",
|
"未配置主 Agent,无法运行",
|
||||||
BizCode.MODEL_NOT_FOUND
|
BizCode.AGENT_CONFIG_MISSING
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
raise BusinessException(
|
master_agent_release = self.db.get(AppRelease, multi_agent_config.master_agent_id)
|
||||||
"主 Agent 未配置模型,无法运行",
|
if not master_agent_release:
|
||||||
BizCode.MODEL_NOT_FOUND
|
raise BusinessException(
|
||||||
)
|
f"主 Agent 配置不存在: {multi_agent_config.master_agent_id}",
|
||||||
|
BizCode.AGENT_CONFIG_MISSING
|
||||||
|
)
|
||||||
|
|
||||||
|
# 检查主 Agent 的模型配置
|
||||||
|
multi_agent_config.default_model_config_id = master_agent_release.default_model_config_id
|
||||||
|
|
||||||
|
model_api_key = ModelApiKeyService.get_a_api_key(self.db, multi_agent_config.default_model_config_id)
|
||||||
|
if not model_api_key:
|
||||||
|
raise ResourceNotFoundException("模型配置", str(multi_agent_config.default_model_config_id))
|
||||||
|
|
||||||
|
|
||||||
# 3. 检查子 Agent 配置
|
# 3. 检查子 Agent 配置
|
||||||
if not multi_agent_config.sub_agents or len(multi_agent_config.sub_agents) == 0:
|
if not multi_agent_config.sub_agents or len(multi_agent_config.sub_agents) == 0:
|
||||||
|
|||||||
@@ -362,12 +362,14 @@ class MasterAgentRouter:
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
temperature = 0.3 # 决策任务使用较低温度
|
temperature = 0.3 # 决策任务使用较低温度
|
||||||
max_tokens = 1000
|
max_tokens = 1000
|
||||||
extra_params = None
|
|
||||||
if self.model_parameters:
|
if self.model_parameters:
|
||||||
extra_params = {"temperature": temperature,
|
temperature = self.model_parameters.temperature
|
||||||
"max_tokens":max_tokens
|
max_tokens = self.model_parameters.max_tokens
|
||||||
}
|
|
||||||
|
extra_params = {"temperature": temperature,
|
||||||
|
"max_tokens":max_tokens
|
||||||
|
}
|
||||||
# 创建 RedBearModelConfig
|
# 创建 RedBearModelConfig
|
||||||
model_config = RedBearModelConfig(
|
model_config = RedBearModelConfig(
|
||||||
model_name=api_key_config.model_name,
|
model_name=api_key_config.model_name,
|
||||||
|
|||||||
@@ -631,7 +631,7 @@ class MultiAgentOrchestrator:
|
|||||||
"agent_name": agent_name,
|
"agent_name": agent_name,
|
||||||
"sub_question": sub_question
|
"sub_question": sub_question
|
||||||
})
|
})
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# 非 data 事件直接转发
|
# 非 data 事件直接转发
|
||||||
|
|||||||
2912
api/uv.lock
generated
2912
api/uv.lock
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user