|
import streamlit as st |
|
from model import load_vectorstore, ask_question |
|
import os |
|
|
|
st.set_page_config(page_title="RAG with Mistral AI", layout="centered") |
|
|
|
st.title("RAG Q&A App with Mistral AI") |
|
st.write("Upload a document and ask questions about it.") |
|
|
|
uploaded_file = st.file_uploader("Upload PDF", type=["pdf"]) |
|
|
|
if uploaded_file: |
|
with open("document.pdf", "wb") as f: |
|
f.write(uploaded_file.read()) |
|
st.success("File uploaded!") |
|
|
|
if st.button("Index Document"): |
|
with st.spinner("Processing..."): |
|
load_vectorstore("document.pdf") |
|
st.success("Vectorstore ready.") |
|
|
|
query = st.text_input("Enter your question") |
|
if st.button("Ask") and query: |
|
with st.spinner("Generating answer..."): |
|
answer = ask_question(query) |
|
st.write("**Answer:**", answer) |
|
|
|
|