Skip to content

Commit

Permalink
User Interface Added
Browse files Browse the repository at this point in the history
  • Loading branch information
Shashank1202 committed Jul 19, 2024
1 parent 5e0ff08 commit 40f9dfd
Show file tree
Hide file tree
Showing 16 changed files with 1,003 additions and 1 deletion.
98 changes: 98 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: workflow

on:
push:
branches:
- main
paths-ignore:
- 'README.md'

permissions:
id-token: write
contents: read

jobs:
integration:
name: Continuous Integration
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Lint code
run: echo "Linting repository"

- name: Run unit tests
run: echo "Running unit tests"

build-and-push-ecr-image:
name: Continuous Delivery
needs: integration
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Install Utilities
run: |
sudo apt-get update
sudo apt-get install -y jq unzip
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_NAME }}
IMAGE_TAG: latest
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
Continuous-Deployment:
needs: build-and-push-ecr-image
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1


- name: Pull latest images
run: |
docker pull ${{secrets.AWS_ECR_LOGIN_URI}}/${{ secrets.ECR_REPOSITORY_NAME }}:latest
# - name: Stop and remove container if running
# run: |
# docker ps -q --filter "name=chatbot" | grep -q . && docker stop texts && docker rm -fv chatbot

- name: Run Docker Image to serve users
run: |
docker run -d -p 8080:8080 --name=chatbot -e 'AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}' -e 'AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }}' -e 'AWS_REGION=${{ secrets.AWS_REGION }}' ${{secrets.AWS_ECR_LOGIN_URI}}/${{ secrets.ECR_REPOSITORY_NAME }}:latest
- name: Clean previous images and containers
run: |
docker system prune -f
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
# AI-Driven-Customer-Chatbot
# AI-Driven-Customer-Support-Chatbot

## Steps to run the project

```bash
Project reop: https://github.com/Shashank1202/AI-Driven-Customer-Chatbot.git
```

```bash
conda create -m yourenv_name python=3.8 -y
```

```bash
conda activate yourenv_name
```

```bash
pip install -r requirements.txt
```

```ini
PINECONE_API_KEY="YOUR KEY"
PINECONE_API_ENV="YOUR ENV"
```
58 changes: 58 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from flask import Flask, render_template, jsonify, request
from src.helper import download_hugging_face_embeddings
from langchain.vectorstores import Pinecone
import pinecone
from langchain.prompts import PromptTemplate
from langchain.llms import CTransformers
from langchain.chains import RetrievalQA
from dotenv import load_dotenv
from src.prompt import *
import os

#flask object initial
app= Flask(__name__)

PINECONE_API_KEY= os.environ.get('PINECONE_API_KEY')
PINECONE_API_ENV= os.environ.get('PINECONE_API_ENV')

embeddings= download_hugging_face_embeddings()

pinecone.init(api_key= PINECONE_API_KEY,
environment= PINECONE_API_ENV)

index_name= ""

docsearch= Pinecone.from_existing_index(index_name, embeddings)

PROMPT= PromptTemplate(template=prompt_template, input_variables=["context", "question"] )
chain_type_kwargs= {"prompt": PROMPT}

llm= CTransformers(model="model/llama-2-7b-chat.ggmlv3.q4_0.bin",
model_type="llama",
config={'max_new_tokens': 512,
'temperature': 0.8})

qa= RetrievalQA.from_chain_type(
llm= llm,
chain_type= "stuff",
retriever=docsearch.as_retriever(search_kwargs={'k':2}),
return_source_documents= True,
chain_type_kwargs= chain_type_kwargs
)


@app.route("/")
def index():
return render_template('chat.html')

@app.route("/get", methods=["GET", "POST"])
def chat():
msg= request.form["msg"]
input= msg
print(input)
result= qa({"query": input})
print=("Response", result["result"])
return str(result["result"])

if __name__=="__main__":
app.run(debug= True)
Binary file added data/Django.pdf
Binary file not shown.
12 changes: 12 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM python:3.8-slim-buster


RUN apt update -y && apt install awscli -y

WORKDIR /app

COPY . /app

RUN pip install -r requirement.txt

CMD ["python3","app.py"]
5 changes: 5 additions & 0 deletions model/instruction.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Download the Model

llama-2-7b-chat.ggmlv3.q4_0.bin

## From Hugging Face
9 changes: 9 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ctransformers==0.2.5
sentence-transformers==2.2.2
pinecone-client
langchain
flask
pypdf
pinecone-client
python-dotenv
-e .
Loading

0 comments on commit 40f9dfd

Please sign in to comment.