6b7e6b44f1
Python Build and Type Check / python-ci (ubuntu-latest, 3.11) (push) Has been cancelled
Python Build and Type Check / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Build and Type Check / python-ci (windows-latest, 3.11) (push) Has been cancelled
Python Build and Type Check / python-ci (windows-latest, 3.13) (push) Has been cancelled
Python Integration Tests / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Integration Tests / python-ci (windows-latest, 3.13) (push) Has been cancelled
Python Notebook Tests / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Notebook Tests / python-ci (windows-latest, 3.13) (push) Has been cancelled
Python Smoke Tests / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Smoke Tests / python-ci (windows-latest, 3.13) (push) Has been cancelled
Python Unit Tests / python-ci (ubuntu-latest, 3.13) (push) Has been cancelled
Python Unit Tests / python-ci (windows-latest, 3.13) (push) Has been cancelled
gh-pages / build (push) Has been cancelled
Python Publish (pypi) / Upload release to PyPI (push) Has been cancelled
Spellcheck / spellcheck (push) Has been cancelled
40 lines
971 B
Python
40 lines
971 B
Python
# Copyright (c) 2024 Microsoft Corporation.
|
|
# Licensed under the MIT License
|
|
|
|
"""Create embedding response utilities."""
|
|
|
|
from graphrag_llm.types import LLMEmbedding, LLMEmbeddingResponse, LLMEmbeddingUsage
|
|
|
|
|
|
def create_embedding_response(
|
|
embeddings: list[float], batch_size: int = 1
|
|
) -> LLMEmbeddingResponse:
|
|
"""Create a CreateEmbeddingResponse object.
|
|
|
|
Args:
|
|
embeddings: List of embedding vectors.
|
|
model: The model used to create the embeddings.
|
|
|
|
Returns
|
|
-------
|
|
An LLMEmbeddingResponse object.
|
|
"""
|
|
embeddings_objects = [
|
|
LLMEmbedding(
|
|
object="embedding",
|
|
embedding=embeddings,
|
|
index=index,
|
|
)
|
|
for index in range(batch_size)
|
|
]
|
|
|
|
return LLMEmbeddingResponse(
|
|
object="list",
|
|
data=embeddings_objects,
|
|
model="mock-model",
|
|
usage=LLMEmbeddingUsage(
|
|
prompt_tokens=0,
|
|
total_tokens=0,
|
|
),
|
|
)
|