[PR #7258] feat: support OPENAI json_schema #25623

Closed
opened 2026-02-21 20:25:20 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/7258

State: closed
Merged: Yes


Checklist:

Important

Please review the checklist below before submitting your pull request.

  • Please open an issue before creating a PR or link to an existing issue
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods

Description

follow the openAI structured output doc to make dify workflow's LLM node can adhere to use define's json schema.

692d52c0ad2d8564bf38316104643af

file-20240814152258084

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update, included: Dify Document
  • Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
  • Dependency upgrade

Testing Instructions

test locally with gpt-4o-mini
with schema:

{  
    "name": "get_weather",  
    "description": "Fetches the weather in the given location",  
    "strict": true,  
    "schema": {  
        "type": "object",  
        "properties": {  
            "location": {  
                "type": "string",  
                "description": "The location to get the weather for"  
            },  
            "unit": {  
                "type": "string",  
                "description": "The unit to return the temperature in",  
                "enum": ["F", "C"]  
            }  
        },  
        "additionalProperties": false,  
        "required": ["location", "unit"]  
    }  
}
**Original Pull Request:** https://github.com/langgenius/dify/pull/7258 **State:** closed **Merged:** Yes --- # Checklist: > [!IMPORTANT] > Please review the checklist below before submitting your pull request. - [ ] Please open an issue before creating a PR or link to an existing issue - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods # Description follow the openAI [structured output doc](https://platform.openai.com/docs/guides/structured-outputs/introduction) to make dify workflow's LLM node can adhere to use define's json schema. ![692d52c0ad2d8564bf38316104643af](https://github.com/user-attachments/assets/76826da7-a646-4be5-9a0e-9c625f874f99) ![file-20240814152258084](https://github.com/user-attachments/assets/b5e6e2cc-4bc7-4463-b260-2e28703e1d68) ## Type of Change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [ ] Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement - [ ] Dependency upgrade # Testing Instructions test locally with `gpt-4o-mini` with schema: ``` { "name": "get_weather", "description": "Fetches the weather in the given location", "strict": true, "schema": { "type": "object", "properties": { "location": { "type": "string", "description": "The location to get the weather for" }, "unit": { "type": "string", "description": "The unit to return the temperature in", "enum": ["F", "C"] } }, "additionalProperties": false, "required": ["location", "unit"] } } ```
yindo added the pull-request label 2026-02-21 20:25:20 -05:00
yindo closed this issue 2026-02-21 20:25:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#25623