refactor(agent): refactor Agent model parameters reset logic and add environment variable support

Split reset_agent_config into two independent methods for getting and resetting model parameters
Add functionality to read quota configuration from environment variables to the default free tier
This commit is contained in:
wxy
2026-04-17 11:00:22 +08:00
parent a105df33ab
commit 26a3d8a41b
3 changed files with 109 additions and 50 deletions

View File

@@ -271,18 +271,17 @@ def update_agent_config(
return success(data=app_schema.AgentConfig.model_validate(cfg))
@router.post("/{app_id}/config/reset", summary="重置 Agent 配置为默认状态")
@router.post("/{app_id}/model/parameters/reset", summary="获取 Agent 模型参数默认配置")
@cur_workspace_access_guard()
def reset_agent_config(
def reset_agent_model_parameters(
app_id: uuid.UUID,
db: Session = Depends(get_db),
current_user=Depends(get_current_user),
):
workspace_id = current_user.current_workspace_id
service = AppService(db)
cfg = service.reset_agent_config(app_id=app_id, workspace_id=workspace_id)
cfg = enrich_agent_config(cfg)
return success(data=app_schema.AgentConfig.model_validate(cfg), msg="Agent 配置已重置为默认状态")
model_parameters = service.get_default_model_parameters(app_id=app_id)
return success(data=model_parameters, msg="获取 Agent 模型参数默认配置")
@router.get("/{app_id}/config", summary="获取 Agent 配置")