Nyha15 commited on
Commit
d55aceb
·
1 Parent(s): 7fcac4d

Refactored

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -348,6 +348,9 @@ class SpecialistAgent:
348
  # Get country-specific knowledge using RAG
349
  knowledge = self.knowledge_base.retrieve(query, country)
350
 
 
 
 
351
  # Prepare a detailed prompt with the knowledge and query
352
  prompt = f"""
353
  As a specialist {self.name} for international students, provide detailed, specific financial advice for a student from {country}.
@@ -356,7 +359,7 @@ class SpecialistAgent:
356
  {query}
357
 
358
  RELEVANT KNOWLEDGE FROM RAG:
359
- {"\n".join('- ' + item for item in knowledge)}
360
 
361
  Provide extremely detailed, actionable advice addressing the query with these requirements:
362
  1. Include specific bank/service/product names with exact fees or rates where applicable
@@ -508,13 +511,16 @@ class CoordinatorAgent:
508
  voting_results = {option: 0 for option in options}
509
  specialist_votes = {}
510
 
 
 
 
511
  voting_prompt = f"""
512
  As a financial advisor for international students from {country}, which of the following options would you recommend?
513
 
514
  QUESTION: {question}
515
 
516
  OPTIONS:
517
- {"\n".join([f"{i+1}. {option}" for i, option in enumerate(options)])}
518
 
519
  Analyze the options carefully, then respond with ONLY the number of your recommendation (e.g., "1" or "2").
520
  """
@@ -680,6 +686,9 @@ class CoordinatorAgent:
680
  # 4. Synthesize the collected advice and plans into a coherent response
681
  log_workflow("Synthesizing comprehensive response")
682
 
 
 
 
683
  synthesis_prompt = f"""
684
  As the coordinator for an International Student Finance Portal, synthesize specialist advice and financial plans into a comprehensive response.
685
 
@@ -694,7 +703,7 @@ class CoordinatorAgent:
694
  {query}
695
 
696
  SPECIALIST ADVICE:
697
- {"\n".join([f"--- {domain.upper()} SPECIALIST ---\n{advice[:1000]}\n" for domain, advice in specialist_advice.items()])}
698
 
699
  FINANCIAL APPROACHES:
700
  --- CONSERVATIVE APPROACH ---
@@ -995,4 +1004,4 @@ if __name__ == "__main__":
995
  print("Starting International Student Finance Portal with Visible Workflow...")
996
  print("This implementation tests all components and shows the workflow in real-time.")
997
  interface = create_interface()
998
- interface.launch()
 
348
  # Get country-specific knowledge using RAG
349
  knowledge = self.knowledge_base.retrieve(query, country)
350
 
351
+ # Join the knowledge items with newlines
352
+ knowledge_text = "\n".join('- ' + item for item in knowledge)
353
+
354
  # Prepare a detailed prompt with the knowledge and query
355
  prompt = f"""
356
  As a specialist {self.name} for international students, provide detailed, specific financial advice for a student from {country}.
 
359
  {query}
360
 
361
  RELEVANT KNOWLEDGE FROM RAG:
362
+ {knowledge_text}
363
 
364
  Provide extremely detailed, actionable advice addressing the query with these requirements:
365
  1. Include specific bank/service/product names with exact fees or rates where applicable
 
511
  voting_results = {option: 0 for option in options}
512
  specialist_votes = {}
513
 
514
+ # Create options text separately
515
+ options_text = "\n".join([f"{i+1}. {option}" for i, option in enumerate(options)])
516
+
517
  voting_prompt = f"""
518
  As a financial advisor for international students from {country}, which of the following options would you recommend?
519
 
520
  QUESTION: {question}
521
 
522
  OPTIONS:
523
+ {options_text}
524
 
525
  Analyze the options carefully, then respond with ONLY the number of your recommendation (e.g., "1" or "2").
526
  """
 
686
  # 4. Synthesize the collected advice and plans into a coherent response
687
  log_workflow("Synthesizing comprehensive response")
688
 
689
+ # Create the specialist advice text separately
690
+ specialist_advice_text = "\n".join([f"--- {domain.upper()} SPECIALIST ---\n{advice[:1000]}\n" for domain, advice in specialist_advice.items()])
691
+
692
  synthesis_prompt = f"""
693
  As the coordinator for an International Student Finance Portal, synthesize specialist advice and financial plans into a comprehensive response.
694
 
 
703
  {query}
704
 
705
  SPECIALIST ADVICE:
706
+ {specialist_advice_text}
707
 
708
  FINANCIAL APPROACHES:
709
  --- CONSERVATIVE APPROACH ---
 
1004
  print("Starting International Student Finance Portal with Visible Workflow...")
1005
  print("This implementation tests all components and shows the workflow in real-time.")
1006
  interface = create_interface()
1007
+ interface.launch()