dify/api/models
QuantumGhost 2c1ab4879f
refactor(api): Separate SegmentType for Integer/Float to Enable Pydantic Serialization (#22025)
refactor(api): Separate SegmentType for Integer/Float to Enable Pydantic Serialization (#22025)

This PR addresses serialization issues in the VariablePool model by separating the `value_type` tags for `IntegerSegment`/`FloatSegment` and `IntegerVariable`/`FloatVariable`. Previously, both Integer and Float types shared the same `SegmentType.NUMBER` tag, causing conflicts during serialization.

Key changes:
- Introduce distinct `value_type` tags for Integer and Float segments/variables
- Add `VariableUnion` and `SegmentUnion` types for proper type discrimination
- Leverage Pydantic's discriminated union feature for seamless serialization/deserialization
- Enable accurate serialization of data structures containing these types

Closes #22024.
2025-07-16 12:31:37 +08:00
..
__init__.py feat: add MCP support (#20716) 2025-07-10 14:01:34 +08:00
_workflow_exc.py feat: Persist Variables for Enhanced Debugging Workflow (#20699) 2025-06-24 09:05:29 +08:00
account.py refactor: Use typed SQLAlchemy base model and fix type errors (#19980) 2025-05-21 15:38:03 +08:00
api_based_extension.py refactor(models): Use the SQLAlchemy base model. (#19435) 2025-05-09 13:52:05 +08:00
base.py refactor: Use typed SQLAlchemy base model and fix type errors (#19980) 2025-05-21 15:38:03 +08:00
dataset.py fix: set the func.coalesce() second paramter default value #21239 (#21240) 2025-07-01 11:31:14 +08:00
engine.py feat(api): Add image multimodal support for LLMNode (#17372) 2025-04-30 17:28:02 +08:00
enums.py moving the `MessageStatus` class from the `models.model` module to `models.enums` module (#21867) 2025-07-03 13:56:23 +08:00
model.py feat(api/repo): Allow to config repository implementation (#21458) 2025-07-14 14:54:38 +08:00
provider.py refactor: Improve model status handling and structured output (#20586) 2025-06-04 19:56:54 +08:00
source.py refactor(models): Use the SQLAlchemy base model. (#19435) 2025-05-09 13:52:05 +08:00
task.py Introduce Plugins (#13836) 2025-02-17 17:05:13 +08:00
tools.py feat: add MCP support (#20716) 2025-07-10 14:01:34 +08:00
types.py feat(api): Introduce `WorkflowDraftVariable` Model (#19737) 2025-05-19 22:59:56 +08:00
web.py Introduce Plugins (#13836) 2025-02-17 17:05:13 +08:00
workflow.py refactor(api): Separate SegmentType for Integer/Float to Enable Pydantic Serialization (#22025) 2025-07-16 12:31:37 +08:00