[PR #82] [MERGED] Fix: handle explicit None values in ToolCall responses from OpenAI-compatible LLMs #129

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

📋 Pull Request Information

Original PR: https://github.com/langgenius/dify-plugin-sdks/pull/82
Author: @ExenVitor
Created: 4/8/2025
Status: Merged
Merged: 4/10/2025
Merged by: @Yeuoly

Base: mainHead: fix-toolcall-fields-may-be-explicit-none


📝 Commits (1)

  • b772d66 fix: ensure string fields in ToolCall default to empty string during initialization if set to explicit None

📊 Changes

2 files changed (+71 additions, -5 deletions)

View changed files

📝 python/dify_plugin/entities/model/message.py (+12 -5)
python/tests/test_tool_call_model_init.py (+59 -0)

📄 Description

Certain OpenAI-compatible LLM providers (e.g., SGLang, SiliconFlow) may return explicit None values in tool call response fields when operating in streaming mode.
To prevent Pydantic validation errors, ensure that string fields in ToolCall instances default to empty string ("") during initialization.


🔄 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/82 **Author:** [@ExenVitor](https://github.com/ExenVitor) **Created:** 4/8/2025 **Status:** ✅ Merged **Merged:** 4/10/2025 **Merged by:** [@Yeuoly](https://github.com/Yeuoly) **Base:** `main` ← **Head:** `fix-toolcall-fields-may-be-explicit-none` --- ### 📝 Commits (1) - [`b772d66`](https://github.com/langgenius/dify-plugin-sdks/commit/b772d66635f4dc5776ec45e83da899659fd04a3e) fix: ensure string fields in ToolCall default to empty string during initialization if set to explicit None ### 📊 Changes **2 files changed** (+71 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `python/dify_plugin/entities/model/message.py` (+12 -5) ➕ `python/tests/test_tool_call_model_init.py` (+59 -0) </details> ### 📄 Description Certain OpenAI-compatible LLM providers (e.g., SGLang, SiliconFlow) may return explicit `None` values in tool call response fields when operating in streaming mode. To prevent Pydantic validation errors, ensure that string fields in ToolCall instances default to empty string (`""`) during initialization. --- <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:54 -05:00
yindo closed this issue 2026-02-15 21:15:54 -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#129