[PR #57] [MERGED] fix: bypass _code_block_mode_wrapper if response_format is not JSON or XML #111

Closed
opened 2026-02-15 21:15:49 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langgenius/dify-plugin-sdks/pull/57
Author: @kurokobo
Created: 3/20/2025
Status: Merged
Merged: 3/24/2025
Merged by: @Yeuoly

Base: mainHead: json_xml


📝 Commits (1)

  • 05a9bf4 fix: bypass _code_block_mode_wrapper if response_format is not JSON or XML

📊 Changes

1 file changed (+2 additions, -2 deletions)

View changed files

📝 python/dify_plugin/interfaces/model/large_language_model.py (+2 -2)

📄 Description

This is regression of #8451, and re-application of #9148 by @hjlarry.

Related issues and PRs:

In the current implementation, self._code_block_mode_wrapper is executed when the response_format is json_schema, but this method is intended to force output format to JSON or XML that is independently implemented by Dify itself, and not for the Structured Output feature that the LLM model possesses.

When this method is called when the response_format is neither JSON nor XML such as json_schema, the model_parameters and prompts can be formatted in an unintended way by the LLM, leading to errors in subsequent processing.

Closes #28


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langgenius/dify-plugin-sdks/pull/57 **Author:** [@kurokobo](https://github.com/kurokobo) **Created:** 3/20/2025 **Status:** ✅ Merged **Merged:** 3/24/2025 **Merged by:** [@Yeuoly](https://github.com/Yeuoly) **Base:** `main` ← **Head:** `json_xml` --- ### 📝 Commits (1) - [`05a9bf4`](https://github.com/langgenius/dify-plugin-sdks/commit/05a9bf4dfd5c190360d6b91076311fb85923010f) fix: bypass _code_block_mode_wrapper if response_format is not JSON or XML ### 📊 Changes **1 file changed** (+2 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `python/dify_plugin/interfaces/model/large_language_model.py` (+2 -2) </details> ### 📄 Description This is regression of #8451, and re-application of #9148 by @hjlarry. Related issues and PRs: - https://github.com/langgenius/dify-official-plugins/issues/477 - https://github.com/langgenius/dify-official-plugins/issues/425 - https://github.com/langgenius/dify/issues/14475 - https://github.com/langgenius/dify-plugin-sdks/issues/28 - https://github.com/langgenius/dify-plugin-sdks/pull/29 In the current implementation, `self._code_block_mode_wrapper` is executed when the `response_format` is `json_schema`, but this method is intended to force output format to `JSON` or `XML` that is independently implemented by Dify itself, and not for the Structured Output feature that the LLM model possesses. When this method is called when the `response_format` is neither `JSON` nor `XML` such as `json_schema`, the `model_parameters` and prompts can be formatted in an unintended way by the LLM, leading to errors in subsequent processing. Closes #28 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 21:15:49 -05:00
yindo closed this issue 2026-02-15 21:15:49 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-plugin-sdks#111