K Mohith Goud commited on
Commit
91c92b8
·
1 Parent(s): 4ac7877

Updated the demo Function

Browse files
Components/__pycache__/para_agent.cpython-312.pyc CHANGED
Binary files a/Components/__pycache__/para_agent.cpython-312.pyc and b/Components/__pycache__/para_agent.cpython-312.pyc differ
 
Components/__pycache__/para_utility.cpython-312.pyc CHANGED
Binary files a/Components/__pycache__/para_utility.cpython-312.pyc and b/Components/__pycache__/para_utility.cpython-312.pyc differ
 
Components/para_agent.py CHANGED
@@ -121,7 +121,9 @@ def demo_file_load():
121
 
122
  retriever = db.as_retriever(similarity_score_threshold=0.8)
123
  print(retriever,"retrived document indemo")
124
-
 
 
125
  prompt_template = """
126
  CONTEXT: {context}
127
  QUESTION: {question}"""
 
121
 
122
  retriever = db.as_retriever(similarity_score_threshold=0.8)
123
  print(retriever,"retrived document indemo")
124
+ query1 = "What is LLM?"
125
+ results = retriever.get_relevant_documents(query1)
126
+ print(results)
127
  prompt_template = """
128
  CONTEXT: {context}
129
  QUESTION: {question}"""
app.py CHANGED
@@ -139,8 +139,8 @@ with st.form(key="my_form"):
139
  if submit_button and generate_questions_checkbox and (uploaded_file or use_demo):
140
  query = f"Generate 5 flashcard questions based Context: {query}"
141
  st.write(query)
142
- if agent:
143
- response, Source = agent.ask(query)
144
  add_query_response(query, response)
145
 
146
  # Uncheck the checkbox after processing
@@ -165,7 +165,7 @@ if submit_button and generate_questions_checkbox and (uploaded_file or use_demo
165
  st.write("No documents found.")
166
 
167
  # Modify the query processing section
168
- if submit_button and query and not uploaded_video_file: # Check if button is pressed
169
  if st.session_state.agent:
170
  response, Source = st.session_state.agent.ask(query)
171
  add_query_response(query, response)
@@ -218,25 +218,3 @@ else:
218
  # Add this after session state initialization
219
  if 'needs_cleanup' not in st.session_state:
220
  st.session_state.needs_cleanup = False
221
-
222
- def cleanup_temp_files():
223
- """Clean up temporary files when the session ends"""
224
- try:
225
- # Clean up the temporary video files
226
- temp_dir = tempfile.gettempdir()
227
- for filename in os.listdir(temp_dir):
228
- if filename.endswith(('.mp4', '.avi', '.mov', '.wav')):
229
- filepath = os.path.join(temp_dir, filename)
230
- os.remove(filepath)
231
-
232
- # Clean up any temporary audio files in current directory
233
- if os.path.exists("temp_audio.wav"):
234
- os.remove("temp_audio.wav")
235
-
236
- # Clean up dataset directory but keep user storage
237
- if os.path.exists("dataset"):
238
- shutil.rmtree("dataset")
239
-
240
- except Exception as e:
241
- st.error(f"Error during cleanup: {e}")
242
-
 
139
  if submit_button and generate_questions_checkbox and (uploaded_file or use_demo):
140
  query = f"Generate 5 flashcard questions based Context: {query}"
141
  st.write(query)
142
+ if st.session_state.agent:
143
+ response, Source = st.session_state.agent.ask(query)
144
  add_query_response(query, response)
145
 
146
  # Uncheck the checkbox after processing
 
165
  st.write("No documents found.")
166
 
167
  # Modify the query processing section
168
+ if submit_button and query and not uploaded_video_file and not generate_questions_checkbox: # Check if button is pressed
169
  if st.session_state.agent:
170
  response, Source = st.session_state.agent.ask(query)
171
  add_query_response(query, response)
 
218
  # Add this after session state initialization
219
  if 'needs_cleanup' not in st.session_state:
220
  st.session_state.needs_cleanup = False