main.py
: This is the main FastAPI application file where we have registered all our endpoints.dependencies.py
: Contains the code for loading environment variables, setting up the MongoDB connection and initializing the llms.prompt_templates.py
: Stores all the template string for the prompts.prompt_examples.py
: Loads all the examples for each prompt from the database.prompts.py
: Creates all the Prompts(LangChain Format) by importing prompt templates fromprompt_templates.py
and examples fromprompt_examples.py
clf_api.py
: This file has the enpoint for classifying the user complaint.rl_apis.py
: This file contains the endpoints for updating the examples for the prompt.translate.py
: This file provides the translation from english to spanish and korean.
Commands after SSHing into remote Azure server:
- cd ssd/sensfix-demo/
- git pull origin main
- deactivate
- rm -rf venv
- python3.8 -m venv venv
- source venv/bin/activate
- pip install -r requirements.txt
- Inside tmux session:
8.1 Ctrl + C 8.2 deactivate 8.3 source venv/bin/activate 8.4 uvicorn main:app --port 9000 8.5 Ctrl + B. Then D.
- deactivate
-
Set up your credentials by creating a
.env
file in the project directory with the following content:MONGO_DB_URI=<your mongo db uri> OPENAI_API_KEY=<your api key> DB=<database name> COLLECTION_CAT_L1=<collection name for category l1> COLLECTION_CAT_L1=<collection name for category l2> COLLECTION_VALID=<collection name for valid complaint(complete/not complete)> COLLECTION_TICKET=<collection name for complaint ticket(ticket/not ticket)> COLLECTION_RESP=<collection name for complaint reponse> TRANSLATE_KEY=<rapid api key for google translate by google cloud>
Translate API link: https://rapidapi.com/googlecloud/api/google-translate1
-
Clone this repository to your local machine:
git clone https://github.com/T3xtifyai/sensifix-demo.git
and move the .env file into this folder.
-
Navigate to the project directory:
cd sensifix-demo
-
There are two ways you can run the app.
a. Use Docker (recommended)
first build the docker image
docker build -t sensfix_image ./
second run the docker image
docker run -d --name sensfix_container -p 80:80 sensfix_image
left part in port 80:80 is host port and the right part is the container port.
b. Virtual environment
python -m venv venv source venv/bin/activate # On Windows, use: venv\Scripts\activate
Install the project dependencies:
pip install -r requirements.txt
uvicorn main:app
-
Access the API in your web browser or use a tool like
curl
orhttpie
to make HTTP requests.
-
/ticket_qualification
: Categorize user complaint and generate the appropriate response
inputs:user_input
: user complaint,language
,memory
: previous context.
output:ticket_status
,category
, andresponse
-
/complaint_is_complete
: endpoint to update the valid complaint type(complete/incomplete)
inputs:text
: complaint text,correct_class
: could be either ("complete", "incomplete"). -
/complaint_l1_type
: endpoint to update the correct level 1 category of the complaint
inputs:text
: complaint text,correct_class
: could be either ("electrical_it", "cleaning_janitorial", "building_infrastructure", "security"). -
/complaint_l2_type
: endpoint to update the correct level 2 category of the complaint
inputs:text
: complaint text,correct_class
: could be either ("electrical", "it", "cleaning", "janitorial", "building", "infrastructure", "security"). -
/complaint_response
: endpoint to update the correct response for complaint with the correct category
inputs:complaint_text
: complaint text,complaint_response
,complaint_class
: could be either ("electrical", "it", "cleaning", "janitorial", "building", "infrastructure", "security"). -
/ticket_clf
: endpoint to update the correct ticket type of the complaint
inputs:text
: complaint text,correct_class
: could be either ("ticket", "not_ticket").
- 200: Success
- 430: Incomplete complaint
- 431: Invalid Level 1 classification
- 432: Invalid Level 2 classification
- 504: Project API Gateway Timeout, the request is not completed within time.