添加search方法

This commit is contained in:
2025-12-23 00:36:49 +08:00
parent 1585b2c31b
commit 9b283d2f72
5 changed files with 134 additions and 4 deletions

View File

@@ -57,7 +57,7 @@ def chunks_embedding(texts: list[str], api_key: str) -> list[list[float]]:
if "output" in result and "embeddings" in result["output"]:
embeddings_list = result["output"]["embeddings"]
embeddings_list.sort(key=lambda x: x["text_index"])
embeddings_list.sort(key=lambda x: x["text_index"]) # 按文本索引排序,确保顺序一致
# --- 核心修复:对每个浮点数保留 8 位小数,解决精度过高报错 ---
final_vectors = []