File size: 2,164 Bytes
a48fb15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5103377
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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()