2023-05-03 15:29:18 +00:00
|
|
|
## Langchain-python
|
|
|
|
|
|
|
|
Langchain example from [quickstart](https://python.langchain.com/en/latest/getting_started/getting_started.html).
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
# start with docker-compose
|
2023-06-07 22:05:17 +00:00
|
|
|
docker-compose up --pull always
|
2023-05-03 15:29:18 +00:00
|
|
|
|
|
|
|
pip install langchain
|
|
|
|
pip install openai
|
|
|
|
|
|
|
|
export OPENAI_API_BASE=http://localhost:8080
|
2023-05-20 15:03:53 +00:00
|
|
|
# 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.
|
2023-05-03 15:29:18 +00:00
|
|
|
export OPENAI_API_KEY=sk-
|
|
|
|
|
|
|
|
python test.py
|
|
|
|
# A good company name for a company that makes colorful socks would be "Colorsocks".
|
2023-05-07 06:14:01 +00:00
|
|
|
|
|
|
|
python agent.py
|
2023-05-03 15:29:18 +00:00
|
|
|
```
|