File size: 1,066 Bytes
22ab087
 
2c6d53a
22ab087
93b947c
22ab087
93b947c
22ab087
 
93b947c
22ab087
 
93b947c
22ab087
93b947c
22ab087
 
 
93b947c
22ab087
 
 
 
93b947c
 
22ab087
 
 
 
 
 
 
 
 
93b947c
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
33
34
35
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()