danulr05 commited on
Commit
5d078cb
·
verified ·
1 Parent(s): 5c778c3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -3
app.py CHANGED
@@ -394,8 +394,8 @@ def get_short_document_name(filename: str) -> str:
394
  short_names = {
395
  '20241211_Econ_VRProposals_Budget2025_OnePagers': 'Budget 2025 One-Pagers',
396
  '20250813_Budget2026_Proposal_ExpandingIndustrialLand_En_F': 'Industrial Land Expansion (EN)',
397
- '20250813_Budget2026Proposal_MaternityLeaveBenefit_Raj_D01': 'Maternity Leave Benefits ',
398
- '20250813_Budget2026Proposal_RemovalOfTaxationOnEPF_Raj_F': 'EPF Tax Removal',
399
  '20250825_Budget2026Proposal_MaternityLeaveBenefit_Sin_F': 'Maternity Leave Benefits (Sinhala)',
400
  '20250825_Budget2026Proposal_MaternityLeaveBenefit_Tam_F': 'Maternity Leave Benefits (Tamil)',
401
  '20250825_Budget2026Proposal_RemovalOfTaxationOnEPF_Sin_Final': 'EPF Tax Removal (Sinhala)',
@@ -859,16 +859,20 @@ def get_available_pdfs_endpoint():
859
 
860
  # Create list with both full names and short names
861
  pdf_list = []
 
862
  for pdf in available_pdfs:
 
863
  pdf_list.append({
864
  "filename": pdf,
865
- "short_name": get_short_document_name(pdf),
866
  "type": "PDF" if pdf.endswith('.pdf') else "DOCX"
867
  })
 
868
 
869
  return jsonify({
870
  "available_pdfs": available_pdfs,
871
  "pdf_list": pdf_list,
 
872
  "count": len(available_pdfs),
873
  "pdf_directory": "Budget_Proposals copy-2/assets/pdfs"
874
  })
@@ -895,6 +899,25 @@ def get_document_names():
895
  logger.error(f"Error getting document names: {e}")
896
  return jsonify({"error": str(e)}), 500
897
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
898
  @app.route('/api/chat/detect-language', methods=['POST'])
899
  def detect_language():
900
  """Test language detection functionality"""
@@ -943,6 +966,7 @@ def home():
943
  "GET /api/chat/suggestions": "Get suggested questions (multilingual)",
944
  "GET /api/chat/available-pdfs": "Get available PDF files with short names",
945
  "GET /api/chat/document-names": "Get document name mapping (full to short names)",
 
946
  "POST /api/chat/detect-language": "Test language detection"
947
  },
948
  "status": "running"
 
394
  short_names = {
395
  '20241211_Econ_VRProposals_Budget2025_OnePagers': 'Budget 2025 One-Pagers',
396
  '20250813_Budget2026_Proposal_ExpandingIndustrialLand_En_F': 'Industrial Land Expansion (EN)',
397
+ '20250813_Budget2026Proposal_MaternityLeaveBenefit_Raj_D01': 'Maternity Leave Benefits (Raj)',
398
+ '20250813_Budget2026Proposal_RemovalOfTaxationOnEPF_Raj_F': 'EPF Tax Removal (Raj)',
399
  '20250825_Budget2026Proposal_MaternityLeaveBenefit_Sin_F': 'Maternity Leave Benefits (Sinhala)',
400
  '20250825_Budget2026Proposal_MaternityLeaveBenefit_Tam_F': 'Maternity Leave Benefits (Tamil)',
401
  '20250825_Budget2026Proposal_RemovalOfTaxationOnEPF_Sin_Final': 'EPF Tax Removal (Sinhala)',
 
859
 
860
  # Create list with both full names and short names
861
  pdf_list = []
862
+ short_names = []
863
  for pdf in available_pdfs:
864
+ short_name = get_short_document_name(pdf)
865
  pdf_list.append({
866
  "filename": pdf,
867
+ "short_name": short_name,
868
  "type": "PDF" if pdf.endswith('.pdf') else "DOCX"
869
  })
870
+ short_names.append(short_name)
871
 
872
  return jsonify({
873
  "available_pdfs": available_pdfs,
874
  "pdf_list": pdf_list,
875
+ "short_names": short_names, # Simple array for easy frontend use
876
  "count": len(available_pdfs),
877
  "pdf_directory": "Budget_Proposals copy-2/assets/pdfs"
878
  })
 
899
  logger.error(f"Error getting document names: {e}")
900
  return jsonify({"error": str(e)}), 500
901
 
902
+ @app.route('/api/chat/short-document-names', methods=['GET'])
903
+ def get_short_document_names():
904
+ """Get just the short document names as a simple array for frontend display"""
905
+ try:
906
+ available_pdfs = get_available_pdfs()
907
+
908
+ # Create simple array of short names
909
+ short_names = []
910
+ for pdf in available_pdfs:
911
+ short_names.append(get_short_document_name(pdf))
912
+
913
+ return jsonify({
914
+ "short_names": short_names,
915
+ "count": len(short_names)
916
+ })
917
+ except Exception as e:
918
+ logger.error(f"Error getting short document names: {e}")
919
+ return jsonify({"error": str(e)}), 500
920
+
921
  @app.route('/api/chat/detect-language', methods=['POST'])
922
  def detect_language():
923
  """Test language detection functionality"""
 
966
  "GET /api/chat/suggestions": "Get suggested questions (multilingual)",
967
  "GET /api/chat/available-pdfs": "Get available PDF files with short names",
968
  "GET /api/chat/document-names": "Get document name mapping (full to short names)",
969
+ "GET /api/chat/short-document-names": "Get simple array of short document names",
970
  "POST /api/chat/detect-language": "Test language detection"
971
  },
972
  "status": "running"