File size: 908 Bytes
8c3a73e
 
 
c29b3b9
 
 
 
8c3a73e
 
c29b3b9
 
 
 
 
 
 
 
8c3a73e
 
 
 
 
 
 
 
 
 
c29b3b9
 
 
 
 
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
# File: app.py
import gradio as gr
from retrieval import rag_query
import logging

# Set up logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

def gradio_interface(query: str) -> str:
    try:
        logging.info(f"Received query: {query}")
        result = rag_query(query)
        logging.info("Query processed successfully")
        return result
    except Exception as e:
        logging.error(f"Error processing query: {str(e)}")
        return f"An error occurred: {str(e)}"

iface = gr.Interface(
    fn=gradio_interface,
    inputs="text",
    outputs="text",
    title="arXiv RAG System",
    description="Ask questions about arXiv papers"
)

if __name__ == "__main__":
    try:
        logging.info("Starting Gradio interface")
        iface.launch()
    except Exception as e:
        logging.error(f"Failed to start Gradio interface: {str(e)}")