File size: 991 Bytes
eccde2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import gradio as gr
from models import EmbeddingModel, LLM
from utils import MistralPrompts
from vector_store import FaissVectorStore
from chat import ChatBot

VECTOR_DATABASE_PATH = 'vector_db'
# Initialize models and vector store
embedding_model = EmbeddingModel(model_name='sentence-transformers/all-MiniLM-L6-v2')
llm = LLM("mistralai/Mistral-7B-Instruct-v0.1")
vector_store = FaissVectorStore.as_retriever(database_path=VECTOR_DATABASE_PATH)

# Create a ChatBot instance
chat_bot = ChatBot(llm, embedding_model, vector_store)

# Function to handle the user's input and generate a response
def chat_bot(input_text):
    response = chat_bot.chat(input_text)

    return response

# Create a Gradio interface
chatbot_interface = gr.Interface(
    fn=chat_bot,
    inputs=gr.inputs.Textbox(prompt="User:"),
    outputs=gr.inputs.Textbox(prompt="Bot:"),
    title="Chatbot Assitant for PAN card related query",
    theme="compact"
)

# Launch the Gradio interface
chatbot_interface.launch()