feat(agent): 增强 Agent 配置,新增结构化字段与聊天功能支持
This commit is contained in:
1 parent
ac4262cd75
commit
c8ce77199e
183 files changed
+11690
-2300
No files matched your search
@@ -42,26 +42,37 @@ def _upsert_agent(
|
||||
dify_app_id: str | None = None,
|
||||
dify_api_key: str | None = None,
|
||||
api_base_url: str | None = None,
|
||||
agent_code: str = 'shipping_notice',
|
||||
runtime_provider: str = 'hybrid',
|
||||
conversation_mode: str = 'task_chat',
|
||||
):
|
||||
agent = Agent.query.filter_by(name=name).first()
|
||||
extra_config = {"dify_app_type": dify_app_type}
|
||||
extra_config = {'dify_app_type': dify_app_type}
|
||||
if not agent:
|
||||
agent = Agent(
|
||||
name=name,
|
||||
description=description,
|
||||
type="api",
|
||||
type='api',
|
||||
dify_app_id=dify_app_id,
|
||||
dify_api_key=dify_api_key,
|
||||
api_base_url=api_base_url,
|
||||
extra_config=extra_config,
|
||||
is_active=True,
|
||||
agent_code=agent_code,
|
||||
runtime_provider=runtime_provider,
|
||||
conversation_mode=conversation_mode,
|
||||
dify_app_type=dify_app_type,
|
||||
)
|
||||
db.session.add(agent)
|
||||
print(f"Created agent: {name}")
|
||||
print(f'Created agent: {name}')
|
||||
else:
|
||||
agent.description = description
|
||||
agent.type = "api"
|
||||
agent.type = 'api'
|
||||
agent.extra_config = extra_config
|
||||
agent.agent_code = agent_code
|
||||
agent.runtime_provider = runtime_provider
|
||||
agent.conversation_mode = conversation_mode
|
||||
agent.dify_app_type = dify_app_type
|
||||
if dify_app_id:
|
||||
agent.dify_app_id = dify_app_id
|
||||
if dify_api_key:
|
||||
@@ -69,7 +80,7 @@ def _upsert_agent(
|
||||
if api_base_url:
|
||||
agent.api_base_url = api_base_url
|
||||
agent.is_active = True
|
||||
print(f"Updated agent: {name}")
|
||||
print(f'Updated agent: {name}')
|
||||
return agent
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user