dify/api/core/prompt
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
..
entities chore(api/core): apply ruff reformatting (#7624) 2024-09-10 17:00:20 +08:00
prompt_templates Enhance Code Consistency Across Repository with `.editorconfig` (#19023) 2025-04-29 18:04:33 +08:00
utils feat(api/repo): Allow to config repository implementation (#21458) 2025-07-14 14:54:38 +08:00
__init__.py FEAT: NEW WORKFLOW ENGINE (#3160) 2024-04-08 18:51:46 +08:00
advanced_prompt_transform.py refactor(api): Separate SegmentType for Integer/Float to Enable Pydantic Serialization (#22025) 2025-07-16 12:31:37 +08:00
agent_history_prompt_transform.py feat: mypy for all type check (#10921) 2024-12-24 18:38:51 +08:00
prompt_transform.py feat: mypy for all type check (#10921) 2024-12-24 18:38:51 +08:00
simple_prompt_transform.py fix: Update prompt message content types to use Literal and add union type for content (#17136) 2025-04-22 16:17:55 +08:00