Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from indexer import index_text, answer_query
|
| 3 |
+
|
| 4 |
+
# Gradio interface function to handle the RAG system
|
| 5 |
+
def rag_system(input_text, query):
|
| 6 |
+
# Index the input text
|
| 7 |
+
vectorstore = index_text(input_text)
|
| 8 |
+
|
| 9 |
+
# Answer the query based on the indexed text
|
| 10 |
+
answer = answer_query(query, vectorstore)
|
| 11 |
+
|
| 12 |
+
return answer
|
| 13 |
+
|
| 14 |
+
# Build the Gradio interface
|
| 15 |
+
iface = gr.Interface(
|
| 16 |
+
fn=rag_system,
|
| 17 |
+
inputs=["text", "text"],
|
| 18 |
+
outputs="text",
|
| 19 |
+
title="RAG QA System",
|
| 20 |
+
description="Enter a text and ask questions based on the input text."
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
# Launch the app
|
| 24 |
+
iface.launch()
|