mirror of
https://github.com/hwchase17/langchain
synced 2024-11-04 06:00:26 +00:00
Updated LocalAIEmbeddings
docstring to better explain why openai
(#10946)
Fixes my misgivings in https://github.com/langchain-ai/langchain/issues/10912
This commit is contained in:
parent
2c114fcb5e
commit
b11f21c25f
@ -120,16 +120,19 @@ async def async_embed_with_retry(embeddings: LocalAIEmbeddings, **kwargs: Any) -
|
|||||||
class LocalAIEmbeddings(BaseModel, Embeddings):
|
class LocalAIEmbeddings(BaseModel, Embeddings):
|
||||||
"""LocalAI embedding models.
|
"""LocalAI embedding models.
|
||||||
|
|
||||||
To use, you should have the ``openai`` python package installed, and the
|
Since LocalAI and OpenAI have 1:1 compatibility between APIs, this class
|
||||||
environment variable ``OPENAI_API_KEY`` set to a random string. You need to
|
uses the ``openai`` Python package's ``openai.Embedding`` as its client.
|
||||||
specify ``OPENAI_API_BASE`` to point to your LocalAI service endpoint.
|
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:
|
Example:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
from langchain.embeddings import LocalAIEmbeddings
|
from langchain.embeddings import LocalAIEmbeddings
|
||||||
openai = LocalAIEmbeddings(
|
openai = LocalAIEmbeddings(
|
||||||
openai_api_key="random-key",
|
openai_api_key="random-string",
|
||||||
openai_api_base="http://localhost:8080"
|
openai_api_base="http://localhost:8080"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user