[PR #1960] [MERGED] Feat/add new tool to dicom reader #2175

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

📋 Pull Request Information

Original PR: https://github.com/langgenius/dify-official-plugins/pull/1960
Author: @crazywoola
Created: 10/29/2025
Status: Merged
Merged: 10/29/2025
Merged by: @crazywoola

Base: mainHead: feat/add-new-tool-to-dicom-reader


📝 Commits (6)

📊 Changes

31 files changed (+2365 additions, -36 deletions)

View changed files

📝 tools/dicom_reader/README.md (+72 -27)
📝 tools/dicom_reader/manifest.yaml (+1 -1)
📝 tools/dicom_reader/provider/dicom_reader.yaml (+11 -0)
tools/dicom_reader/readme/README_ja_JP.md (+31 -0)
tools/dicom_reader/readme/README_pt_BR.md (+31 -0)
tools/dicom_reader/readme/README_zh_Hans.md (+31 -0)
tools/dicom_reader/tools/__init__.py (+2 -0)
tools/dicom_reader/tools/_utils.py (+280 -0)
tools/dicom_reader/tools/dicom_hu_correction.py (+78 -0)
tools/dicom_reader/tools/dicom_hu_correction.yaml (+63 -0)
tools/dicom_reader/tools/dicom_metadata.py (+107 -0)
tools/dicom_reader/tools/dicom_metadata.yaml (+38 -0)
tools/dicom_reader/tools/dicom_model_input.py (+135 -0)
tools/dicom_reader/tools/dicom_model_input.yaml (+87 -0)
tools/dicom_reader/tools/dicom_multiframe.py (+81 -0)
tools/dicom_reader/tools/dicom_multiframe.yaml (+75 -0)
tools/dicom_reader/tools/dicom_pixel_ops.py (+132 -0)
tools/dicom_reader/tools/dicom_pixel_ops.yaml (+132 -0)
tools/dicom_reader/tools/dicom_pixels.py (+86 -0)
tools/dicom_reader/tools/dicom_pixels.yaml (+63 -0)

...and 11 more files

📄 Description

Related Issues or Context

This pull request refactors the DICOM reader plugin to split the original monolithic tool into multiple focused tools, each handling a specific DICOM processing task. It introduces shared utility functions for code reuse, updates documentation to reflect the new structure, and adds new tool definitions and implementations for granular operations such as metadata extraction, pixel manipulation, and HU correction. The changes improve modularity, maintainability, and clarity for both developers and users.

Plugin refactor and multi-tool architecture:

  • The plugin is restructured from a single tool to a multi-tool plugin, with each tool (e.g., dicom_metadata, dicom_pixels, dicom_hu_correction, etc.) handling a distinct DICOM processing function. The original combined tool is retained for backward compatibility. (README.md, provider/dicom_reader.yaml) [1] [2]

Shared utilities and code reuse:

  • Common helper functions for parameter parsing, frame selection, image normalization, preview generation, and metadata extraction are centralized in tools/dicom_reader/tools/_utils.py to reduce duplication and standardize behavior across tools. (_utils.py)

New tool implementations:

  • Added new Python modules for tools such as dicom_metadata (extracts key metadata), dicom_hu_correction (applies HU correction and generates previews), with corresponding YAML definitions for parameters, descriptions, and outputs. (dicom_metadata.py, dicom_hu_correction.py, dicom_hu_correction.yaml) [1] [2] [3]

Documentation and manifest updates:

  • The README.md is rewritten to describe the new multi-tool structure, use cases, common parameters, and shared utilities. The plugin version is incremented in manifest.yaml to 0.0.2 to reflect the changes. (README.md, manifest.yaml) [1] [2]

Project structure and initialization:

  • Added __init__.py to the tools/dicom_reader/tools package for proper module initialization. (__init__.py)

This PR contains Changes to Non-Plugin

  • Documentation
  • Other

This PR contains Changes to Non-LLM Models Plugin

  • I have Run Comprehensive 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, Fix Model Parameters 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)

Dify Plugin SDK Version

  • I have Ensured dify_plugin>=0.3.0,<0.6.0 is in requirements.txt (SDK docs)

Environment Verification (If Any Code Changes)

