refactor: update API endpoint paths to include admin prefix

This commit is contained in:
CaptainB 2025-07-01 18:08:12 +08:00
parent f9a8b9c270
commit 8c0361bbc2

View File

@ -30,7 +30,8 @@ class WebLocalEmbedding(MaxKBBaseModel, BaseModel, Embeddings):
def embed_query(self, text: str) -> List[float]:
bind = f'{CONFIG.get("LOCAL_MODEL_HOST")}:{CONFIG.get("LOCAL_MODEL_PORT")}'
res = requests.post(f'{CONFIG.get("LOCAL_MODEL_PROTOCOL")}://{bind}/api/model/{self.model_id}/embed_query',
prefix = CONFIG.get_admin_path()
res = requests.post(f'{CONFIG.get("LOCAL_MODEL_PROTOCOL")}://{bind}{prefix}/api/model/{self.model_id}/embed_query',
{'text': text})
result = res.json()
if result.get('code', 500) == 200:
@ -39,7 +40,8 @@ class WebLocalEmbedding(MaxKBBaseModel, BaseModel, Embeddings):
def embed_documents(self, texts: List[str]) -> List[List[float]]:
bind = f'{CONFIG.get("LOCAL_MODEL_HOST")}:{CONFIG.get("LOCAL_MODEL_PORT")}'
res = requests.post(f'{CONFIG.get("LOCAL_MODEL_PROTOCOL")}://{bind}/api/model/{self.model_id}/embed_documents',
prefix = CONFIG.get_admin_path()
res = requests.post(f'{CONFIG.get("LOCAL_MODEL_PROTOCOL")}://{bind}/{prefix}/api/model/{self.model_id}/embed_documents',
{'texts': texts})
result = res.json()
if result.get('code', 500) == 200: