[PR #738] [MERGED] feat: add structured output support to openai_api_compatible #1522

Closed
opened 2026-02-16 10:23:12 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langgenius/dify-official-plugins/pull/738
Author: @mountln
Created: 4/16/2025
Status: Merged
Merged: 5/6/2025
Merged by: @crazywoola

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


📝 Commits (4)

  • 4758eee feat: add structured output support to openai_api_compatible
  • 0461c49 style(openai_api_compatible): replace string with enum value
  • 190e590 Merge branch 'langgenius:main' into feat/oai-compat-structured-output
  • 6cc0eb4 Merge branch 'main' into feat/oai-compat-structured-output

📊 Changes

3 files changed (+49 additions, -1 deletions)

View changed files

📝 models/openai_api_compatible/manifest.yaml (+1 -1)
📝 models/openai_api_compatible/models/llm/llm.py (+30 -0)
📝 models/openai_api_compatible/provider/openai_api_compatible.yaml (+18 -0)

📄 Description

Related Issues or Context

Added structured output support to OpenAI-compatible LLMs.
The parameter rule settings were based on gpt-4o.yaml.

Related Issue and PR

Test Result

If "Structured Output" was set to "Support" in model settings:

Then json_schema can be configured in PARAMETERS:

Here is an output example:

This PR contains Changes to Non-Plugin

  • Documentation
  • Other

This PR contains Changes to Non-LLM Models Plugin

  • I have Run All Tests Relevant to My Changes

This PR contains Changes to LLM Models Plugin

  • My Changes Affect Message Flow Handling (System Messages and User→Assistant Turn-Taking)
  • My Changes Affect Tool Interaction Flow (Multi-Round Usage and Output Handling, for both Agent App and Agent Node)
  • My Changes Affect Multimodal Input Handling (Images, PDFs, Audio, Video, etc.)
  • My Changes Affect Multimodal Output Generation (Images, Audio, Video, etc.)
  • My Changes Affect Structured Output Format (JSON, XML, etc.)
  • My Changes Affect Token Consumption Metrics
  • My Changes Affect Other LLM Functionalities (Reasoning Process, Grounding, Prompt Caching, etc.)
  • Other Changes (Add New Models, etc.)

Version Control (Any Changes to the Plugin Will Require Bumping the Version)

  • I have Bumped Up the Version in Manifest.yaml (Top-Level Version Field, Not in Meta Section)

Environment Verification (If Any Code Changes)

Local Deployment Environment

  • I have Tested My Changes on Local Deployment Dify with a Clean Environment That Matches the Production Configuration. Dify Version is: 1.2.0

SaaS Environment

  • I have Tested My Changes on cloud.dify.ai with a Clean Environment That Matches the Production Configuration

🔄 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-official-plugins/pull/738 **Author:** [@mountln](https://github.com/mountln) **Created:** 4/16/2025 **Status:** ✅ Merged **Merged:** 5/6/2025 **Merged by:** [@crazywoola](https://github.com/crazywoola) **Base:** `main` ← **Head:** `feat/oai-compat-structured-output` --- ### 📝 Commits (4) - [`4758eee`](https://github.com/langgenius/dify-official-plugins/commit/4758eeeea20556795aab2a3b0235f1a30c349252) feat: add structured output support to openai_api_compatible - [`0461c49`](https://github.com/langgenius/dify-official-plugins/commit/0461c49a7d3f29851ee99a49318caec466511d5b) style(openai_api_compatible): replace string with enum value - [`190e590`](https://github.com/langgenius/dify-official-plugins/commit/190e59049256e50f651a6d25fe413c98d147be02) Merge branch 'langgenius:main' into feat/oai-compat-structured-output - [`6cc0eb4`](https://github.com/langgenius/dify-official-plugins/commit/6cc0eb42be9bda4d4d6c265585d89487449c93a5) Merge branch 'main' into feat/oai-compat-structured-output ### 📊 Changes **3 files changed** (+49 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `models/openai_api_compatible/manifest.yaml` (+1 -1) 📝 `models/openai_api_compatible/models/llm/llm.py` (+30 -0) 📝 `models/openai_api_compatible/provider/openai_api_compatible.yaml` (+18 -0) </details> ### 📄 Description ## Related Issues or Context <!-- ⚠️ NOTE: This repository is for Dify Official Plugins only. For community contributions, please submit to https://github.com/langgenius/dify-plugins instead. - Link Related Issues if Applicable: #issue_number - Or Provide Context about Why this Change is Needed --> Added structured output support to 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). ### Related Issue and PR - [[Feature Request] Structuring Outputs using OpenAi-API-compatible #15831](https://github.com/langgenius/dify/issues/15831) - [feat(openai_compatible): Add structured output support #95](https://github.com/langgenius/dify-plugin-sdks/pull/95) ### Test Result If "Structured Output" was set to "Support" in model settings: <img src="https://github.com/user-attachments/assets/535309c9-0938-44ed-8ed0-9806ed73c61f" width="300"> Then `json_schema` can be configured in PARAMETERS: <img src="https://github.com/user-attachments/assets/56700fc3-9782-419c-99f8-9e62bd2538a4" width="600"> Here is an output example: <img src="https://github.com/user-attachments/assets/b6222393-e994-45fe-989b-37e134d9e0cd" width="300"> ## This PR contains Changes to *Non-Plugin* <!-- Put an `x` in all the boxes that apply by replacing [ ] with [x] For example: - [x] Documentation --> - [ ] Documentation - [ ] Other ## This PR contains Changes to *Non-LLM Models Plugin* - [ ] I have Run All Tests Relevant to My Changes <!-- 📷 Include Screenshots/Videos Demonstrating the Fix, New Feature, or the Behavior Before/After Breaking Changes. --> ## This PR contains Changes to *LLM Models Plugin* <!-- LLM Models Test Example: --> <!-- https://github.com/langgenius/dify-official-plugins/blob/main/.assets/test-examples/llm-plugin-tests/llm_test_example.md --> - [ ] My Changes Affect Message Flow Handling (System Messages and User→Assistant Turn-Taking) <!-- 📷 Include Screenshots/Videos Demonstrating the Fix, New Feature, or the Behavior Before/After Breaking Changes. --> - [ ] My Changes Affect Tool Interaction Flow (Multi-Round Usage and Output Handling, for both Agent App and Agent Node) <!-- 📷 Include Screenshots/Videos Demonstrating the Fix, New Feature, or the Behavior Before/After Breaking Changes. --> - [ ] My Changes Affect Multimodal Input Handling (Images, PDFs, Audio, Video, etc.) <!-- 📷 Include Screenshots/Videos Demonstrating the Fix, New Feature, or the Behavior Before/After Breaking Changes. --> - [ ] My Changes Affect Multimodal Output Generation (Images, Audio, Video, etc.) <!-- 📷 Include Screenshots/Videos Demonstrating the Fix, New Feature, or the Behavior Before/After Breaking Changes. --> - [x] My Changes Affect Structured Output Format (JSON, XML, etc.) <!-- 📷 Include Screenshots/Videos Demonstrating the Fix, New Feature, or the Behavior Before/After Breaking Changes. --> - [ ] My Changes Affect Token Consumption Metrics <!-- 📷 Include Screenshots/Videos Demonstrating the Fix, New Feature, or the Behavior Before/After Breaking Changes. --> - [ ] My Changes Affect Other LLM Functionalities (Reasoning Process, Grounding, Prompt Caching, etc.) <!-- 📷 Include Screenshots/Videos Demonstrating the Fix, New Feature, or the Behavior Before/After Breaking Changes. --> - [ ] Other Changes (Add New Models, etc.) <!-- 📷 Include Screenshots/Videos Demonstrating the Fix, New Feature, or the Behavior Before/After Breaking Changes. --> ## Version Control (Any Changes to the Plugin Will Require Bumping the Version) - [x] I have Bumped Up the Version in Manifest.yaml (Top-Level `Version` Field, Not in Meta Section) <!-- ⚠️ NOTE: Version Format: MAJOR.MINOR.PATCH - MAJOR (0.x.x): Reserved for Significant architectural changes or incompatible API modifications - MINOR (x.0.x): For New feature additions while maintaining backward compatibility - PATCH (x.x.0): For Backward-compatible bug fixes and minor improvements - Note: Each Version Component (MAJOR, MINOR, PATCH) Can Be 2 Digits, e.g., 10.11.22 --> ## Environment Verification (If Any Code Changes) <!-- ⚠️ NOTE: At Least One Environment Must Be Tested. --> ### Local Deployment Environment - [x] I have Tested My Changes on Local Deployment Dify with a Clean Environment That Matches the Production Configuration. Dify Version is: 1.2.0<!-- Specify Your Version (e.g., 1.2.0) --> <!-- - Python Virtual Env Matching Manifest.yaml & requirements.txt - No Breaking Changes in Dify That May Affect the Testing Result --> ### SaaS Environment - [ ] I have Tested My Changes on cloud.dify.ai with a Clean Environment That Matches the Production Configuration <!-- - Python Virtual Env Matching Manifest.yaml & requirements.txt --> --- <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-16 10:23:12 -05:00
yindo closed this issue 2026-02-16 10:23:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#1522