[bug] input_type is not passed when text embedding #61

Open
opened 2026-02-15 21:15:31 -05:00 by yindo · 1 comment
Owner

Originally created by @utsumi-fj on GitHub (Nov 17, 2025).

Description

The variable data.input_type, which stores either EmbeddingInputType.DOCUMENT or EmbeddingInputType.QUERY, is not passed when executing text embedding.

data.input_type should be passed to model_instance.invoke located 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 _invoke method 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_type inside _invoke. However, input_type was always EmbeddingInputType.DOCUMENT, even when the request was actually a query.

This suggests that the correct input_type value is not being passed through to _invoke.

Originally created by @utsumi-fj on GitHub (Nov 17, 2025). ## Description The variable `data.input_type`, which stores either `EmbeddingInputType.DOCUMENT` or `EmbeddingInputType.QUERY`, is not passed when executing text embedding. `data.input_type` should be passed to `model_instance.invoke` located 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 `_invoke` method 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_type` inside `_invoke`. However, `input_type` was always `EmbeddingInputType.DOCUMENT`, even when the request was actually a query. This suggests that the correct `input_type` value is not being passed through to `_invoke`.
yindo added the bug label 2026-02-15 21:15:31 -05:00
Author
Owner

@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_type parameter is correctly passed through Dify and the plugin daemon, but the SDK fails to receive and forward it:

Component File Has input_type?
Dify core/plugin/impl/model.py:236-264 Yes, passes to daemon
dify-plugin-daemon pkg/entities/requests/model.go:35-38 Yes, has InputType string field
dify-plugin-sdks core/entities/plugin/request.py:199-203 Missing!
dify-plugin-sdks core/plugin_executor.py:210-218 Not passed!

The Problem

In the SDK's ModelInvokeTextEmbeddingRequest class, the input_type field is missing:

class ModelInvokeTextEmbeddingRequest(PluginAccessModelRequest):
    action: ModelActions = ModelActions.InvokeTextEmbedding
    texts: list[str]
    # ❌ Missing: input_type field

And in plugin_executor.py, the input_type is not passed to the model's invoke method:

def invoke_text_embedding(self, session: Session, data: ModelInvokeTextEmbeddingRequest):
    return model_instance.invoke(
        data.model,
        data.credentials,
        data.texts,
        data.user_id,
        # ❌ Missing: input_type parameter
    )

This causes input_type to always default to EmbeddingInputType.DOCUMENT.

Thank you for your contribution with the fix PR! I will follow up on it.

@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_type` parameter is correctly passed through Dify and the plugin daemon, but the SDK fails to receive and forward it: | Component | File | Has `input_type`? | |-----------|------|-------------------| | **Dify** | `core/plugin/impl/model.py:236-264` | ✅ Yes, passes to daemon | | **dify-plugin-daemon** | `pkg/entities/requests/model.go:35-38` | ✅ Yes, has `InputType string` field | | **dify-plugin-sdks** | `core/entities/plugin/request.py:199-203` | ❌ **Missing!** | | **dify-plugin-sdks** | `core/plugin_executor.py:210-218` | ❌ **Not passed!** | ## The Problem In the SDK's `ModelInvokeTextEmbeddingRequest` class, the `input_type` field is missing: ```python class ModelInvokeTextEmbeddingRequest(PluginAccessModelRequest): action: ModelActions = ModelActions.InvokeTextEmbedding texts: list[str] # ❌ Missing: input_type field ``` And in `plugin_executor.py`, the `input_type` is not passed to the model's `invoke` method: ```python def invoke_text_embedding(self, session: Session, data: ModelInvokeTextEmbeddingRequest): return model_instance.invoke( data.model, data.credentials, data.texts, data.user_id, # ❌ Missing: input_type parameter ) ``` This causes `input_type` to always default to `EmbeddingInputType.DOCUMENT`. Thank you for your contribution with the fix PR! I will follow up on it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-plugin-sdks#61