[PR #103] [MERGED] optimize: replace json.loads with TypeAdapter for JSON unmarshaling #147

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

📋 Pull Request Information

Original PR: https://github.com/langgenius/dify-plugin-sdks/pull/103
Author: @Yeuoly
Created: 4/17/2025
Status: Merged
Merged: 4/17/2025
Merged by: @Yeuoly

Base: mainHead: optimize/enhance-json-loads


📝 Commits (2)

  • e870c81 refactor: replace json.loads with TypeAdapter for JSON validation in request readers and model
  • bf5b339 fix: linter

📊 Changes

4 files changed (+14 additions, -13 deletions)

View changed files

📝 python/dify_plugin/core/runtime.py (+3 -4)
📝 python/dify_plugin/core/server/stdio/request_reader.py (+3 -2)
📝 python/dify_plugin/core/server/tcp/request_reader.py (+3 -3)
📝 python/dify_plugin/interfaces/model/openai_compatible/llm.py (+5 -4)

📄 Description

Enhancement

It brings 4x faster performance optimization, especially llm invocation with images

image

Patches

  • https://github.com/langgenius/dify-plugin-daemon/pull/222

  • Updated JSON parsing in BackwardsInvocation, StdioRequestReader, and TCPReaderWriter to use TypeAdapter for improved validation.

  • Enhanced error handling in OAICompatLargeLanguageModel by replacing json.loads with TypeAdapter, ensuring better compliance with expected JSON schema.


🔄 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/103 **Author:** [@Yeuoly](https://github.com/Yeuoly) **Created:** 4/17/2025 **Status:** ✅ Merged **Merged:** 4/17/2025 **Merged by:** [@Yeuoly](https://github.com/Yeuoly) **Base:** `main` ← **Head:** `optimize/enhance-json-loads` --- ### 📝 Commits (2) - [`e870c81`](https://github.com/langgenius/dify-plugin-sdks/commit/e870c8131a857c6180322a6b79cf66721683fad5) refactor: replace json.loads with TypeAdapter for JSON validation in request readers and model - [`bf5b339`](https://github.com/langgenius/dify-plugin-sdks/commit/bf5b33998b2b33644cfe254b3fe0406d78794feb) fix: linter ### 📊 Changes **4 files changed** (+14 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `python/dify_plugin/core/runtime.py` (+3 -4) 📝 `python/dify_plugin/core/server/stdio/request_reader.py` (+3 -2) 📝 `python/dify_plugin/core/server/tcp/request_reader.py` (+3 -3) 📝 `python/dify_plugin/interfaces/model/openai_compatible/llm.py` (+5 -4) </details> ### 📄 Description ## Enhancement It brings 4x faster performance optimization, especially llm invocation with images <img width="1515" alt="image" src="https://github.com/user-attachments/assets/5383793d-8aae-44f0-aed1-9a5810f7dd85" /> ## Patches - https://github.com/langgenius/dify-plugin-daemon/pull/222 - Updated JSON parsing in BackwardsInvocation, StdioRequestReader, and TCPReaderWriter to use TypeAdapter for improved validation. - Enhanced error handling in OAICompatLargeLanguageModel by replacing json.loads with TypeAdapter, ensuring better compliance with expected JSON schema. --- <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:58 -05:00
yindo closed this issue 2026-02-15 21:15:58 -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#147