Spaces:
Running
Running
update
Browse files
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 |
-
#
|
| 823 |
-
|
| 824 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|