Local Deployment Environment

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

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/1960 **Author:** [@crazywoola](https://github.com/crazywoola) **Created:** 10/29/2025 **Status:** ✅ Merged **Merged:** 10/29/2025 **Merged by:** [@crazywoola](https://github.com/crazywoola) **Base:** `main` ← **Head:** `feat/add-new-tool-to-dicom-reader` --- ### 📝 Commits (6) - [`62ef00e`](https://github.com/langgenius/dify-official-plugins/commit/62ef00e0711f267b4efd9a6bdce5ad501546a423) add some tools - [`4b1c51e`](https://github.com/langgenius/dify-official-plugins/commit/4b1c51e28178c57de3864e7417449d2999e4057e) add: more tools - [`f272e68`](https://github.com/langgenius/dify-official-plugins/commit/f272e68469106d9a27dda76eb231ae9b6d07535a) add: more tools - [`163f8ab`](https://github.com/langgenius/dify-official-plugins/commit/163f8ab1cac7f7dace3ede6be7adced765828bf9) add: more tools - [`2c203fc`](https://github.com/langgenius/dify-official-plugins/commit/2c203fcdc545e92af36ef26ec5533efe2adea24f) Update tools/dicom_reader/tools/dicom_spatial.py - [`4eda9b5`](https://github.com/langgenius/dify-official-plugins/commit/4eda9b592ad276972f3bab34fa28893ac7051e4e) Update tools/dicom_reader/tools/_utils.py ### 📊 Changes **31 files changed** (+2365 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `tools/dicom_reader/README.md` (+72 -27) 📝 `tools/dicom_reader/manifest.yaml` (+1 -1) 📝 `tools/dicom_reader/provider/dicom_reader.yaml` (+11 -0) ➕ `tools/dicom_reader/readme/README_ja_JP.md` (+31 -0) ➕ `tools/dicom_reader/readme/README_pt_BR.md` (+31 -0) ➕ `tools/dicom_reader/readme/README_zh_Hans.md` (+31 -0) ➕ `tools/dicom_reader/tools/__init__.py` (+2 -0) ➕ `tools/dicom_reader/tools/_utils.py` (+280 -0) ➕ `tools/dicom_reader/tools/dicom_hu_correction.py` (+78 -0) ➕ `tools/dicom_reader/tools/dicom_hu_correction.yaml` (+63 -0) ➕ `tools/dicom_reader/tools/dicom_metadata.py` (+107 -0) ➕ `tools/dicom_reader/tools/dicom_metadata.yaml` (+38 -0) ➕ `tools/dicom_reader/tools/dicom_model_input.py` (+135 -0) ➕ `tools/dicom_reader/tools/dicom_model_input.yaml` (+87 -0) ➕ `tools/dicom_reader/tools/dicom_multiframe.py` (+81 -0) ➕ `tools/dicom_reader/tools/dicom_multiframe.yaml` (+75 -0) ➕ `tools/dicom_reader/tools/dicom_pixel_ops.py` (+132 -0) ➕ `tools/dicom_reader/tools/dicom_pixel_ops.yaml` (+132 -0) ➕ `tools/dicom_reader/tools/dicom_pixels.py` (+86 -0) ➕ `tools/dicom_reader/tools/dicom_pixels.yaml` (+63 -0) _...and 11 more files_ </details> ### 📄 Description ## Related Issues or Context This pull request refactors the DICOM reader plugin to split the original monolithic tool into multiple focused tools, each handling a specific DICOM processing task. It introduces shared utility functions for code reuse, updates documentation to reflect the new structure, and adds new tool definitions and implementations for granular operations such as metadata extraction, pixel manipulation, and HU correction. The changes improve modularity, maintainability, and clarity for both developers and users. **Plugin refactor and multi-tool architecture:** * The plugin is restructured from a single tool to a multi-tool plugin, with each tool (e.g., `dicom_metadata`, `dicom_pixels`, `dicom_hu_correction`, etc.) handling a distinct DICOM processing function. The original combined tool is retained for backward compatibility. (`README.md`, `provider/dicom_reader.yaml`) [[1]](diffhunk://#diff-9824fdd3ab2f511ec2a38d4744169e4145634c1eba2ce7d254a637c5577755d1L1-R81) [[2]](diffhunk://#diff-cb587d670500865b366635d4d0f29bf6b1134be28591faf5f1232514528866eaR60-R70) **Shared utilities and code reuse:** * Common helper functions for parameter parsing, frame selection, image normalization, preview generation, and metadata extraction are centralized in `tools/dicom_reader/tools/_utils.py` to reduce duplication and standardize behavior across tools. (`_utils.py`) **New tool implementations:** * Added new Python modules for tools such as `dicom_metadata` (extracts key metadata), `dicom_hu_correction` (applies HU correction and generates previews), with corresponding YAML definitions for parameters, descriptions, and outputs. (`dicom_metadata.py`, `dicom_hu_correction.py`, `dicom_hu_correction.yaml`) [[1]](diffhunk://#diff-05bd19b53750500dcb4b5e2271588786b0cd5bf6816112a9634fc0b886e72285R1-R114) [[2]](diffhunk://#diff-1740c1370f732dc074661c9da9714a275236f4b9ebda5c7c08299d370e04aa3aR1-R78) [[3]](diffhunk://#diff-d265dffdebed1b901ad860ac9d9314994a131376fd2035a97a25e795237e5472R1-R63) **Documentation and manifest updates:** * The `README.md` is rewritten to describe the new multi-tool structure, use cases, common parameters, and shared utilities. The plugin version is incremented in `manifest.yaml` to 0.0.2 to reflect the changes. (`README.md`, `manifest.yaml`) [[1]](diffhunk://#diff-9824fdd3ab2f511ec2a38d4744169e4145634c1eba2ce7d254a637c5577755d1L1-R81) [[2]](diffhunk://#diff-ba31df6dc57187c4f3ab583b64e94d8fde430a441d94e8de270981eec6342ba7L1-R1) **Project structure and initialization:** * Added `__init__.py` to the `tools/dicom_reader/tools` package for proper module initialization. (`__init__.py`) ## 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 Comprehensive 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. --> - [ ] 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, Fix Model Parameters 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) - [ ] 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 --> ## Dify Plugin SDK Version - [ ] I have Ensured `dify_plugin>=0.3.0,<0.6.0` is in requirements.txt ([SDK docs](https://github.com/langgenius/dify-plugin-sdks/blob/main/python/README.md)) ## Environment Verification (If Any Code Changes) <!-- ⚠️ NOTE: At Least One Environment Must Be Tested. --> ### Local Deployment Environment - [ ] Dify Version is: <!-- Specify Your Version (e.g., 1.2.0) -->, I have Tested My Changes on Local Deployment Dify with a Clean Environment That Matches the Production Configuration. <!-- - Python Virtual Env Matching Manifest.yaml & requirements.txt - No Breaking Changes in Dify That May Affect the Testing Result --> ### SaaS Environment - [x] 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 11:16:16 -05:00
yindo closed this issue 2026-02-16 11:16:16 -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#2175