Spaces:
Sleeping
Sleeping
File size: 985 Bytes
3db9763 4bd59e5 3db9763 4bd59e5 3db9763 4bd59e5 3db9763 dc77a16 3db9763 | 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 | 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() |