LocalAI/examples/langchain-python
Ettore Di Giacinto 577d36b596
images: cleanup, drop .dev Dockerfile (#437)
Signed-off-by: mudler <mudler@mocaccino.org>
2023-05-30 15:58:10 +02:00
..
agent.py examples: add langchain agent example 2023-05-07 08:14:01 +02:00
docker-compose.yaml images: cleanup, drop .dev Dockerfile (#437) 2023-05-30 15:58:10 +02:00
models Return usage in the API responses (#166) 2023-05-03 17:29:18 +02:00
README.md feat: allow to override model config (#323) 2023-05-20 17:03:53 +02:00
test.py Return usage in the API responses (#166) 2023-05-03 17:29:18 +02:00

Langchain-python

Langchain example from quickstart.

To interact with langchain, you can just set the OPENAI_API_BASE URL and provide a token with a random string.

See the example below:

# Clone LocalAI
git clone https://github.com/go-skynet/LocalAI

cd LocalAI/examples/langchain-python

# (optional) Checkout a specific LocalAI tag
# git checkout -b build <TAG>

# Download gpt4all-j to models/
wget https://gpt4all.io/models/ggml-gpt4all-j.bin -O models/ggml-gpt4all-j

# start with docker-compose
docker-compose up -d --build


pip install langchain
pip install openai

export OPENAI_API_BASE=http://localhost:8080
# Note: **OPENAI_API_KEY** is not required. However the library might fail if no API_KEY is passed by, so an arbitrary string can be used.
export OPENAI_API_KEY=sk-

python test.py
# A good company name for a company that makes colorful socks would be "Colorsocks".

python agent.py