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