Skip to content

Commit

Permalink
Updated LocalAIEmbeddings docstring to better explain why openai (#…
Browse files Browse the repository at this point in the history
…10946)

Fixes my misgivings in
#10912
  • Loading branch information
jamesbraza authored Sep 29, 2023
1 parent 2c114fc commit b11f21c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions libs/langchain/langchain/embeddings/localai.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,19 @@ async def _async_embed_with_retry(**kwargs: Any) -> Any:
class LocalAIEmbeddings(BaseModel, Embeddings):
"""LocalAI embedding models.
To use, you should have the ``openai`` python package installed, and the
environment variable ``OPENAI_API_KEY`` set to a random string. You need to
specify ``OPENAI_API_BASE`` to point to your LocalAI service endpoint.
Since LocalAI and OpenAI have 1:1 compatibility between APIs, this class
uses the ``openai`` Python package's ``openai.Embedding`` as its client.
Thus, you should have the ``openai`` python package installed, and defeat
the environment variable ``OPENAI_API_KEY`` by setting to a random string.
You also need to specify ``OPENAI_API_BASE`` to point to your LocalAI
service endpoint.
Example:
.. code-block:: python
from langchain.embeddings import LocalAIEmbeddings
openai = LocalAIEmbeddings(
openai_api_key="random-key",
openai_api_key="random-string",
openai_api_base="http://localhost:8080"
)
Expand Down

0 comments on commit b11f21c

Please sign in to comment.