File size: 817 Bytes
404c584
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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)