__base.model_provider.ModelProvider
base class and implement the following interfaces:
credentials
(object) Credential information
The parameters of credential information are defined by the provider_credential_schema
in the providerâs YAML configuration file. Inputs such as api_key
are included.
errors.validate.CredentialsValidateFailedError
error.
model
(string) Model name
credentials
(object) Credential information
The parameters of credential information are defined by either the provider_credential_schema
or model_credential_schema
in the providerâs YAML configuration file. Inputs such as api_key
are included.
errors.validate.CredentialsValidateFailedError
error.
InvokeError
type specified by Runtime. This facilitates Difyâs ability to handle different errors with appropriate follow-up actions.
Runtime Errors:
InvokeConnectionError
Invocation connection errorInvokeServerUnavailableError
Invocation service provider unavailableInvokeRateLimitError
Invocation reached rate limitInvokeAuthorizationError
Invocation authorization failureInvokeBadRequestError
Invocation parameter error_invoke_error_mapping
for an example.
__base.large_language_model.LargeLanguageModel
base class and implement the following interfaces:
model
(string) Model name
credentials
(object) Credential information
The parameters of credential information are defined by either the provider_credential_schema
or model_credential_schema
in the providerâs YAML configuration file. Inputs such as api_key
are included.
prompt_messages
(array[PromptMessage]) List of prompts
If the model is of the Completion
type, the list only needs to include one UserPromptMessage element;
If the model is of the Chat
type, it requires a list of elements such as SystemPromptMessage, UserPromptMessage, AssistantPromptMessage, ToolPromptMessage depending on the message.
model_parameters
(object) Model parameters
The model parameters are defined by the parameter_rules
in the modelâs YAML configuration.
tools
(array[PromptMessageTool]) [optional] List of tools, equivalent to the function
in function calling
.
That is, the tool list for tool calling.
stop
(array[string]) [optional] Stop sequences
The model output will stop before the string defined by the stop sequence.
stream
(bool) Whether to output in a streaming manner, default is True
Streaming output returns Generator[LLMResultChunk], non-streaming output returns LLMResult.
user
(string) [optional] Unique identifier of the user
This can help the provider monitor and detect abusive behavior.
LLM Invocation
.
__base.text_embedding_model.TextEmbeddingModel
base class and implement the following interfaces:
model
(string) Model name
credentials
(object) Credential information
The parameters of credential information are defined by either the provider_credential_schema
or model_credential_schema
in the providerâs YAML configuration file. Inputs such as api_key
are included.
texts
(array[string]) List of texts, capable of batch processing
user
(string) [optional] Unique identifier of the user
This can help the provider monitor and detect abusive behavior.
Embedding Invocation
.
__base.rerank_model.RerankModel
base class and implement the following interfaces:
model
(string) Model name
credentials
(object) Credential information
The parameters of credential information are defined by either the provider_credential_schema
or model_credential_schema
in the providerâs YAML configuration file. Inputs such as api_key
are included.
query
(string) Query request content
docs
(array[string]) List of segments to be reranked
score_threshold
(float) [optional] Score threshold
top_n
(int) [optional] Select the top n segments
user
(string) [optional] Unique identifier of the user
This can help the provider monitor and detect abusive behavior.
__base.speech2text_model.Speech2TextModel
base class and implement the following interfaces:
model
(string) Model name
credentials
(object) Credential information
The parameters of credential information are defined by either the provider_credential_schema
or model_credential_schema
in the providerâs YAML configuration file. Inputs such as api_key
are included.
file
(File) File stream
user
(string) [optional] Unique identifier of the user
This can help the provider monitor and detect abusive behavior.
__base.text2speech_model.Text2SpeechModel
base class and implement the following interfaces:
model
(string) Model name
credentials
(object) Credential information
The parameters of credential information are defined by either the provider_credential_schema
or model_credential_schema
in the providerâs YAML configuration file. Inputs such as api_key
are included.
content_text
(string) The text content that needs to be converted
streaming
(bool) Whether to stream output
user
(string) [optional] Unique identifier of the user
This can help the provider monitor and detect abusive behavior.
__base.moderation_model.ModerationModel
base class and implement the following interfaces:
model
(string) Model name
credentials
(object) Credential information
The parameters of credential information are defined by either the provider_credential_schema
or model_credential_schema
in the providerâs YAML configuration file. Inputs such as api_key
are included.
text
(string) Text content
user
(string) [optional] Unique identifier of the user
This can help the provider monitor and detect abusive behavior.
TextPromptMessageContent
and ImagePromptMessageContent
separately for input.
content
list.
content
list.
data
can be either a url
or a base64
encoded string of the image.
few-shots
or inputting chat history.
tool_calls
are the list of tool calls
returned by the model after invoking the model with the tools
input.
content
takes in the results of tool execution.
delta
entity.