mirror of
				https://github.com/langgenius/dify.git
				synced 2025-11-04 12:53:38 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			46 lines
		
	
	
		
			838 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			838 B
		
	
	
	
		
			Python
		
	
	
	
	
	
from collections.abc import Sequence
 | 
						|
from typing import Literal, Optional
 | 
						|
 | 
						|
from pydantic import BaseModel, Field
 | 
						|
 | 
						|
SupportedComparisonOperator = Literal[
 | 
						|
    # for string or array
 | 
						|
    "contains",
 | 
						|
    "not contains",
 | 
						|
    "start with",
 | 
						|
    "end with",
 | 
						|
    "is",
 | 
						|
    "is not",
 | 
						|
    "empty",
 | 
						|
    "not empty",
 | 
						|
    # for number
 | 
						|
    "=",
 | 
						|
    "≠",
 | 
						|
    ">",
 | 
						|
    "<",
 | 
						|
    "≥",
 | 
						|
    "≤",
 | 
						|
    # for time
 | 
						|
    "before",
 | 
						|
    "after",
 | 
						|
]
 | 
						|
 | 
						|
 | 
						|
class Condition(BaseModel):
 | 
						|
    """
 | 
						|
    Conditon detail
 | 
						|
    """
 | 
						|
 | 
						|
    name: str
 | 
						|
    comparison_operator: SupportedComparisonOperator
 | 
						|
    value: str | Sequence[str] | None | int | float = None
 | 
						|
 | 
						|
 | 
						|
class MetadataCondition(BaseModel):
 | 
						|
    """
 | 
						|
    Metadata Condition.
 | 
						|
    """
 | 
						|
 | 
						|
    logical_operator: Optional[Literal["and", "or"]] = "and"
 | 
						|
    conditions: Optional[list[Condition]] = Field(default=None, deprecated=True)
 |