Skip to content

Commit

Permalink
Merge pull request wagtail#79 from wagtail/fix/litellm-aembed-returns…
Browse files Browse the repository at this point in the history
…-iterator

LiteLLM's aembed method returns an Iterator to conform to BaseEmbeddingBackend
  • Loading branch information
tomusher authored Jul 25, 2024
2 parents 1f74ee2 + 41643db commit 412632f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/wagtail_vector_index/ai_utils/backends/litellm.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ def embed(self, inputs: Iterable[str], **kwargs) -> Iterator[list[float]]:
assert isinstance(response, litellm.EmbeddingResponse)
yield from [data["embedding"] for data in response["data"]]

async def aembed(self, inputs: Iterable[str], **kwargs) -> list[float]:
async def aembed(self, inputs: Iterable[str], **kwargs) -> Iterator[list[float]]:
response = await litellm.aembedding(
model=self.config.model_id, input=inputs, **kwargs
)

return [data["embedding"] for data in response["data"]]
return iter([data["embedding"] for data in response["data"]])

0 comments on commit 412632f

Please sign in to comment.