chatbot-ui backend using FastAPI, LangChain and Lanarky.
The backend code is built with Python 3.11. Follow the steps below to get started.
-
Create conda environment:
conda create -n chatbot-ui python=3.11 -y conda activate chatbot-ui
You can choose any other environment manager of your choice.
-
Install dependencies:
pip install -r requirements.in
Note: All requirement files are generated using
pip-tools
.
Run the app locally:
uvicorn app:app --reload
You can the Swagger UI at http://localhost:8000/docs.
Sample curl request:
curl -X 'POST' \
'http://localhost:8000/chat' \
-H 'accept: application/json' \
-H 'Authorization: Bearer $OPENAI_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant"
},
{
"role": "user",
"content": "hello!"
}
],
"max_tokens": 1000,
"temperature": 0
}'