hogRAGger / app.py
parthmodi22's picture
Add application file
1b8b75e
import streamlit as st
import json
from hogragger import Hogragger
# Initialize the Hogragger class with your corpus path
hogragger = Hogragger(corpus_path='corpus.json') # Ensure corpus.json is in the correct path
# Streamlit app title
st.title("Hogragger Query Processor")
# Input text box for the query
query_input = st.text_area("Enter your query:", height=100)
# Button to process the query
if st.button("Process Query"):
if query_input:
st.write(f"Processing query: {query_input}")
# Step 3: Run the query through the pipeline
result = hogragger.process_query(query_input)
# Step 4: Format the result as JSON
result_dict = {
"query": query_input,
"answer": result['answer'],
"question_type": result['question_type'],
"evidence_list": [
{
"title": ev['title'],
"fact": ev['fact'],
"source": ev['source'],
"url": ev['url'],
"published_at": ev['published_at'],
"category": ev['category']
}
for ev in result['evidence_list'] # Optional: Limit if needed
]
}
# Convert the result to pretty JSON format
result_json = json.dumps(result_dict, indent=4)
# Display the JSON result on the web app
st.subheader("Result (JSON format):")
st.code(result_json, language='json')
else:
st.error("Please enter a query.")