Sayandip commited on
Commit
4f2d9ec
·
verified ·
1 Parent(s): ace4758

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -2
app.py CHANGED
@@ -75,7 +75,7 @@ def load_and_extract_text(file_path):
75
 
76
  elif ext == 'py':
77
  with open(file_path, 'r', encoding='utf-8') as f:
78
- return f.read()
79
 
80
  elif ext == 'ipynb':
81
  with open(file_path, 'r', encoding='utf-8') as f:
@@ -146,9 +146,11 @@ if uploaded_file and question:
146
  else:
147
  with st.spinner("Processing document..."):
148
  try:
 
 
149
  prompt = f"Context: {extracted_text}\n\nQuestion: {question}\n\nAnswer:"
150
  response = model.generate_content(prompt)
151
  st.success("💡 Answer:")
152
  st.write(response.text)
153
  except Exception as e:
154
- st.error(f"Error generating answer: {e}")
 
75
 
76
  elif ext == 'py':
77
  with open(file_path, 'r', encoding='utf-8') as f:
78
+ return f.read() # We just read the Python code content
79
 
80
  elif ext == 'ipynb':
81
  with open(file_path, 'r', encoding='utf-8') as f:
 
146
  else:
147
  with st.spinner("Processing document..."):
148
  try:
149
+ # Hide the extracted content
150
+ st.write("Processing your query based on the uploaded content...")
151
  prompt = f"Context: {extracted_text}\n\nQuestion: {question}\n\nAnswer:"
152
  response = model.generate_content(prompt)
153
  st.success("💡 Answer:")
154
  st.write(response.text)
155
  except Exception as e:
156
+ st.error(f"Error generating answer: {e}")