[PR #95] [CLOSED] feat(openai_compatible): Add structured output support #141

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

📋 Pull Request Information

Original PR: https://github.com/langgenius/dify-plugin-sdks/pull/95
Author: @mountln
Created: 4/14/2025
Status: Closed

Base: mainHead: feat/oai-compat-structured-output


📝 Commits (1)

  • f2bb016 feat: add structured output support to OpenAI compatible LLM

📊 Changes

1 file changed (+15 additions, -0 deletions)

View changed files

📝 python/dify_plugin/interfaces/model/openai_compatible/llm.py (+15 -0)

📄 Description

Added the parameter rules response_format and json_schema to support structured output when using OpenAI-compatible LLMs.
The parameter rule settings were based on gpt-4o.yaml.
(The response_format logic already exists in _generate (L352-L367), so only adding the parameter rules is necessary.)

Related Issue

[Feature Request] Structuring Outputs using OpenAi-API-compatible #15831

Test Result (Tested on Local Deployment - Dify v1.2.0)

json_schema can now be configured from the UI.

Below is an output example.


🔄 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/95 **Author:** [@mountln](https://github.com/mountln) **Created:** 4/14/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/oai-compat-structured-output` --- ### 📝 Commits (1) - [`f2bb016`](https://github.com/langgenius/dify-plugin-sdks/commit/f2bb016840b5f7f71e4ad8742b8f730acf7f0da9) feat: add structured output support to OpenAI compatible LLM ### 📊 Changes **1 file changed** (+15 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `python/dify_plugin/interfaces/model/openai_compatible/llm.py` (+15 -0) </details> ### 📄 Description Added the parameter rules `response_format` and `json_schema` to support structured output when using OpenAI-compatible LLMs. The parameter rule settings were based on [gpt-4o.yaml](https://github.com/langgenius/dify-official-plugins/blob/2ea9dba5de751566865b8f99c8fbcc9ae2f03c77/models/openai/models/llm/gpt-4o.yaml#L28-L42). (The `response_format` logic already exists in `_generate` ([L352-L367](https://github.com/langgenius/dify-plugin-sdks/blob/5cb24625c36eb069f80c7f71196d15536101e588/python/dify_plugin/interfaces/model/openai_compatible/llm.py#L352-L367)), so only adding the parameter rules is necessary.) ## Related Issue [[Feature Request] Structuring Outputs using OpenAi-API-compatible #15831](https://github.com/langgenius/dify/issues/15831) ## Test Result (Tested on Local Deployment - Dify v1.2.0) `json_schema` can now be configured from the UI. <img src="https://github.com/user-attachments/assets/9080fa86-21f4-4e43-bbeb-42f662f1e13c" width="600"> Below is an output example. <img src="https://github.com/user-attachments/assets/809fb3a2-03e7-4644-a0ef-dbd0eabe43d8" width="300"> --- <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:56 -05:00
yindo closed this issue 2026-02-15 21:15:56 -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#141