cmulgy commited on
Commit
61f8b5c
Β·
1 Parent(s): bcd9cc2
Files changed (1) hide show
  1. demo.py +50 -6
demo.py CHANGED
@@ -756,7 +756,9 @@ def get_routed_llm(query: str, config_path: str = None) -> Tuple[str, str, str]:
756
  selection_info = f"""
757
  πŸ”„ **Fallback Mode**: Graph router not available
758
  πŸ€– **Selected LLM**: llama-3.1-8b-instruct (Default)
 
759
  πŸ“ **Task Description**: General query processing
 
760
  ⚠️ **Note**: Using fallback system due to missing graph router components
761
  """
762
  return "llama-3.1-8b-instruct", "General query processing", selection_info
@@ -819,17 +821,57 @@ def get_routed_llm(query: str, config_path: str = None) -> Tuple[str, str, str]:
819
  routed_llm_name = router.test_GNN()
820
  print(f"Graph router selected: {routed_llm_name}")
821
 
822
- # Create detailed selection info
823
- api_model = map_llm_to_api(routed_llm_name)
824
- selection_info = f"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
825
  🎯 **Graph Router Analysis Complete**
826
 
827
  πŸ€– **Selected LLM**: {routed_llm_name}
 
828
  πŸ“ **Task Description**: {user_task_description}
829
  βœ… **Routing Method**: Advanced Graph Neural Network
830
  πŸ“Š **Analysis**: Query analyzed for optimal model selection
831
  ⚑ **Performance**: Cost-performance optimized routing
832
- """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
833
 
834
  return routed_llm_name, user_task_description, selection_info
835
 
@@ -843,8 +885,9 @@ def get_routed_llm(query: str, config_path: str = None) -> Tuple[str, str, str]:
843
  ❌ **Configuration Error**: {str(e)}
844
  πŸ”„ **Fallback**: Using default LLM
845
  πŸ€– **Selected LLM**: llama-3.1-8b-instruct (Default)
846
- πŸ“ **Task Description**: General query processing
847
  πŸ”— **API Model**: meta/llama-3.1-8b-instruct
 
 
848
  """
849
  return "llama-3.1-8b-instruct", "General query processing", selection_info
850
 
@@ -854,8 +897,9 @@ def get_routed_llm(query: str, config_path: str = None) -> Tuple[str, str, str]:
854
  ❌ **Graph Router Error**: {str(e)}
855
  πŸ”„ **Fallback**: Using default LLM
856
  πŸ€– **Selected LLM**: llama-3.1-8b-instruct (Default)
857
- πŸ“ **Task Description**: General query processing
858
  πŸ”— **API Model**: meta/llama-3.1-8b-instruct
 
 
859
  ⚠️ **Note**: Advanced routing failed, using fallback system
860
  """
861
  return "llama-3.1-8b-instruct", "General query processing", selection_info
 
756
  selection_info = f"""
757
  πŸ”„ **Fallback Mode**: Graph router not available
758
  πŸ€– **Selected LLM**: llama-3.1-8b-instruct (Default)
759
+ πŸ”— **API Model**: meta/llama-3.1-8b-instruct
760
  πŸ“ **Task Description**: General query processing
761
+ πŸ“‹ **LLM Details**: Meta's 8B Llama-3 series for chat & reasoning; $0.20/M input and $0.20/M output
762
  ⚠️ **Note**: Using fallback system due to missing graph router components
