增加测试AI接口
This commit is contained in:
BIN
apps/createDocument/schema/__pycache__/__init__.cpython-313.pyc
Normal file
BIN
apps/createDocument/schema/__pycache__/__init__.cpython-313.pyc
Normal file
Binary file not shown.
Binary file not shown.
@@ -1,13 +1,84 @@
|
|||||||
from datetime import date
|
from datetime import date
|
||||||
from ninja_extra import api_controller, ControllerBase, route
|
from ninja_extra import api_controller, ControllerBase, route
|
||||||
|
import json
|
||||||
|
|
||||||
from apps.project.models import Project
|
from apps.project.models import Project
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.contrib.auth import get_user_model
|
from django.contrib.auth import get_user_model
|
||||||
from utils.chen_response import ChenResponse
|
from utils.chen_response import ChenResponse
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
|
from ninja import Schema
|
||||||
|
|
||||||
Users = get_user_model()
|
Users = get_user_model()
|
||||||
|
|
||||||
|
class AIPostSchema(Schema):
|
||||||
|
question: str
|
||||||
|
stream: bool
|
||||||
|
|
||||||
|
# AI测试接口
|
||||||
|
@api_controller("/local_doc_qa", tags=['AI测试接口'])
|
||||||
|
class AITestController(ControllerBase):
|
||||||
|
"""AI测试接口:自定义延迟"""
|
||||||
|
|
||||||
|
@route.post("/testing_item")
|
||||||
|
def ai_return(self, item: AIPostSchema):
|
||||||
|
import time
|
||||||
|
time.sleep(2)
|
||||||
|
res = [
|
||||||
|
{
|
||||||
|
"demandDescription": "验证外部32MHz品振时钟和内部10KHZ时钟能否正确布线至FPGA内部相应的全局时钟网络,并通过指定缓冲器降低延迟。",
|
||||||
|
"title": "时钟布线与缓冲功能测试",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"name": "外部32MHz时钟布线到HCLKBUF级冲测试",
|
||||||
|
"subStep": [
|
||||||
|
{
|
||||||
|
"operation": "配置FPGA逻辑,将外部32MHz晶振输入连接到HCLKBUF缓冲器。",
|
||||||
|
"expect": "时钟信号成功接入HCLKBUF缓冲器,无错误提示。"
|
||||||
|
}, {
|
||||||
|
"operation": "使用示波器或时序分析工具检测HCLKBUF输出端的时钟波形。",
|
||||||
|
"expect": "输出端应稳定输出32MHz时钟信号,频率准确目波形无明显失真。"
|
||||||
|
}, {
|
||||||
|
"operation": "监测从HCLKBUF到各寄存器的时钟路径延迟。",
|
||||||
|
"expect": "各路径延迟保持一致目为最小值,满足分布式延迟最低的变求。"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}, {
|
||||||
|
"name": "内部10KHz时钟布线到CLKINT缓冲测试",
|
||||||
|
"subStep": [
|
||||||
|
{
|
||||||
|
"operation": "在FPGA中启用内部10KHz时钟源并将其连接至CLKINT缓冲器。",
|
||||||
|
"expect": "内部时钟信号成功接入CLKINT缓冲器,系统无报错。"
|
||||||
|
}, {
|
||||||
|
"operation": "测量CLKINT输出端的时钟频率。",
|
||||||
|
"expect": "输出端应稳定输出10KHz时钟信号,频率精度符合设计要求。"
|
||||||
|
}, {
|
||||||
|
"operation": "检查CLKINT是否将时钟广播到全局时钟网器",
|
||||||
|
"expect": "时钟能被正常分发至内部各个需要该时钟的模块。"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}, {
|
||||||
|
"name": "异常情况下的时钟处理测试",
|
||||||
|
"subStep": [
|
||||||
|
{
|
||||||
|
"operation": "断开外部32MHz晶振输入后尝试进行HCLKBUF配置。",
|
||||||
|
"expect": "系统应报告时钟缺失错误,无法完成正常的时钟分配。"
|
||||||
|
}, {
|
||||||
|
"operation": "人为制造内部10KHz时钟不稳定(如干扰)后再送入CLKINT。",
|
||||||
|
"expect": "CLKINT应拒绝不稳定的时钟或将错误上报给监控机制。"
|
||||||
|
}, {
|
||||||
|
"operation": "同时配置两个时钟但未正确绑定各自缓冲器。",
|
||||||
|
"expect": "系统应阻止非法配置操作,确保每个时钟进入正确的缓冲通道。"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
return {
|
||||||
|
"history":[["我是没有用的",json.dumps(res)]]
|
||||||
|
}
|
||||||
|
|
||||||
# 这是其他common内容接口
|
# 这是其他common内容接口
|
||||||
@api_controller("/system", tags=['通用接口'])
|
@api_controller("/system", tags=['通用接口'])
|
||||||
class CommonController(ControllerBase):
|
class CommonController(ControllerBase):
|
||||||
@@ -19,7 +90,8 @@ class CommonController(ControllerBase):
|
|||||||
item1 = {"title": "测试管理平台V0.0.2测试发布", "created_at": "2023-09-23",
|
item1 = {"title": "测试管理平台V0.0.2测试发布", "created_at": "2023-09-23",
|
||||||
"content": "测试管理平台V0.0.2发布,正在进行内部测试.."}
|
"content": "测试管理平台V0.0.2发布,正在进行内部测试.."}
|
||||||
item_list.append(item1)
|
item_list.append(item1)
|
||||||
item2 = {"title": "测试管理平台更新公共", "created_at": "2024-06-17", "content": "<p>1.修改大纲和报告模版<p><p>2.修复多个bug<p>"}
|
item2 = {"title": "测试管理平台更新公共", "created_at": "2024-06-17",
|
||||||
|
"content": "<p>1.修改大纲和报告模版<p><p>2.修复多个bug<p>"}
|
||||||
item_list.append(item2)
|
item_list.append(item2)
|
||||||
return item_list
|
return item_list
|
||||||
|
|
||||||
|
|||||||
@@ -346,3 +346,96 @@ AttributeError: 'str' object has no attribute 'testType'
|
|||||||
[WARNING][2025-12-02 09:12:28,124][log.py:253]Unauthorized: /api/system/logout
|
[WARNING][2025-12-02 09:12:28,124][log.py:253]Unauthorized: /api/system/logout
|
||||||
[WARNING][2025-12-02 09:12:36,217][backend.py:91]Caught LDAPError looking up user: SERVER_DOWN({'result': -1, 'desc': "Can't contact LDAP server", 'ctrls': []})
|
[WARNING][2025-12-02 09:12:36,217][backend.py:91]Caught LDAPError looking up user: SERVER_DOWN({'result': -1, 'desc': "Can't contact LDAP server", 'ctrls': []})
|
||||||
[WARNING][2025-12-02 15:56:55,439][backend.py:91]Caught LDAPError looking up user: SERVER_DOWN({'result': -1, 'desc': "Can't contact LDAP server", 'ctrls': []})
|
[WARNING][2025-12-02 15:56:55,439][backend.py:91]Caught LDAPError looking up user: SERVER_DOWN({'result': -1, 'desc': "Can't contact LDAP server", 'ctrls': []})
|
||||||
|
[WARNING][2025-12-02 21:18:59,902][backend.py:91]Caught LDAPError looking up user: SERVER_DOWN({'result': -1, 'desc': "Can't contact LDAP server", 'ctrls': []})
|
||||||
|
[WARNING][2025-12-02 21:19:00,236][operation.py:131]"POST - UserTokenController[obtain_token] /api/system/login" 401
|
||||||
|
[WARNING][2025-12-02 21:19:00,238][log.py:253]Unauthorized: /api/system/login
|
||||||
|
[WARNING][2025-12-02 21:24:22,073][backend.py:91]Caught LDAPError looking up user: SERVER_DOWN({'result': -1, 'desc': "Can't contact LDAP server", 'ctrls': []})
|
||||||
|
[WARNING][2025-12-03 15:13:23,183][log.py:253]Unauthorized: /api/system/getInfo
|
||||||
|
[WARNING][2025-12-03 15:13:23,373][log.py:253]Unauthorized: /api/system/logout
|
||||||
|
[WARNING][2025-12-03 15:17:42,724][backend.py:91]Caught LDAPError looking up user: SERVER_DOWN({'result': -1, 'desc': "Can't contact LDAP server", 'ctrls': []})
|
||||||
|
[WARNING][2025-12-03 15:30:54,106][log.py:253]Not Found: /
|
||||||
|
[WARNING][2025-12-03 15:30:54,221][log.py:253]Not Found: /favicon.ico
|
||||||
|
[WARNING][2025-12-03 15:31:06,398][operation.py:131]"POST - AITestController[ai_return] /api/local_doc_qa/testing_item" ('Type is not JSON serializable: AIPostSchema',)
|
||||||
|
[ERROR][2025-12-03 15:31:06,398][errors.py:131]Type is not JSON serializable: AIPostSchema
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "E:\pycharmProjects\cdtestplant_v1\.venv\Lib\site-packages\ninja_extra\operation.py", line 214, in run
|
||||||
|
_processed_results = self._result_to_response(
|
||||||
|
request, result, ctx.response
|
||||||
|
)
|
||||||
|
File "E:\pycharmProjects\cdtestplant_v1\.venv\Lib\site-packages\ninja\operation.py", line 270, in _result_to_response
|
||||||
|
return self.api.create_response(
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~^
|
||||||
|
request, result, temporal_response=temporal_response
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
)
|
||||||
|
^
|
||||||
|
File "E:\pycharmProjects\cdtestplant_v1\utils\chen_ninja.py", line 41, in create_response
|
||||||
|
content = self.renderer.render(request, std_data, response_status=status)
|
||||||
|
File "E:\pycharmProjects\cdtestplant_v1\cdtestplant_v1\renderer.py", line 11, in render
|
||||||
|
return orjson.dumps(data)
|
||||||
|
~~~~~~~~~~~~^^^^^^
|
||||||
|
TypeError: Type is not JSON serializable: AIPostSchema
|
||||||
|
[ERROR][2025-12-03 15:31:06,400][log.py:253]Internal Server Error: /api/local_doc_qa/testing_item
|
||||||
|
[WARNING][2025-12-03 15:32:42,222][operation.py:131]"POST - AITestController[ai_return] /api/local_doc_qa/testing_item" ('Object of type AIPostSchema is not JSON serializable',)
|
||||||
|
[ERROR][2025-12-03 15:32:42,222][errors.py:131]Object of type AIPostSchema is not JSON serializable
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "E:\pycharmProjects\cdtestplant_v1\.venv\Lib\site-packages\ninja_extra\operation.py", line 212, in run
|
||||||
|
result = self.view_func(request, **ctx.kwargs["view_func_kwargs"])
|
||||||
|
File "E:\pycharmProjects\cdtestplant_v1\.venv\Lib\site-packages\ninja_extra\controllers\route\route_functions.py", line 99, in as_view
|
||||||
|
result = self.route.view_func(
|
||||||
|
ctx.controller_instance, *args, **ctx.view_func_kwargs
|
||||||
|
)
|
||||||
|
File "E:\pycharmProjects\cdtestplant_v1\apps\dict\controllers\common.py", line 23, in ai_return
|
||||||
|
return ChenResponse(data=item)
|
||||||
|
File "E:\pycharmProjects\cdtestplant_v1\utils\chen_response.py", line 24, in __init__
|
||||||
|
data = json.dumps(std_data, cls=DateEncoder)
|
||||||
|
File "D:\python13\Lib\json\__init__.py", line 238, in dumps
|
||||||
|
**kw).encode(obj)
|
||||||
|
~~~~~~^^^^^
|
||||||
|
File "D:\python13\Lib\json\encoder.py", line 200, in encode
|
||||||
|
chunks = self.iterencode(o, _one_shot=True)
|
||||||
|
File "D:\python13\Lib\json\encoder.py", line 261, in iterencode
|
||||||
|
return _iterencode(o, 0)
|
||||||
|
File "E:\pycharmProjects\cdtestplant_v1\utils\chen_response.py", line 11, in default
|
||||||
|
return json.JSONEncoder.default(self, obj)
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
|
||||||
|
File "D:\python13\Lib\json\encoder.py", line 180, in default
|
||||||
|
raise TypeError(f'Object of type {o.__class__.__name__} '
|
||||||
|
f'is not JSON serializable')
|
||||||
|
TypeError: Object of type AIPostSchema is not JSON serializable
|
||||||
|
[ERROR][2025-12-03 15:32:42,229][log.py:253]Internal Server Error: /api/local_doc_qa/testing_item
|
||||||
|
[WARNING][2025-12-03 15:33:12,683][operation.py:131]"POST - AITestController[ai_return] /api/local_doc_qa/testing_item" ('Object of type AIPostSchema is not JSON serializable',)
|
||||||
|
[ERROR][2025-12-03 15:33:12,683][errors.py:131]Object of type AIPostSchema is not JSON serializable
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "E:\pycharmProjects\cdtestplant_v1\.venv\Lib\site-packages\ninja_extra\operation.py", line 212, in run
|
||||||
|
result = self.view_func(request, **ctx.kwargs["view_func_kwargs"])
|
||||||
|
File "E:\pycharmProjects\cdtestplant_v1\.venv\Lib\site-packages\ninja_extra\controllers\route\route_functions.py", line 99, in as_view
|
||||||
|
result = self.route.view_func(
|
||||||
|
ctx.controller_instance, *args, **ctx.view_func_kwargs
|
||||||
|
)
|
||||||
|
File "E:\pycharmProjects\cdtestplant_v1\apps\dict\controllers\common.py", line 26, in ai_return
|
||||||
|
return ChenResponse(data=item)
|
||||||
|
File "E:\pycharmProjects\cdtestplant_v1\utils\chen_response.py", line 24, in __init__
|
||||||
|
data = json.dumps(std_data, cls=DateEncoder)
|
||||||
|
File "D:\python13\Lib\json\__init__.py", line 238, in dumps
|
||||||
|
**kw).encode(obj)
|
||||||
|
~~~~~~^^^^^
|
||||||
|
File "D:\python13\Lib\json\encoder.py", line 200, in encode
|
||||||
|
chunks = self.iterencode(o, _one_shot=True)
|
||||||
|
File "D:\python13\Lib\json\encoder.py", line 261, in iterencode
|
||||||
|
return _iterencode(o, 0)
|
||||||
|
File "E:\pycharmProjects\cdtestplant_v1\utils\chen_response.py", line 11, in default
|
||||||
|
return json.JSONEncoder.default(self, obj)
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
|
||||||
|
File "D:\python13\Lib\json\encoder.py", line 180, in default
|
||||||
|
raise TypeError(f'Object of type {o.__class__.__name__} '
|
||||||
|
f'is not JSON serializable')
|
||||||
|
TypeError: Object of type AIPostSchema is not JSON serializable
|
||||||
|
[ERROR][2025-12-03 15:33:12,703][log.py:253]Internal Server Error: /api/local_doc_qa/testing_item
|
||||||
|
[WARNING][2025-12-03 15:49:10,317][log.py:253]Not Found: /api/api/local_doc_qa/testing_item
|
||||||
|
[ERROR][2025-12-03 17:38:54,536][log.py:253]Internal Server Error: /api/project/testDemand/save
|
||||||
|
[ERROR][2025-12-03 17:45:58,931][log.py:253]Internal Server Error: /api/project/testDemand/save
|
||||||
|
[WARNING][2025-12-04 09:54:24,808][backend.py:91]Caught LDAPError looking up user: SERVER_DOWN({'result': -1, 'desc': "Can't contact LDAP server", 'ctrls': []})
|
||||||
|
[ERROR][2025-12-04 09:55:44,899][log.py:253]Internal Server Error: /api/project/testDemand/save
|
||||||
|
[ERROR][2025-12-04 09:57:37,563][log.py:253]Internal Server Error: /api/project/testDemand/save
|
||||||
|
[ERROR][2025-12-04 09:58:39,189][log.py:253]Internal Server Error: /api/project/testDemand/save
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
Django~=5.2.8
|
Django~=5.2.9
|
||||||
django-auth-ldap~=5.2.0
|
django-auth-ldap~=5.2.0
|
||||||
asgiref~=3.10.0
|
asgiref~=3.11.0
|
||||||
sqlparse~=0.5.3
|
sqlparse~=0.5.4
|
||||||
# 基础包
|
# 基础包
|
||||||
mysqlclient~=2.2.7
|
mysqlclient~=2.2.7
|
||||||
orjson~=3.11.4
|
orjson~=3.11.4
|
||||||
@@ -12,24 +12,24 @@ python-ldap~=3.4.4
|
|||||||
# 项目包
|
# 项目包
|
||||||
django-environ~=0.12.0
|
django-environ~=0.12.0
|
||||||
django-ninja~=1.5.0
|
django-ninja~=1.5.0
|
||||||
pydantic~=2.12.4
|
pydantic~=2.12.5
|
||||||
pydantic-core~=2.41.5
|
pydantic-core~=2.41.5
|
||||||
django-ninja-extra~=0.30.6
|
django-ninja-extra~=0.30.6
|
||||||
django-ninja-jwt~=5.4.2
|
django-ninja-jwt~=5.4.2
|
||||||
django-tinymce~=5.0.0
|
django-tinymce~=5.0.0
|
||||||
PyJWT~=2.10.1
|
PyJWT~=2.10.1
|
||||||
cryptography~=45.0.6
|
cryptography~=46.0.3
|
||||||
ninja-schema~=0.14.3
|
ninja-schema~=0.14.3
|
||||||
user-agents~=2.2.0
|
user-agents~=2.2.0
|
||||||
numpy~=2.3.4
|
numpy~=2.3.5
|
||||||
docxtpl~=0.20.2
|
docxtpl~=0.20.2
|
||||||
python-docx~=1.2.0
|
python-docx~=1.2.0
|
||||||
Jinja2~=3.1.6
|
Jinja2~=3.1.6
|
||||||
django-redis~=6.0.0
|
django-redis~=6.0.0
|
||||||
pandas~=2.3.3
|
pandas~=2.3.3
|
||||||
beautifulsoup4~=4.14.2
|
beautifulsoup4~=4.14.3
|
||||||
python-dateutil~=2.9.0.post0
|
python-dateutil~=2.9.0.post0
|
||||||
redis~=7.0.1
|
redis~=7.1.0
|
||||||
waitress~=3.0.2
|
waitress~=3.0.2
|
||||||
django-shortuuidfield~=0.1.3
|
django-shortuuidfield~=0.1.3
|
||||||
lizard~=1.19.0
|
lizard~=1.19.0
|
||||||
|
|||||||
Reference in New Issue
Block a user