Spaces:
Build error
Build error
| 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() |