def_invoke(self,model:str,credentials:dict,prompt_messages: list[PromptMessage],model_parameters:dict,tools: Optional[list[PromptMessageTool]]=None,stop: Optional[List[str]]=None,stream:bool=True,user: Optional[str]=None) \-> Union[LLMResult, Generator]:""" Invoke large language model :param model: model name :param credentials: model credentials :param prompt_messages: prompt messages :param model_parameters: model parameters :param tools: tools for tool calling :param stop: stop words :param stream: is stream response :param user: unique user id :return: full response or stream response chunk generator result """
defget_num_tokens(self,model:str,credentials:dict,prompt_messages: list[PromptMessage],tools: Optional[list[PromptMessageTool]]=None) ->int:""" Get number of tokens for given prompt messages :param model: model name :param credentials: model credentials :param prompt_messages: prompt messages :param tools: tools for tool calling :return: """
モデル認証情報検証
プロバイダーの認証情報検証と同様に、ここでは個別のモデルに対して検証を行います。
defvalidate_credentials(self,model:str,credentials:dict) ->None:""" Validate model credentials :param model: model name :param credentials: model credentials :return: """
@propertydef_invoke_error_mapping(self) -> dict[type[InvokeError], list[type[Exception]]]:""" Map model invoke error to unified error The key is the error type thrown to the caller The value is the error type thrown by the model, which needs to be converted into a unified error type for the caller. :return: Invoke error mapping """