Skip to content

Commit

Permalink
Fix lint errors, ported client.embeddings.create
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jan 26, 2024
1 parent 9493da9 commit d9d5c72
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions llm/default_plugins/openai_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ def embed_batch(self, items: Iterable[Union[str, bytes]]) -> Iterator[List[float
kwargs = {
"input": items,
"model": self.openai_model_id,
"api_key": self.get_key(),
}
if self.dimensions:
kwargs["dimensions"] = self.dimensions
results = client.Embedding.create(**kwargs)["data"]
return ([float(r) for r in result["embedding"]] for result in results)
client = openai.OpenAI(api_key=self.get_key())
results = client.embeddings.create(**kwargs).data
return ([float(r) for r in result.embedding] for result in results)


@hookimpl
Expand Down
2 changes: 1 addition & 1 deletion llm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def dicts_to_table_string(
return res


def remove_dict_none_values(d: dict) -> dict:
def remove_dict_none_values(d):
"""
Recursively remove keys with value of None or value of a dict that is all values of None
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import llm
from llm.plugins import pm
from pydantic import Field
from pytest_httpx import HTTPXMock, IteratorStream
from pytest_httpx import IteratorStream
from typing import Optional


Expand Down

0 comments on commit d9d5c72

Please sign in to comment.