| import streamlit as st | |
| import utils | |
| # https://github.com/serkanyasr/RAG-with-LangChain-URL-PDF/blob/main/utils.py | |
| st.set_page_config(layout="centered") | |
| st.markdown("<h1 style='font-size:24px;'>RAG with LangChain & GenAI: Any url</h1>", unsafe_allow_html=True) | |
| # st.title("RAG with LangChain & GenAI: Any url") | |
| # URL text box for user input | |
| url_input = st.text_input("Enter a URL to be queried:", "") | |
| # Input text box for user input | |
| user_input = st.text_input("Enter your Question below:", "") | |
| # Display the user input | |
| # st.write("You entered:", user_input) | |
| # st.write("URL entered:", url_input) | |
| sumbit_btn = st.button(label="Submit",key="url_btn") | |
| if sumbit_btn: | |
| with st.spinner("Processing..."): | |
| st.success("Response: Answering with RAG...") | |
| response = utils.rag_with_url(url_input,user_input) | |
| st.markdown(response) | |
| # st.title("Retrieval-Augmented Generation (RAG) with LangChain : PDF ") | |
| # st.divider() | |
| # col_input , col_rag , col_normal = st.columns([3,5,5]) | |
| # with col_input: | |
| # selected_file = st.file_uploader("PDF File", type=["pdf"]) | |
| # st.divider() | |
| # prompt = st.text_input("Prompt",key="pdf_prompt") | |
| # st.divider() | |
| # sumbit_btn = st.button(label="Submit",key="pdf_btn") | |
| # if sumbit_btn: | |
| # with col_rag: | |
| # with st.spinner("Processing..."): | |
| # st.success("Response: Answering with RAG...") | |
| # response,relevant_documents = utils.rag_with_pdf(file_path=f"./data/{selected_file.name}", | |
| # prompt=prompt) | |
| # st.markdown(response) | |
| # st.divider() | |
| # st.info("Documents") | |
| # for doc in relevant_documents: | |
| # st.caption(doc.page_content) | |
| # st.markdown(f"Source: {doc.metadata}") | |
| # st.divider() | |
| # with col_normal: | |
| # with st.spinner("Processing..."): | |
| # st.info("Response: Answering without RAG...") | |
| # response = utils.ask_gemini(prompt) | |
| # st.markdown(response) | |
| # st.divider() | |