This document details how plugins can reverse invoke model services within the Dify platform. It covers specific methods for reverse invoking LLM, Summary, TextEmbedding, Rerank, TTS, Speech2Text, and Moderation models. Each model invocation includes its entry point, interface parameter descriptions, practical usage code examples, and best practice recommendations for invoking models.
ModelConfig
type parameter. Its structure can be referenced in the General Specifications Definition, and this structure will have slight differences for different types of models.
For example, for LLM
type models, it also needs to include completion_params
and mode
parameters. You can manually construct this structure or use model-selector
type parameters or configurations.
tool_call
capability, the tools
passed here will not take effect.
gpt-4o-mini
model within a Tool
, please refer to the following example code:
query
parameter from tool_parameters
is passed in the code.
LLMModelConfig
. Instead, allow users to select the model they want to use on the UI. In this case, you can modify the tool’s parameter list by adding a model
parameter as follows:
scope
of model
is specified as llm
. This means the user can only select llm
type parameters. Thus, the code from the previous use case can be modified as follows:
text
is the text to be summarized.instruction
is the additional instruction you want to add, allowing you to summarize the text stylistically.bytes
stream returned by the tts
endpoint is an mp3
audio byte stream. Each iteration returns a complete audio segment. If you want to perform more in-depth processing tasks, please choose an appropriate library.
file
is an audio file encoded in mp3
format.
true
, it indicates that the text
contains sensitive content.