MCPcopy Create free account
hub / github.com/THESIS-AGENT/AIRouter / function_calling

Method function_calling

LLMwrapper.py:779–981  ·  view source on GitHub ↗
(
        model_name,
        prompt,
        tools,
        timeout=30,
        mode="fast_first",
        input_proportion=60,
        output_proportion=40,
        max_tokens=None,
        test_response = None,
        remark = ""
    )

Source from the content-addressed store, hash-verified

777
778 @staticmethod
779 def function_calling(
780 model_name,
781 prompt,
782 tools,
783 timeout=30,
784 mode="fast_first",
785 input_proportion=60,
786 output_proportion=40,
787 max_tokens=None,
788 test_response = None,
789 remark = ""
790 ):
791 # Validate model is allowed for function calling
792 LLM_Wrapper._validate_model_for_function_calling(model_name)
793
794 if test_response is not None:
795 return test_response
796 """
797 使用功能调用能力生成响应
798
799 Args:
800 model_name (str): 模型名称
801 prompt (str): 输入提示
802 tools (list): 工具定义列表
803 timeout (int): 请求超时时间(秒)
804 mode (str): 选择策略,"cheap_first""fast_first"
805 input_proportion (int): 输入比例
806 output_proportion (int): 输出比例
807 max_tokens (int, optional): 最大生成token数,默认None(不限制)
808
809 Returns:
810 dict: 包含响应内容和工具调用的完整响应
811
812 Raises:
813 ValueError: 当模型在源上不可用时
814 Exception: 请求失败或其他错误
815 """
816 try:
817
818 load_balancing = LoadBalancing()
819 (
820 main_source_name,
821 main_source_model_name,
822 main_api_key,
823 backup_source_name,
824 backup_source_model_name,
825 backup_api_key,
826 ) = load_balancing.get_config(
827 model_name, mode, input_proportion, output_proportion
828 )
829
830 # Verify model mappings are valid
831 LLM_Wrapper._verify_model_mapping(
832 main_source_name,
833 backup_source_name,
834 main_source_model_name,
835 backup_source_model_name,
836 model_name,

Callers 3

test_function_callingFunction · 0.80
end_to_end_test_scenarioFunction · 0.80

Calls 10

get_configMethod · 0.95
get_responseMethod · 0.95
get_responseMethod · 0.95
LoadBalancingClass · 0.90
OpenaiInfraClass · 0.90
CurlInfraClass · 0.90
_verify_model_mappingMethod · 0.80
_generate_request_idMethod · 0.80
_send_api_key_usageMethod · 0.80

Tested by 3

test_function_callingFunction · 0.64
end_to_end_test_scenarioFunction · 0.64