feat:embeding改成支持电信模型

This commit is contained in:
雷雨
2025-09-29 19:29:26 +08:00
parent c537a5fdd5
commit 3285f3bca7
2 changed files with 6 additions and 6 deletions

4
.env
View File

@@ -3,8 +3,8 @@ IS_FIRST_LOAD=True
CHAT_MODEL_BASE_URL=https://api.siliconflow.cn CHAT_MODEL_BASE_URL=https://api.siliconflow.cn
CHAT_MODEL_API_KEY=sk-iyhiltycmrfnhrnbljsgqjrinhbztwdplyvuhfihcdlepole CHAT_MODEL_API_KEY=sk-iyhiltycmrfnhrnbljsgqjrinhbztwdplyvuhfihcdlepole
CHAT_MODEL_NAME=zai-org/GLM-4.5 CHAT_MODEL_NAME=zai-org/GLM-4.5
#使用ai中台的模型
EMBEDDING_MODEL_BASE_URL=https://api.siliconflow.cn EMBEDDING_MODEL_BASE_URL=http://10.225.128.2:13206/member1/small-model/bge/encode
EMBEDDING_MODEL_API_KEY=sk-iyhiltycmrfnhrnbljsgqjrinhbztwdplyvuhfihcdlepole EMBEDDING_MODEL_API_KEY=sk-iyhiltycmrfnhrnbljsgqjrinhbztwdplyvuhfihcdlepole
EMBEDDING_MODEL_NAME=BAAI/bge-m3 EMBEDDING_MODEL_NAME=BAAI/bge-m3

View File

@@ -270,21 +270,21 @@ class CustomQdrant_VectorStore(Qdrant_VectorStore):
request_body = { request_body = {
"model": self.embedding_model_name, "model": self.embedding_model_name,
"input": data, "sentences": [data],
} }
request_body.update(kwargs) request_body.update(kwargs)
response = requests.post( response = requests.post(
url=f"{self.embedding_api_base}/v1/embeddings", url=f"{self.embedding_api_base}",
json=request_body, json=request_body,
headers={"Authorization": f"Bearer {self.embedding_api_key}"}, headers={"Authorization": f"Bearer {self.embedding_api_key}", 'Content-Type': 'application/json'},
) )
if response.status_code != 200: if response.status_code != 200:
raise RuntimeError( raise RuntimeError(
f"Failed to create the embeddings, detail: {_get_error_string(response)}" f"Failed to create the embeddings, detail: {_get_error_string(response)}"
) )
result = response.json() result = response.json()
embeddings = [d["embedding"] for d in result["data"]] embeddings = result['embeddings']
return embeddings[0] return embeddings[0]
class CustomVanna(CustomQdrant_VectorStore, OpenAICompatibleLLM): class CustomVanna(CustomQdrant_VectorStore, OpenAICompatibleLLM):