[PR #199] [MERGED] feat(openai): Support o1 and o3-mini models with compatibility fixes #1174

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

📋 Pull Request Information

Original PR: https://github.com/langgenius/dify-official-plugins/pull/199
Author: @takatea
Created: 2/11/2025
Status: Merged
Merged: 2/12/2025
Merged by: @Yeuoly

Base: mainHead: support-o1-and-o3-mini-models


📝 Commits (7)

  • 7d3dec3 feat(openai): add support for o1 and o3-mini models
  • 546cfaa chore(openai): update the dependcy version
  • f2ee7ea chore(openai): add .env.sample
  • a3afa03 fix(openai): add compatibility for o1/o3 series models
  • cfc73de feat(openai): Add block-as-stream support for o1 models
  • 331df23 docs(openai): update URL for token calculation NotImplementedError
  • a19444c chore(openai): bump openai dependency

📊 Changes

8 files changed (+249 additions, -8 deletions)

View changed files

models/openai/.env.example (+4 -0)
📝 models/openai/manifest.yaml (+1 -1)
📝 models/openai/models/llm/_position.yaml (+6 -0)
📝 models/openai/models/llm/llm.py (+95 -5)
models/openai/models/llm/o1.yaml (+49 -0)
models/openai/models/llm/o3-mini-2025-01-31.yaml (+46 -0)
models/openai/models/llm/o3-mini.yaml (+46 -0)
📝 models/openai/requirements.txt (+2 -2)

📄 Description

Summary:

  • Support o1 and o3-mini models
  • Implement compatibility fixes to handle specific requirements for o1-mini, o1, and o3-mini models (e.g., max_tokens -> max_completion_tokens conversion, system message handling).

Help Wanted:

  • Verify compatibility and functionality of o1 and o3-mini models

The changes have been verified with o1-mini, o1-mini-2024-09-12 and o1-preview.
Since I couldn't verify o1 and o3-mini models with my Tier 1 access, it would be great if someone with Tier 3 or higher access could check these models as well...!

Description:

Port compatibility handling from langgenius/dify@0.15.3 to support following o1 series and o3-mini models.

Notes:

  • Confirmed working with o1-mini, o1-mini-2024-09-12 and o1-preview models
  • o1 and o3-mini models require Tier 3 or higher access and could not be checked

Screenshots

Workflow Type before (o1-mini not worked) after (o1-mini work)
Chatbot image image
Agent image image
Chatflow image image
Workflow image image

Supplemental error details:

The same error occurred in both Chatbot and Agent implementations.

NotImplementedError: get_num_tokens_from_messages() is not presently implemented for model o1-mini.See https://github.com/openai/openai-python/blob/main/chatml.md for information on how messages are converted to tokens.

Reference using gpt-4o-mini

Chatbot Agent Chatflow Workflow
image image image image

Ref


🔄 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/199 **Author:** [@takatea](https://github.com/takatea) **Created:** 2/11/2025 **Status:** ✅ Merged **Merged:** 2/12/2025 **Merged by:** [@Yeuoly](https://github.com/Yeuoly) **Base:** `main` ← **Head:** `support-o1-and-o3-mini-models` --- ### 📝 Commits (7) - [`7d3dec3`](https://github.com/langgenius/dify-official-plugins/commit/7d3dec3477ae3bce2ea3f3f862ced429dc27107a) feat(openai): add support for o1 and o3-mini models - [`546cfaa`](https://github.com/langgenius/dify-official-plugins/commit/546cfaa7cd7a44e12ed9e4d8a8f085ad11ffc386) chore(openai): update the dependcy version - [`f2ee7ea`](https://github.com/langgenius/dify-official-plugins/commit/f2ee7ead07e2413712bcf5c044f065bc4c5865c0) chore(openai): add .env.sample - [`a3afa03`](https://github.com/langgenius/dify-official-plugins/commit/a3afa032ae48f5b6bb6d6f6317d20e3592afffdd) fix(openai): add compatibility for o1/o3 series models - [`cfc73de`](https://github.com/langgenius/dify-official-plugins/commit/cfc73de598920bb1095695b3a2ef7ed275325368) feat(openai): Add block-as-stream support for o1 models - [`331df23`](https://github.com/langgenius/dify-official-plugins/commit/331df23e66502c79d9b6da2ae6499e670b9a8ebb) docs(openai): update URL for token calculation NotImplementedError - [`a19444c`](https://github.com/langgenius/dify-official-plugins/commit/a19444cea257635d696dabad4c525431dd398d8a) chore(openai): bump openai dependency ### 📊 Changes **8 files changed** (+249 additions, -8 deletions) <details> <summary>View changed files</summary> ➕ `models/openai/.env.example` (+4 -0) 📝 `models/openai/manifest.yaml` (+1 -1) 📝 `models/openai/models/llm/_position.yaml` (+6 -0) 📝 `models/openai/models/llm/llm.py` (+95 -5) ➕ `models/openai/models/llm/o1.yaml` (+49 -0) ➕ `models/openai/models/llm/o3-mini-2025-01-31.yaml` (+46 -0) ➕ `models/openai/models/llm/o3-mini.yaml` (+46 -0) 📝 `models/openai/requirements.txt` (+2 -2) </details> ### 📄 Description ## Summary: - Support o1 and o3-mini models - Implement compatibility fixes to handle specific requirements for o1-mini, o1, and o3-mini models (e.g., max_tokens -> max_completion_tokens conversion, system message handling). **Help Wanted:** - Verify compatibility and functionality of o1 and o3-mini models The changes have been verified with o1-mini, o1-mini-2024-09-12 and o1-preview. Since I couldn't verify o1 and o3-mini models with my [Tier 1](https://platform.openai.com/docs/guides/rate-limits?tier=tier-one) access, it would be great if someone with [Tier 3](https://platform.openai.com/docs/guides/rate-limits?tier=tier-three) or higher access could check these models as well...! ## Description: Port compatibility handling from langgenius/dify@0.15.3 to support following o1 series and o3-mini models. - Convert max_tokens to max_completion_tokens - https://platform.openai.com/docs/api-reference/chat/create#chat-create-max_tokens - langgenius/dify@867bf70 - Remove stop parameter which is not supported by o1 series models - langgenius/dify@4637dda (initial o1 support) - langgenius/dify@bff4cc5 (extend to o3 models) - Convert system messages to user messages - langgenius/dify@4637dda - Handle o1 series stream mode - langgenius/dify#12839 - Adjust token calculation method - langgenius/dify@e90d3c2 - langgenius/dify@7203991 Notes: - Confirmed working with o1-mini, o1-mini-2024-09-12 and o1-preview models - o1 and o3-mini models require [Tier 3](https://platform.openai.com/docs/guides/rate-limits?tier=tier-three) or higher access and could not be checked - [Tier 1](https://platform.openai.com/docs/guides/rate-limits?tier=tier-one) - [Tier 2](https://platform.openai.com/docs/guides/rate-limits?tier=tier-two) ## Screenshots | Workflow Type | before (o1-mini not worked) | after (o1-mini work) | | ------------- | --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | | Chatbot | <img width="270" alt="image" src="https://github.com/user-attachments/assets/7cbcb030-c720-4783-a051-808adc9f96d0" /> | <img width="270" alt="image" src="https://github.com/user-attachments/assets/e38cdd78-696e-4909-8c68-76b858fb66d1" /> | | Agent | <img width="270" alt="image" src="https://github.com/user-attachments/assets/c41ba1d3-b248-46f1-88a5-cd217800c596" /> | <img width="270" alt="image" src="https://github.com/user-attachments/assets/8e244da4-ee76-422d-8bef-3bc8e99b6893" /> | | Chatflow | <img width="270" alt="image" src="https://github.com/user-attachments/assets/b99867f9-61b6-4c92-98c0-72bc5d55b427" /> | <img width="270" alt="image" src="https://github.com/user-attachments/assets/080126c3-f43f-4d28-a781-ae42c6086ae7" /> | | Workflow | <img width="270" alt="image" src="https://github.com/user-attachments/assets/696c42a2-adc7-4da7-a1ed-a711d5379ca0" /> | <img width="270" alt="image" src="https://github.com/user-attachments/assets/be23ced0-9711-4fa6-9665-c66cde96dccf" /> | **Supplemental error details:** The same error occurred in both Chatbot and Agent implementations. ``` NotImplementedError: get_num_tokens_from_messages() is not presently implemented for model o1-mini.See https://github.com/openai/openai-python/blob/main/chatml.md for information on how messages are converted to tokens. ``` ### Reference using gpt-4o-mini | Chatbot | Agent | Chatflow | Workflow | | --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | | <img width="300" alt="image" src="https://github.com/user-attachments/assets/6b081d37-75b9-47be-8930-78d49e0aded5" /> | <img width="300" alt="image" src="https://github.com/user-attachments/assets/dec87d6c-28d9-4237-a849-370681282b95" /> | <img width="300" alt="image" src="https://github.com/user-attachments/assets/2e52af31-5fa4-4395-a2d1-8093dd73fca9" /> | <img width="300" alt="image" src="https://github.com/user-attachments/assets/4ca5e39f-373d-4310-9469-246368c9d1eb" /> | ## Ref - https://github.com/langgenius/dify/blob/0.15.3/api/core/model_runtime/model_providers/openai/llm/llm.py --- <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:22:11 -05:00
yindo closed this issue 2026-02-16 10:22:11 -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#1174