原始代码
This commit is contained in:
11
xinference_client.py
Normal file
11
xinference_client.py
Normal file
@@ -0,0 +1,11 @@
|
||||
import requests
|
||||
from typing import List
|
||||
|
||||
XINFERENCE_EMBED_URL = "http://127.0.0.1:9997/models/bge-base-zh/embed"
|
||||
|
||||
def embed_texts(texts: List[str]) -> List[List[float]]:
|
||||
payload = {"inputs": texts}
|
||||
resp = requests.post(XINFERENCE_EMBED_URL, json=payload, timeout=30)
|
||||
resp.raise_for_status()
|
||||
data = resp.json()
|
||||
return data.get("embeddings", [])
|
||||
Reference in New Issue
Block a user