Spaces:
Sleeping
Sleeping
File size: 1,017 Bytes
22a77e1 5779d70 1f47ab4 22a77e1 8678597 5779d70 cef0fe4 90338f1 dba827a b2d9845 c170403 b2d9845 5779d70 b2d9845 c170403 30205bf 0156967 b2d9845 c170403 fbca0e5 93d54ea c170403 |
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 |
import pickle
import gradio as gr
from utils.chatbot import answer_query_with_context
from utils.file_utils import load_database, load_embeddings, load_file
database_filepath = 'data/services.csv'
embeddings_filepath = 'data/document_embeddings.pkl'
database = load_database(database_filepath)
database_embeddings = load_embeddings(database, database_filepath, 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 = load_file('prompts/chabot_header_message.txt')
iface = gr.Interface(fn=chatbot,
inputs=inputs,
outputs=outputs,
title="AI Chatbot",
description=header_message)
if __name__ == "__main__":
iface.launch() |