danulr05 commited on
Commit
cb96026
·
verified ·
1 Parent(s): 7b576cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -635,7 +635,8 @@ def get_available_pdfs() -> List[str]:
635
  '20250825_Budget2026Proposal_RemovalOfTaxationOnEPF_Tam_F.pdf'
636
  ]
637
 
638
- def extract_sources_from_search_context(search_context: str, user_language: str = 'en') -> List[Dict[str, str]]:
 
639
  """Extract source documents from search context with short names, filtered by user language"""
640
  sources = []
641
 
@@ -744,7 +745,8 @@ def get_correct_pdf_url(filename: str) -> str:
744
  # English documents
745
  return f"assets/pdfs/{filename}"
746
 
747
- def extract_sources_from_response(response: str) -> List[Dict[str, str]]:
 
748
  """Extract source documents mentioned in the response with short names (fallback method)"""
749
  sources = []
750
 
@@ -863,8 +865,7 @@ Please provide a helpful response:"""
863
 
864
  # No need to translate response - Gemini handles language matching automatically
865
 
866
- # Extract sources from search context (where the actual filenames are)
867
- sources = extract_sources_from_search_context(search_context, original_language)
868
 
869
  # Add messages to memory (store original user message for context)
870
  memory.chat_memory.add_user_message(user_message)
@@ -880,7 +881,7 @@ Please provide a helpful response:"""
880
  "conversation_length": len(chat_history),
881
  "memory_used": True,
882
  "rag_used": True,
883
- "sources": sources,
884
  "language_detected": original_language,
885
  "translation_used": needs_translation,
886
  "transliteration_used": transliteration_used,
@@ -942,7 +943,7 @@ def chat():
942
  "conversation_length": result.get("conversation_length", 0),
943
  "memory_used": result.get("memory_used", False),
944
  "rag_used": result.get("rag_used", False),
945
- "sources": result.get("sources", []),
946
  "user_message": user_message,
947
  "language_detected": result.get("language_detected", "en"),
948
  "translation_used": result.get("translation_used", False),
@@ -1900,7 +1901,8 @@ def get_available_pdfs() -> List[str]:
1900
  '20250825_Budget2026Proposal_RemovalOfTaxationOnEPF_Tam_F.pdf'
1901
  ]
1902
 
1903
- def extract_sources_from_search_context(search_context: str, user_language: str = 'en') -> List[Dict[str, str]]:
 
1904
  """Extract source documents from search context with short names, filtered by user language"""
1905
  sources = []
1906
 
@@ -2009,7 +2011,8 @@ def get_correct_pdf_url(filename: str) -> str:
2009
  # English documents
2010
  return f"assets/pdfs/{filename}"
2011
 
2012
- def extract_sources_from_response(response: str) -> List[Dict[str, str]]:
 
2013
  """Extract source documents mentioned in the response with short names (fallback method)"""
2014
  sources = []
2015
 
@@ -2128,8 +2131,7 @@ Please provide a helpful response:"""
2128
 
2129
  # No need to translate response - Gemini handles language matching automatically
2130
 
2131
- # Extract sources from search context (where the actual filenames are)
2132
- sources = extract_sources_from_search_context(search_context, original_language)
2133
 
2134
  # Add messages to memory (store original user message for context)
2135
  memory.chat_memory.add_user_message(user_message)
@@ -2145,7 +2147,7 @@ Please provide a helpful response:"""
2145
  "conversation_length": len(chat_history),
2146
  "memory_used": True,
2147
  "rag_used": True,
2148
- "sources": sources,
2149
  "language_detected": original_language,
2150
  "translation_used": needs_translation,
2151
  "transliteration_used": transliteration_used,
@@ -2207,7 +2209,7 @@ def chat():
2207
  "conversation_length": result.get("conversation_length", 0),
2208
  "memory_used": result.get("memory_used", False),
2209
  "rag_used": result.get("rag_used", False),
2210
- "sources": result.get("sources", []),
2211
  "user_message": user_message,
2212
  "language_detected": result.get("language_detected", "en"),
2213
  "translation_used": result.get("translation_used", False),
 
635
  '20250825_Budget2026Proposal_RemovalOfTaxationOnEPF_Tam_F.pdf'
636
  ]
637
 
638
+ # DISABLED - Source extraction removed
639
+ def extract_sources_from_search_context_DISABLED(search_context: str, user_language: str = 'en') -> List[Dict[str, str]]:
640
  """Extract source documents from search context with short names, filtered by user language"""
641
  sources = []
642
 
 
745
  # English documents
746
  return f"assets/pdfs/{filename}"
747
 
748
+ # DISABLED - Source extraction removed
749
+ def extract_sources_from_response_DISABLED(response: str) -> List[Dict[str, str]]:
750
  """Extract source documents mentioned in the response with short names (fallback method)"""
751
  sources = []
752
 
 
865
 
866
  # No need to translate response - Gemini handles language matching automatically
867
 
868
+ # Sources removed - no longer extracting source documents
 
869
 
870
  # Add messages to memory (store original user message for context)
871
  memory.chat_memory.add_user_message(user_message)
 
881
  "conversation_length": len(chat_history),
882
  "memory_used": True,
883
  "rag_used": True,
884
+ "sources": [],
885
  "language_detected": original_language,
886
  "translation_used": needs_translation,
887
  "transliteration_used": transliteration_used,
 
943
  "conversation_length": result.get("conversation_length", 0),
944
  "memory_used": result.get("memory_used", False),
945
  "rag_used": result.get("rag_used", False),
946
+ "sources": [],
947
  "user_message": user_message,
948
  "language_detected": result.get("language_detected", "en"),
949
  "translation_used": result.get("translation_used", False),
 
1901
  '20250825_Budget2026Proposal_RemovalOfTaxationOnEPF_Tam_F.pdf'
1902
  ]
1903
 
1904
+ # DISABLED - Source extraction removed
1905
+ def extract_sources_from_search_context_DISABLED(search_context: str, user_language: str = 'en') -> List[Dict[str, str]]:
1906
  """Extract source documents from search context with short names, filtered by user language"""
1907
  sources = []
1908
 
 
2011
  # English documents
2012
  return f"assets/pdfs/{filename}"
2013
 
2014
+ # DISABLED - Source extraction removed
2015
+ def extract_sources_from_response_DISABLED(response: str) -> List[Dict[str, str]]:
2016
  """Extract source documents mentioned in the response with short names (fallback method)"""
2017
  sources = []
2018
 
 
2131
 
2132
  # No need to translate response - Gemini handles language matching automatically
2133
 
2134
+ # Sources removed - no longer extracting source documents
 
2135
 
2136
  # Add messages to memory (store original user message for context)
2137
  memory.chat_memory.add_user_message(user_message)
 
2147
  "conversation_length": len(chat_history),
2148
  "memory_used": True,
2149
  "rag_used": True,
2150
+ "sources": [],
2151
  "language_detected": original_language,
2152
  "translation_used": needs_translation,
2153
  "transliteration_used": transliteration_used,
 
2209
  "conversation_length": result.get("conversation_length", 0),
2210
  "memory_used": result.get("memory_used", False),
2211
  "rag_used": result.get("rag_used", False),
2212
+ "sources": [],
2213
  "user_message": user_message,
2214
  "language_detected": result.get("language_detected", "en"),
2215
  "translation_used": result.get("translation_used", False),