Files
opro_demo/xinference_client.py

12 lines
364 B
Python
Raw Permalink Normal View History

2025-12-05 07:11:25 +00:00
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", [])