NHZ commited on
Commit
91c2e41
·
verified ·
1 Parent(s): aa9ff60

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -42
app.py CHANGED
@@ -70,46 +70,5 @@ def create_vector_store(text):
70
  st.title("RAG-based Application with Focused Context")
71
 
72
  # Predefined Google Drive link
73
- drive_url = "https://drive.google.com/file/d/1XvqA1OIssRs2gbmOtKFKj-02yQ5X2yg0/view?usp=sharing"
74
 
75
- # Extract document content
76
- st.write("Extracting content from the document...")
77
- text = extract_pdf_content(drive_url)
78
- if text:
79
- st.write("Document extracted successfully!")
80
-
81
- st.write("Creating vector store...")
82
- vector_store, sentences = create_vector_store(text)
83
-
84
- st.write("Vector store created successfully!")
85
-
86
- query = st.text_input("Enter your query:")
87
- if query:
88
- st.write("Retrieving relevant context from the document...")
89
- retriever = vector_store.as_retriever()
90
- retriever.search_kwargs["k"] = 3 # Retrieve top 3 matches
91
-
92
- # Define a prompt template to guide LLM response generation
93
- prompt_template = PromptTemplate(
94
- template="""
95
- Use the following context to answer the question:
96
-
97
- {context}
98
-
99
- Question: {question}
100
- Answer:""",
101
- input_variables=["context", "question"]
102
- )
103
-
104
- # Create a RetrievalQA chain
105
- qa_chain = RetrievalQA(
106
- retriever=retriever,
107
- llm=llm,
108
- prompt=prompt_template
109
- )
110
-
111
- # Run the query through the QA chain
112
- result = qa_chain.run(query)
113
- st.write("Answer:", result)
114
- else:
115
- st.error("Failed to extract content from the document.")
 
70
  st.title("RAG-based Application with Focused Context")
71
 
72
  # Predefined Google Drive link
73
+ drive_url = "h
74