Spaces:
Runtime error
Runtime error
Update app.py
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142import subprocessimport sysimport gradio as grfrom utils import initialize_databasefrom model import llm_chain_response, get_response_valuefrom process_documents import create_db_from_filesdef run_setup():subprocess.check_call([sys.executable, "setup.py"])# Run the setup scriptrun_setup()llm_chain = llm_chain_response()def chat_with_mistral(user_input):if not user_input:return "The message is not be empty."response = llm_chain.invoke({"query": user_input})print(response)print("---------------Response--------------")print(get_response_value(response["result"]))return get_response_value(response["result"])def main():# Initialize the databasecreate_db_from_files()# Set up and launch the Gradio interfaceiface = gr.Interface(fn=chat_with_mistral,inputs=gr.components.Textbox(label="Enter Your Message"),outputs=gr.components.Markdown(label="ChatbotResponse"),title="Resvu AI Chatbot",description="Interact with the Resvu API via this chatbot. Enter a message and get a response.",examples=["Hi, how are you", "Who are you?", "What services do you offer?", "How can I find out about upcoming community events?"],allow_flagging="never")iface.launch()if __name__ == "__main__":main()1234567891011121314151617181920212223242526272829303132333435363738394041import subprocessimport sysimport gradio as grfrom model import llm_chain_response, get_response_valuefrom process_documents import create_db_from_filesdef run_setup():subprocess.check_call([sys.executable, "setup.py"])# Run the setup scriptrun_setup()llm_chain = llm_chain_response()def chat_with_mistral(user_input):if not user_input:return "The message is not be empty."response = llm_chain.invoke({"query": user_input})print(response)print("---------------Response--------------")print(get_response_value(response["result"]))return get_response_value(response["result"])def main():# Initialize the databasecreate_db_from_files()# Set up and launch the Gradio interfaceiface = gr.Interface(fn=chat_with_mistral,inputs=gr.components.Textbox(label="Enter Your Message"),outputs=gr.components.Markdown(label="ChatbotResponse"),title="Resvu AI Chatbot",description="Interact with the Resvu API via this chatbot. Enter a message and get a response.",examples=["Hi, how are you", "Who are you?", "What services do you offer?", "How can I find out about upcoming community events?"],allow_flagging="never")iface.launch()if __name__ == "__main__":main()
app.py+40-41