Spaces:
Sleeping
Sleeping
import os | |
import gradio as gr | |
from rag import generate_answer | |
def chat_with_bot(query: str) -> tuple: | |
""" | |
Chat with the bot using the provided query. | |
""" | |
try: | |
response = generate_answer(query) # Ensure this function is working correctly | |
except Exception as e: | |
print(f"Error in generate_answer: {str(e)}") # More specific error handling | |
return "Error generating answer", None # Return a default response on error | |
return response | |
def main(): | |
""" | |
Main function to create and launch the Gradio interface. | |
""" | |
try: | |
interface = gr.Interface( | |
fn=chat_with_bot, | |
inputs="text", | |
outputs="text", | |
title="RAG-LLM based Medical Chatbot", | |
description="Ask your medical questions and get answers from the chatbot." | |
) | |
interface.launch(share=True) | |
except Exception as e: | |
print(f"An error occurred while launching the interface: {str(e)}") # More context on errors | |
if __name__ == "__main__": | |
main() |