feat(agent): 增强 Agent 配置,新增结构化字段与聊天功能支持
This commit is contained in:
1 parent
ac4262cd75
commit
c8ce77199e
183 files changed
+11690
-2300
No files matched your search
@@ -0,0 +1,62 @@
|
||||
"""
|
||||
backend/tests/test_admin_agent_schema_api.py
|
||||
|
||||
用途:Admin Agent Registry schema / infer-content-profile API 集成测试。
|
||||
依赖:conftest app/client、issue_local_access_token、parse_api_data。
|
||||
逻辑:P3/P7 验收 — Admin 表单权威 schema 与 content_profile 推断接口。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from app import db
|
||||
from app.core.auth.jwt import issue_local_access_token
|
||||
from app.models import User
|
||||
from tests.conftest import parse_api_data
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def admin_jwt_headers(app):
|
||||
"""创建 admin 用户并签发 Bearer JWT(testing 环境 AUTH_JWT_REQUIRED=true)。"""
|
||||
with app.app_context():
|
||||
user = db.session.query(User).filter_by(username='admin').first()
|
||||
if not user:
|
||||
user = User(
|
||||
username='admin',
|
||||
email='admin@example.com',
|
||||
role='admin',
|
||||
status='active',
|
||||
)
|
||||
user.set_password('admin')
|
||||
db.session.add(user)
|
||||
db.session.commit()
|
||||
token = issue_local_access_token(user)
|
||||
return {
|
||||
'Authorization': f'Bearer {token}',
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
|
||||
|
||||
def test_get_agent_registry_schema(client, admin_jwt_headers):
|
||||
"""GET /api/admin/agents/schema 应返回 success envelope 与三类 agent_types。"""
|
||||
response = client.get('/api/admin/agents/schema', headers=admin_jwt_headers)
|
||||
assert response.status_code == 200
|
||||
body = response.json
|
||||
assert body.get('success') is True
|
||||
data = parse_api_data(body)
|
||||
codes = {item['agent_code'] for item in data['agent_types']}
|
||||
assert codes == {'generic', 'shipping_notice', 'file_check'}
|
||||
assert 'dify' in data['platform']['runtime_providers']
|
||||
|
||||
|
||||
def test_infer_content_profile_from_intent_routes(client, admin_jwt_headers):
|
||||
"""POST infer-content-profile 应根据 intent_routes 返回 content_profile 建议。"""
|
||||
response = client.post(
|
||||
'/api/admin/agents/infer-content-profile',
|
||||
headers=admin_jwt_headers,
|
||||
json={'intent_routes': ['text2sql']},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
data = parse_api_data(response.json)
|
||||
assert 'content_profile' in data
|
||||
Reference in new issue
Block a user