mirror of
https://github.com/langgenius/dify-plugin-sdks.git
synced 2026-07-22 02:15:22 -04:00
[bug] input_type is not passed when text embedding #61
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @utsumi-fj on GitHub (Nov 17, 2025).
Description
The variable
data.input_type, which stores eitherEmbeddingInputType.DOCUMENTorEmbeddingInputType.QUERY, is not passed when executing text embedding.data.input_typeshould be passed tomodel_instance.invokelocated here:https://github.com/langgenius/dify-plugin-sdks/blob/0.6.1/python/dify_plugin/core/plugin_executor.py#L213
Background
When implementing a custom
_invokemethod in the following plugin:https://github.com/langgenius/dify-official-plugins/blob/main/models/openai_api_compatible/models/text_embedding/text_embedding.py
I attempted to check the value of
input_typeinside_invoke. However,input_typewas alwaysEmbeddingInputType.DOCUMENT, even when the request was actually a query.This suggests that the correct
input_typevalue is not being passed through to_invoke.@Mairuis commented on GitHub (Dec 8, 2025):
Hi @utsumi-fj,
Thank you for reporting this issue. After investigating the code across the entire pipeline, I can confirm this is indeed a bug.
Root Cause Analysis
The
input_typeparameter is correctly passed through Dify and the plugin daemon, but the SDK fails to receive and forward it:input_type?core/plugin/impl/model.py:236-264pkg/entities/requests/model.go:35-38InputType stringfieldcore/entities/plugin/request.py:199-203core/plugin_executor.py:210-218The Problem
In the SDK's
ModelInvokeTextEmbeddingRequestclass, theinput_typefield is missing:And in
plugin_executor.py, theinput_typeis not passed to the model'sinvokemethod:This causes
input_typeto always default toEmbeddingInputType.DOCUMENT.Thank you for your contribution with the fix PR! I will follow up on it.