|
|
@@ -339,7 +339,8 @@ class QuestionDuplicateChecker:
|
|
|
{"role": "system", "content": "你是一个专业的数学题目查重助手。"},
|
|
|
{"role": "user", "content": prompt}
|
|
|
],
|
|
|
- response_format={"type": "json_object"}
|
|
|
+ response_format={"type": "json_object"},
|
|
|
+ temperature=0
|
|
|
)
|
|
|
|
|
|
result = json.loads(response.choices[0].message.content)
|
|
|
@@ -475,6 +476,21 @@ class QuestionDuplicateChecker:
|
|
|
|
|
|
return {"status": "success", "is_duplicate": False, "top_similar": []}
|
|
|
|
|
|
+ def get_question_data(self, question_id: int) -> Dict:
|
|
|
+ """获取向量库中特定ID的数据及总数"""
|
|
|
+ total_count = self.index.ntotal if self.index else 0
|
|
|
+
|
|
|
+ target_metadata = None
|
|
|
+ for m in self.metadata:
|
|
|
+ if m['id'] == question_id:
|
|
|
+ target_metadata = m
|
|
|
+ break
|
|
|
+
|
|
|
+ return {
|
|
|
+ "total_count": total_count,
|
|
|
+ "question_data": target_metadata
|
|
|
+ }
|
|
|
+
|
|
|
def add_to_index(self, question_id: int, vector: np.ndarray, text: str):
|
|
|
"""将题目加入索引"""
|
|
|
if any(m['id'] == question_id for m in self.metadata):
|