1234567891011121314151617181920212223 |
- from applications.config import MODEL_CONFIG
- from applications.utils import AsyncHttpClient
- async def get_basic_embedding(text: str, model: str):
- """
- embedding text into vectors
- :param text:
- :param model:
- :return:
- """
- cfg = MODEL_CONFIG[model]
- async with AsyncHttpClient(timeout=20) as client:
- response = await client.post(
- url=cfg["url"],
- json={"input": text, "model": model},
- headers={"Content-Type": "application/json"},
- )
- return response['data'][0]["embedding"]
- __all__ = [
- "get_basic_embedding"
- ]
|