Spaces:
Running
Running
File size: 462 Bytes
f2d60b7 af3ecbd f2d60b7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | from loguru import logger
from openai import OpenAI
from config import EMBEDDING_MODEL
def convert_embedding_batch(contents: list[str], client: OpenAI) -> list[list[float]]:
logger.debug(
f"CALL convert_embedding_batch, batch_size={len(contents)}, first_hash={hash(contents[0])}"
)
response = client.embeddings.create(
model=EMBEDDING_MODEL, input=contents, timeout=7200
)
return [item.embedding for item in response.data]
|