763
  """
764
  return "llama-3.1-8b-instruct", "General query processing", selection_info
 
821
  routed_llm_name = router.test_GNN()
822
  print(f"Graph router selected: {routed_llm_name}")
823
 
824
+ # Load LLM descriptions to get detailed information
825
+ try:
826
+ with open(config['llm_description_path'], 'r', encoding='utf-8') as f:
827
+ llm_descriptions = json.load(f)
828
+
829
+ # Get LLM details
830
+ llm_info = llm_descriptions.get(routed_llm_name, {})
831
+ llm_feature = llm_info.get('feature', 'No description available')
832
+ input_price = llm_info.get('input_price', 'Unknown')
833
+ output_price = llm_info.get('output_price', 'Unknown')
834
+
835
+ # Determine if it's a think mode model
836
+ think_mode = routed_llm_name.endswith('_think')
837
+ base_model_name = routed_llm_name[:-6] if think_mode else routed_llm_name
838
+
839
+ # Create detailed selection info with enhanced LLM information
840
+ api_model = map_llm_to_api(routed_llm_name)
841
+ selection_info = f"""
842
  🎯 **Graph Router Analysis Complete**
843
 
844
  πŸ€– **Selected LLM**: {routed_llm_name}
845
+ πŸ”— **API Model**: {api_model}
846
  πŸ“ **Task Description**: {user_task_description}
847
  βœ… **Routing Method**: Advanced Graph Neural Network
848
  πŸ“Š **Analysis**: Query analyzed for optimal model selection
849
  ⚑ **Performance**: Cost-performance optimized routing
850
+
851
+ **πŸ“‹ LLM Details:**
852
+ β€’ **Model**: {base_model_name}
853
+ β€’ **Mode**: {'Think Mode (Step-by-step reasoning)' if think_mode else 'Standard Mode'}
854
+ β€’ **Features**: {llm_feature}
855
+ β€’ **Pricing**: ${input_price}/M input tokens, ${output_price}/M output tokens
856
+ β€’ **Provider**: {api_model.split('/')[0] if '/' in api_model else 'Unknown'}
857
+
858
+ **🎯 Selection Rationale:**
859
+ The Graph Neural Network analyzed your query and determined this model provides the best balance of performance, cost, and capability for your specific task type.
860
+ """
861
+ except Exception as e:
862
+ print(f"Warning: Could not load LLM descriptions: {e}")
863
+ # Fallback to basic information
864
+ api_model = map_llm_to_api(routed_llm_name)
865
+ selection_info = f"""
866
+ 🎯 **Graph Router Analysis Complete**
867
+
868
+ πŸ€– **Selected LLM**: {routed_llm_name}
869
+ πŸ”— **API Model**: {api_model}
870
+ πŸ“ **Task Description**: {user_task_description}
871
+ βœ… **Routing Method**: Advanced Graph Neural Network
872
+ πŸ“Š **Analysis**: Query analyzed for optimal model selection
873
+ ⚑ **Performance**: Cost-performance optimized routing
874
+ """
875
 
876
  return routed_llm_name, user_task_description, selection_info
877
 
 
885
  ❌ **Configuration Error**: {str(e)}
886
  πŸ”„ **Fallback**: Using default LLM
887
  πŸ€– **Selected LLM**: llama-3.1-8b-instruct (Default)
 
888
  πŸ”— **API Model**: meta/llama-3.1-8b-instruct
889
+ πŸ“ **Task Description**: General query processing
890
+ πŸ“‹ **LLM Details**: Meta's 8B Llama-3 series for chat & reasoning; $0.20/M input and $0.20/M output
891
  """
892
  return "llama-3.1-8b-instruct", "General query processing", selection_info
893
 
 
897
  ❌ **Graph Router Error**: {str(e)}
898
  πŸ”„ **Fallback**: Using default LLM
899
  πŸ€– **Selected LLM**: llama-3.1-8b-instruct (Default)
 
900
  πŸ”— **API Model**: meta/llama-3.1-8b-instruct
901
+ πŸ“ **Task Description**: General query processing
902
+ πŸ“‹ **LLM Details**: Meta's 8B Llama-3 series for chat & reasoning; $0.20/M input and $0.20/M output
903
  ⚠️ **Note**: Advanced routing failed, using fallback system
904
  """
905
  return "llama-3.1-8b-instruct", "General query processing", selection_info