From 1304fec1c4480cfffd8f38da757a553ecd60229f Mon Sep 17 00:00:00 2001 From: wangwei Date: Tue, 23 Jun 2026 10:03:46 +0800 Subject: [PATCH] fix: change ScoreRequest json_schema_extra from examples list to example dict Swagger UI Try it out was sending the {summary, value} wrapper as request body instead of just the value contents, causing 422 errors. The 'example' (singular) key is correctly used as the schema-level example by Swagger UI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- webapp/models.py | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/webapp/models.py b/webapp/models.py index 0d9484d..69f5010 100644 --- a/webapp/models.py +++ b/webapp/models.py @@ -408,26 +408,21 @@ class ScoreRequest(BaseModel): model_config = ConfigDict( json_schema_extra={ - "examples": [ - { - "summary": "基础评分请求", - "value": { - "question": "双源CT的时间分辨率是多少?", - "answer": "双源CT的单扇区时间分辨率为75ms。", - "contexts": "双源CT采用两套管-探测器系统 |||| 单扇区采集旋转135度", - "ground_truth": "双源CT单扇区时间分辨率为75ms,需旋转135度。", - "context_separator": " |||| ", - "metrics": [ - "faithfulness", - "answer_relevancy", - "context_recall", - "context_precision", - ], - "judge_model": "deepseek-v4-flash", - "embedding_model": "text-embedding-v3", - }, - } - ] + "example": { + "question": "双源CT的时间分辨率是多少?", + "answer": "双源CT的单扇区时间分辨率为75ms。", + "contexts": "双源CT采用两套管-探测器系统 |||| 单扇区采集旋转135度", + "ground_truth": "双源CT单扇区时间分辨率为75ms,需旋转135度。", + "context_separator": " |||| ", + "metrics": [ + "faithfulness", + "answer_relevancy", + "context_recall", + "context_precision", + ], + "judge_model": "deepseek-v4-flash", + "embedding_model": "text-embedding-v3", + } } )