Sign inSign up

kuberlab/ira-chat-api

By kuberlab

Updated 1 day ago

Image
0

10K+

kuberlab/ira-chat-api repository overview

ira-chat-api

Prerequisites
  • Python 3.10+
  • Available Postgres DBMS (either locally or remotely) and Database
    • PostgresQL installation link1 link2
    • Create database: createdb ira (should work when usual psql command works)
Install requirements

Install all the requirements in virtual env of your choice (using conda, virtualenv or plain pip)

pip install -r requirements.txt
Run locally
Connect to the Postgres

Supply env variables for the DB

export PGHOST=localhost
export PGUSER=postgres
export PGPASSWORD=passwd
export PGDATABASE=ira

Supply env variables related to OpenAI and Pinecone:

export OPENAI_API_KEY=sk-xxxx
export HUGGINGFACE_API_KEY=hf_xxxx

export AUTH_KEY="random-admin-key"
export BASE_URL=http://localhost:8083
export VECTORSTORE=pinecone
export ENV_PREFIX=local
export PINECONE_ENVIRONMENT=asia-southeast1-gcp 
export PINECONE_API_KEY=api-key
export PINECONE_INDEX=hotline-dev
export LLM_MODEL_NAME=gpt-3.5-turbo
export ENGINE_TYPE=langchain

Better keep all these variables together locally in one file like ~/.irarc to be able to activate it with one command:

. ~/.irarc
Run server
python ira_chat/main.py
Run server with DB debug:
DEBUG_DB=true python ira_chat/main.py
Run server with Prompt debug:
DEBUG_PROMPT=true python ira_chat/main.py
Important: before the first access the API

Before the start, it needs to create a first organization with a domain to be able to access the API:

org_name=my-local-org
psql ira -c "INSERT INTO organizations (name, display_name, created_at, updated_at) values ('$org_name', '$org_name', now(), now())"
psql ira -c "INSERT INTO organization_domains (domain, org_id) values ('$org_name.localhost', (select id from organizations where name = '$org_name'))"

In order to access the organization locally with domain in form xxx.localhost, this host must be added into the /etc/hosts file, add this to the end:

127.0.0.1 my-local-org.localhost

Now the API server is available at http://localhost:8083 and the organization API is available at http://my-local-org.localhost:8083

Run using docker (adjust variables):
docker run -it --rm -e PGHOST=192.168.88.54 -e PGUSER=postgres -e PGPASSWORD=passwd \
 -e PGDATABASE=ira kuberlab/ira-chat-api:latest
Swagger docs

Swagger documentation is at http://localhost:8083/docs

Tag summary

Content type

Image

Digest

sha256:ac9c739b4

Size

645.7 MB

Last updated

1 day ago

docker pull kuberlab/ira-chat-api