Mistral-Chatbot / app.py
diego2317
I can't figure out this errror I'm gonna crash out
dc77a16
raw
history blame contribute delete
985 Bytes
import pickle
import gradio as gr
from chatbot import answer_query_with_context
from file_utils import load_service_data, load_pickle
database_filepath = 'services-links.csv'
embeddings_filepath = 'document_embeddings.pkl'
database = load_service_data(database_filepath)
database_embeddings = load_pickle(embeddings_filepath)
def chatbot(input):
try:
if input:
reply = answer_query_with_context(input, database, database_embeddings)
return reply
except Exception as e:
return str(e)
# Create a Gradio interface
inputs = gr.Textbox(lines=7, label="Chat with AI")
outputs = gr.Textbox(label="Reply")
header_message = "Ask anything about the following services: "+", ".join(database.index)
iface = gr.Interface(fn=chatbot,
inputs=inputs,
outputs=outputs,
title="AI Chatbot",
description=header_message)
if __name__ == "__main__":
iface.launch()