Documentation
¶
Index ¶
- type BaseNodeParser
- type ClassifierNodeParser
- type CodeNodeParser
- type ConditionNodeParser
- type DifyApp
- type DifyCase
- type DifyClass
- type DifyCondition
- type DifyContext
- type DifyDSL
- type DifyEdge
- type DifyEdgeData
- type DifyFeatureConfig
- type DifyFeatures
- type DifyFileUploadConfig
- type DifyGraph
- type DifyImageConfig
- type DifyModel
- type DifyNode
- type DifyNodeData
- type DifyOutput
- type DifyParser
- type DifyPosition
- type DifyPrompt
- type DifyRetrieverConfig
- type DifyTextToSpeechConfig
- type DifyUploadLimits
- type DifyVariable
- type DifyViewport
- type DifyVision
- type DifyWorkflow
- type EndNodeParser
- type IterationNodeParser
- type IterationStartNodeParser
- type LLMNodeParser
- type NodeParser
- func NewCodeNodeParser(variableRefSystem *models.VariableReferenceSystem) NodeParser
- func NewConditionNodeParser(variableRefSystem *models.VariableReferenceSystem) NodeParser
- func NewEndNodeParser(vrs *models.VariableReferenceSystem) NodeParser
- func NewIterationNodeParser(variableRefSystem *models.VariableReferenceSystem) NodeParser
- func NewIterationStartNodeParser(variableRefSystem *models.VariableReferenceSystem) NodeParser
- func NewLLMNodeParser(vrs *models.VariableReferenceSystem) NodeParser
- type NodeParserFactory
- type ParserFactory
- func (f *ParserFactory) CreateParser(nodeType string, variableRefSystem *models.VariableReferenceSystem) (NodeParser, error)
- func (f *ParserFactory) CreateParserWithFallback(nodeType string, variableRefSystem *models.VariableReferenceSystem) (NodeParser, bool, error)
- func (f *ParserFactory) GetSupportedTypes() []string
- func (f *ParserFactory) ParseNodeWithFallback(difyNode DifyNode, variableRefSystem *models.VariableReferenceSystem) (*models.Node, bool, error)
- func (f *ParserFactory) Register(nodeType string, creator func(*models.VariableReferenceSystem) NodeParser)
- type StartNodeParser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseNodeParser ¶
type BaseNodeParser struct {
// contains filtered or unexported fields
}
BaseNodeParser provides the base implementation for Dify node parsing.
func NewBaseNodeParser ¶
func NewBaseNodeParser(nodeType string, variableRefSystem *models.VariableReferenceSystem) *BaseNodeParser
func (*BaseNodeParser) GetSupportedType ¶
func (p *BaseNodeParser) GetSupportedType() string
GetSupportedType returns the supported node type.
func (*BaseNodeParser) ParseNode ¶
func (p *BaseNodeParser) ParseNode(difyNode DifyNode) (*models.Node, error)
ParseNode performs basic node parsing with default implementation.
func (*BaseNodeParser) ValidateNode ¶
func (p *BaseNodeParser) ValidateNode(difyNode DifyNode) error
ValidateNode performs basic node validation.
type ClassifierNodeParser ¶
type ClassifierNodeParser struct {
*BaseNodeParser
}
ClassifierNodeParser parses Dify classifier nodes.
func NewClassifierNodeParser ¶
func NewClassifierNodeParser(variableRefSystem *models.VariableReferenceSystem) *ClassifierNodeParser
type CodeNodeParser ¶
type CodeNodeParser struct {
*BaseNodeParser
}
CodeNodeParser parses Dify code nodes.
type ConditionNodeParser ¶
type ConditionNodeParser struct {
*BaseNodeParser
}
ConditionNodeParser parses Dify conditional branch nodes.
type DifyApp ¶
type DifyApp struct {
Name string `yaml:"name" json:"name"`
Description string `yaml:"description" json:"description"`
Icon string `yaml:"icon" json:"icon"`
IconBackground string `yaml:"icon_background" json:"icon_background"`
Mode string `yaml:"mode" json:"mode"`
UseIconAsAnswerIcon bool `yaml:"use_icon_as_answer_icon" json:"use_icon_as_answer_icon"`
}
DifyApp contains application information.
type DifyCase ¶
type DifyCase struct {
CaseID string `yaml:"case_id" json:"case_id"`
ID string `yaml:"id" json:"id"`
LogicalOperator string `yaml:"logical_operator" json:"logical_operator"`
Conditions []DifyCondition `yaml:"conditions" json:"conditions"`
}
DifyCase represents a conditional branch.
type DifyCondition ¶
type DifyCondition struct {
ID string `yaml:"id" json:"id"`
VariableSelector []string `yaml:"variable_selector" json:"variable_selector"`
ComparisonOperator string `yaml:"comparison_operator" json:"comparison_operator"`
Value string `yaml:"value" json:"value"`
VarType string `yaml:"varType" json:"varType"`
}
DifyCondition represents a condition.
type DifyContext ¶
type DifyContext struct {
Enabled bool `yaml:"enabled" json:"enabled"`
VariableSelector []string `yaml:"variable_selector,omitempty" json:"variable_selector,omitempty"`
}
DifyContext contains context configuration.
type DifyDSL ¶
type DifyDSL struct {
App DifyApp `yaml:"app" json:"app"`
Kind string `yaml:"kind" json:"kind"`
Version string `yaml:"version" json:"version"`
Workflow DifyWorkflow `yaml:"workflow" json:"workflow"`
}
DifyDSL represents the root structure of Dify DSL.
type DifyEdge ¶
type DifyEdge struct {
ID string `yaml:"id" json:"id"`
Source string `yaml:"source" json:"source"`
Target string `yaml:"target" json:"target"`
SourceHandle string `yaml:"sourceHandle,omitempty" json:"sourceHandle,omitempty"`
TargetHandle string `yaml:"targetHandle,omitempty" json:"targetHandle,omitempty"`
Type string `yaml:"type" json:"type"`
Data *DifyEdgeData `yaml:"data,omitempty" json:"data,omitempty"`
Selected bool `yaml:"selected,omitempty" json:"selected,omitempty"`
ZIndex int `yaml:"zIndex,omitempty" json:"zIndex,omitempty"`
}
DifyEdge represents a connection edge.
type DifyEdgeData ¶
type DifyEdgeData struct {
IsInLoop bool `yaml:"isInLoop,omitempty" json:"isInLoop,omitempty"`
IsInIteration bool `yaml:"isInIteration,omitempty" json:"isInIteration,omitempty"`
IterationID string `yaml:"iteration_id,omitempty" json:"iteration_id,omitempty"`
SourceType string `yaml:"sourceType,omitempty" json:"sourceType,omitempty"`
TargetType string `yaml:"targetType,omitempty" json:"targetType,omitempty"`
}
DifyEdgeData contains edge data.
type DifyFeatureConfig ¶
type DifyFeatureConfig struct {
Enabled bool `yaml:"enabled" json:"enabled"`
}
DifyFeatureConfig contains general feature configuration.
type DifyFeatures ¶
type DifyFeatures struct {
FileUpload *DifyFileUploadConfig `yaml:"file_upload,omitempty" json:"file_upload,omitempty"`
OpeningStatement string `yaml:"opening_statement,omitempty" json:"opening_statement,omitempty"`
RetrieverResource *DifyRetrieverConfig `yaml:"retriever_resource,omitempty" json:"retriever_resource,omitempty"`
SensitiveWordAvoidance *DifyFeatureConfig `yaml:"sensitive_word_avoidance,omitempty" json:"sensitive_word_avoidance,omitempty"`
SpeechToText *DifyFeatureConfig `yaml:"speech_to_text,omitempty" json:"speech_to_text,omitempty"`
SuggestedQuestions []string `yaml:"suggested_questions,omitempty" json:"suggested_questions,omitempty"`
SuggestedQuestionsAfterAnswer *DifyFeatureConfig `yaml:"suggested_questions_after_answer,omitempty" json:"suggested_questions_after_answer,omitempty"`
TextToSpeech *DifyTextToSpeechConfig `yaml:"text_to_speech,omitempty" json:"text_to_speech,omitempty"`
}
DifyFeatures contains feature configurations.
type DifyFileUploadConfig ¶
type DifyFileUploadConfig struct {
Enabled bool `yaml:"enabled" json:"enabled"`
AllowedFileExtensions []string `yaml:"allowed_file_extensions,omitempty" json:"allowed_file_extensions,omitempty"`
AllowedFileTypes []string `yaml:"allowed_file_types,omitempty" json:"allowed_file_types,omitempty"`
AllowedFileUploadMethods []string `yaml:"allowed_file_upload_methods,omitempty" json:"allowed_file_upload_methods,omitempty"`
FileUploadConfig *DifyUploadLimits `yaml:"fileUploadConfig,omitempty" json:"fileUploadConfig,omitempty"`
Image *DifyImageConfig `yaml:"image,omitempty" json:"image,omitempty"`
NumberLimits int `yaml:"number_limits,omitempty" json:"number_limits,omitempty"`
}
DifyFileUploadConfig contains file upload configuration.
type DifyGraph ¶
type DifyGraph struct {
Edges []DifyEdge `yaml:"edges" json:"edges"`
Nodes []DifyNode `yaml:"nodes" json:"nodes"`
Viewport *DifyViewport `yaml:"viewport,omitempty" json:"viewport,omitempty"`
}
DifyGraph contains graph structure.
type DifyImageConfig ¶
type DifyImageConfig struct {
Enabled bool `yaml:"enabled" json:"enabled"`
NumberLimits int `yaml:"number_limits" json:"number_limits"`
TransferMethods []string `yaml:"transfer_methods" json:"transfer_methods"`
}
DifyImageConfig contains image configuration.
type DifyModel ¶
type DifyModel struct {
Provider string `yaml:"provider" json:"provider"`
Name string `yaml:"name" json:"name"`
Mode string `yaml:"mode" json:"mode"`
CompletionParams map[string]interface{} `yaml:"completion_params,omitempty" json:"completion_params,omitempty"`
}
DifyModel contains model configuration.
type DifyNode ¶
type DifyNode struct {
ID string `yaml:"id" json:"id"`
Type string `yaml:"type" json:"type"`
Position DifyPosition `yaml:"position" json:"position"`
PositionAbsolute *DifyPosition `yaml:"positionAbsolute,omitempty" json:"positionAbsolute,omitempty"`
Width float64 `yaml:"width,omitempty" json:"width,omitempty"`
Height float64 `yaml:"height,omitempty" json:"height,omitempty"`
Selected bool `yaml:"selected,omitempty" json:"selected,omitempty"`
Draggable bool `yaml:"draggable,omitempty" json:"draggable,omitempty"`
Selectable bool `yaml:"selectable,omitempty" json:"selectable,omitempty"`
SourcePosition string `yaml:"sourcePosition,omitempty" json:"sourcePosition,omitempty"`
TargetPosition string `yaml:"targetPosition,omitempty" json:"targetPosition,omitempty"`
ZIndex int `yaml:"zIndex,omitempty" json:"zIndex,omitempty"`
ParentID string `yaml:"parentId,omitempty" json:"parentId,omitempty"`
Extent string `yaml:"extent,omitempty" json:"extent,omitempty"`
Data DifyNodeData `yaml:"data" json:"data"`
}
DifyNode represents a node.
type DifyNodeData ¶
type DifyNodeData struct {
Type string `yaml:"type" json:"type"`
Title string `yaml:"title" json:"title"`
Desc string `yaml:"desc,omitempty" json:"desc,omitempty"`
Selected bool `yaml:"selected,omitempty" json:"selected,omitempty"`
Variables []DifyVariable `yaml:"variables,omitempty" json:"variables,omitempty"`
Outputs interface{} `yaml:"outputs,omitempty" json:"outputs,omitempty"` // Supports []DifyOutput and map[string]interface{}
// LLM node specific fields
Model *DifyModel `yaml:"model,omitempty" json:"model,omitempty"`
PromptTemplate []DifyPrompt `yaml:"prompt_template,omitempty" json:"prompt_template,omitempty"`
Context *DifyContext `yaml:"context,omitempty" json:"context,omitempty"`
Vision *DifyVision `yaml:"vision,omitempty" json:"vision,omitempty"`
// Code node specific fields
Code string `yaml:"code,omitempty" json:"code,omitempty"`
CodeLanguage string `yaml:"code_language,omitempty" json:"code_language,omitempty"`
// Condition node specific fields
Cases []DifyCase `yaml:"cases,omitempty" json:"cases,omitempty"`
// Classifier node specific fields
Classes []DifyClass `yaml:"classes,omitempty" json:"classes,omitempty"`
Instruction string `yaml:"instruction,omitempty" json:"instruction,omitempty"`
Instructions string `yaml:"instructions,omitempty" json:"instructions,omitempty"`
QueryVariableSelector []string `yaml:"query_variable_selector,omitempty" json:"query_variable_selector,omitempty"`
Topics []string `yaml:"topics,omitempty" json:"topics,omitempty"`
// Iteration node specific fields
ErrorHandleMode string `yaml:"error_handle_mode,omitempty" json:"error_handle_mode,omitempty"`
IsParallel bool `yaml:"is_parallel,omitempty" json:"is_parallel,omitempty"`
IteratorInputType string `yaml:"iterator_input_type,omitempty" json:"iterator_input_type,omitempty"`
IteratorSelector []string `yaml:"iterator_selector,omitempty" json:"iterator_selector,omitempty"`
OutputSelector []string `yaml:"output_selector,omitempty" json:"output_selector,omitempty"`
OutputType string `yaml:"output_type,omitempty" json:"output_type,omitempty"`
ParallelNums int `yaml:"parallel_nums,omitempty" json:"parallel_nums,omitempty"`
StartNodeID string `yaml:"start_node_id,omitempty" json:"start_node_id,omitempty"`
// Iteration-related identifiers
IsInIteration bool `yaml:"isInIteration,omitempty" json:"isInIteration,omitempty"`
IsInLoop bool `yaml:"isInLoop,omitempty" json:"isInLoop,omitempty"`
IterationID string `yaml:"iteration_id,omitempty" json:"iteration_id,omitempty"`
}
DifyNodeData contains node data.
type DifyOutput ¶
type DifyOutput struct {
ValueSelector []string `yaml:"value_selector" json:"value_selector"`
ValueType string `yaml:"value_type" json:"value_type"`
Variable string `yaml:"variable" json:"variable"`
}
DifyOutput defines output structure.
type DifyParser ¶
type DifyParser struct {
*common.BaseParser
// contains filtered or unexported fields
}
DifyParser parses Dify DSL to unified format.
func NewDifyParser ¶
func NewDifyParser() *DifyParser
func (*DifyParser) Parse ¶
func (p *DifyParser) Parse(data []byte) (*models.UnifiedDSL, error)
Parse parses Dify DSL to unified format.
func (*DifyParser) Validate ¶
func (p *DifyParser) Validate(data []byte) error
Validate validates Dify DSL format.
type DifyPosition ¶
DifyPosition contains position coordinates.
type DifyPrompt ¶
type DifyPrompt struct {
ID string `yaml:"id" json:"id"`
Role string `yaml:"role" json:"role"`
Text string `yaml:"text" json:"text"`
}
DifyPrompt contains prompt configuration.
type DifyRetrieverConfig ¶
type DifyRetrieverConfig struct {
Enabled bool `yaml:"enabled" json:"enabled"`
}
DifyRetrieverConfig contains retriever configuration.
type DifyTextToSpeechConfig ¶
type DifyTextToSpeechConfig struct {
Enabled bool `yaml:"enabled" json:"enabled"`
Language string `yaml:"language,omitempty" json:"language,omitempty"`
Voice string `yaml:"voice,omitempty" json:"voice,omitempty"`
}
DifyTextToSpeechConfig contains text-to-speech configuration.
type DifyUploadLimits ¶
type DifyUploadLimits struct {
AudioFileSizeLimit int `yaml:"audio_file_size_limit" json:"audio_file_size_limit"`
BatchCountLimit int `yaml:"batch_count_limit" json:"batch_count_limit"`
FileSizeLimit int `yaml:"file_size_limit" json:"file_size_limit"`
ImageFileSizeLimit int `yaml:"image_file_size_limit" json:"image_file_size_limit"`
VideoFileSizeLimit int `yaml:"video_file_size_limit" json:"video_file_size_limit"`
WorkflowFileUploadLimit int `yaml:"workflow_file_upload_limit" json:"workflow_file_upload_limit"`
}
DifyUploadLimits contains upload limit configuration.
type DifyVariable ¶
type DifyVariable struct {
Label string `yaml:"label" json:"label"`
Variable string `yaml:"variable" json:"variable"`
Type string `yaml:"type" json:"type"`
ValueType string `yaml:"value_type,omitempty" json:"value_type,omitempty"`
ValueSelector []string `yaml:"value_selector,omitempty" json:"value_selector,omitempty"`
Required bool `yaml:"required" json:"required"`
MaxLength int `yaml:"max_length,omitempty" json:"max_length,omitempty"`
Options []string `yaml:"options,omitempty" json:"options,omitempty"`
}
DifyVariable defines variable structure.
type DifyViewport ¶
type DifyViewport struct {
X float64 `yaml:"x" json:"x"`
Y float64 `yaml:"y" json:"y"`
Zoom float64 `yaml:"zoom" json:"zoom"`
}
DifyViewport contains viewport configuration.
type DifyVision ¶
type DifyVision struct {
Enabled bool `yaml:"enabled" json:"enabled"`
}
DifyVision contains vision configuration.
type DifyWorkflow ¶
type DifyWorkflow struct {
ConversationVariables []interface{} `yaml:"conversation_variables" json:"conversation_variables"`
EnvironmentVariables []interface{} `yaml:"environment_variables" json:"environment_variables"`
Features DifyFeatures `yaml:"features" json:"features"`
Graph DifyGraph `yaml:"graph" json:"graph"`
}
DifyWorkflow defines workflow structure.
type EndNodeParser ¶
type EndNodeParser struct {
*BaseNodeParser
// contains filtered or unexported fields
}
EndNodeParser parses Dify end nodes.
func (*EndNodeParser) GetSupportedType ¶
func (p *EndNodeParser) GetSupportedType() string
GetSupportedType returns supported node type.
func (*EndNodeParser) ParseNode ¶
func (p *EndNodeParser) ParseNode(difyNode DifyNode) (*models.Node, error)
ParseNode parses Dify end node.
func (*EndNodeParser) SetSkippedNodeIDs ¶
func (p *EndNodeParser) SetSkippedNodeIDs(skippedNodeIDs map[string]bool)
SetSkippedNodeIDs sets skipped node IDs.
func (*EndNodeParser) ValidateNode ¶
func (p *EndNodeParser) ValidateNode(difyNode DifyNode) error
ValidateNode validates Dify end node.
type IterationNodeParser ¶
type IterationNodeParser struct {
*BaseNodeParser
}
IterationNodeParser parses iteration nodes.
type IterationStartNodeParser ¶
type IterationStartNodeParser struct {
*BaseNodeParser
}
IterationStartNodeParser parses iteration start nodes.
type LLMNodeParser ¶
type LLMNodeParser struct {
*BaseNodeParser
}
LLMNodeParser parses Dify LLM nodes.
func (*LLMNodeParser) GetSupportedType ¶
func (p *LLMNodeParser) GetSupportedType() string
GetSupportedType returns supported node type.
func (*LLMNodeParser) ParseNode ¶
func (p *LLMNodeParser) ParseNode(difyNode DifyNode) (*models.Node, error)
ParseNode parses Dify LLM node.
func (*LLMNodeParser) ValidateNode ¶
func (p *LLMNodeParser) ValidateNode(difyNode DifyNode) error
ValidateNode validates Dify LLM node.
type NodeParser ¶
type NodeParser interface {
// GetSupportedType returns the supported node type.
GetSupportedType() string
// ParseNode parses a node.
ParseNode(difyNode DifyNode) (*models.Node, error)
// ValidateNode validates node data.
ValidateNode(difyNode DifyNode) error
}
NodeParser defines the interface for Dify node parsing.
func NewCodeNodeParser ¶
func NewCodeNodeParser(variableRefSystem *models.VariableReferenceSystem) NodeParser
func NewConditionNodeParser ¶
func NewConditionNodeParser(variableRefSystem *models.VariableReferenceSystem) NodeParser
func NewEndNodeParser ¶
func NewEndNodeParser(vrs *models.VariableReferenceSystem) NodeParser
func NewIterationNodeParser ¶
func NewIterationNodeParser(variableRefSystem *models.VariableReferenceSystem) NodeParser
func NewIterationStartNodeParser ¶
func NewIterationStartNodeParser(variableRefSystem *models.VariableReferenceSystem) NodeParser
func NewLLMNodeParser ¶
func NewLLMNodeParser(vrs *models.VariableReferenceSystem) NodeParser
type NodeParserFactory ¶
type NodeParserFactory interface {
// CreateParser creates a parser.
CreateParser(nodeType string, variableRefSystem *models.VariableReferenceSystem) (NodeParser, error)
// GetSupportedTypes returns supported node types.
GetSupportedTypes() []string
}
NodeParserFactory defines the interface for node parser factory.
type ParserFactory ¶
type ParserFactory struct {
// contains filtered or unexported fields
}
ParserFactory creates Dify node parsers.
func NewParserFactory ¶
func NewParserFactory() *ParserFactory
func (*ParserFactory) CreateParser ¶
func (f *ParserFactory) CreateParser(nodeType string, variableRefSystem *models.VariableReferenceSystem) (NodeParser, error)
CreateParser creates a parser.
func (*ParserFactory) CreateParserWithFallback ¶
func (f *ParserFactory) CreateParserWithFallback(nodeType string, variableRefSystem *models.VariableReferenceSystem) (NodeParser, bool, error)
CreateParserWithFallback creates a parser with graceful fallback support
func (*ParserFactory) GetSupportedTypes ¶
func (f *ParserFactory) GetSupportedTypes() []string
GetSupportedTypes returns supported node types.
func (*ParserFactory) ParseNodeWithFallback ¶
func (f *ParserFactory) ParseNodeWithFallback(difyNode DifyNode, variableRefSystem *models.VariableReferenceSystem) (*models.Node, bool, error)
ParseNodeWithFallback parses a node using fallback mechanism
func (*ParserFactory) Register ¶
func (f *ParserFactory) Register(nodeType string, creator func(*models.VariableReferenceSystem) NodeParser)
Register registers a parser.
type StartNodeParser ¶
type StartNodeParser struct {
*BaseNodeParser
}
StartNodeParser parses start nodes.
func NewStartNodeParser ¶
func NewStartNodeParser(variableRefSystem *models.VariableReferenceSystem) *StartNodeParser