parser

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IFlytekNodeTypeStart      = "开始节点"
	IFlytekNodeTypeEnd        = "结束节点"
	IFlytekNodeTypeLLM        = "大模型"
	IFlytekNodeTypeCode       = "代码"
	IFlytekNodeTypeCondition  = "分支器"
	IFlytekNodeTypeClassifier = "决策"
	IFlytekNodeTypeIteration  = "迭代"
)

iFlytek node type constants

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseNodeParser

type BaseNodeParser struct {
	// contains filtered or unexported fields
}

BaseNodeParser provides common functionality for node parsing.

func NewBaseNodeParser

func NewBaseNodeParser(variableRefSystem *models.VariableReferenceSystem) *BaseNodeParser

func (*BaseNodeParser) ParseBasicNodeInfo

func (p *BaseNodeParser) ParseBasicNodeInfo(iflytekNode IFlytekNode, nodeType models.NodeType) *models.Node

ParseBasicNodeInfo parses basic node information.

func (*BaseNodeParser) ParseNodeInputs

func (p *BaseNodeParser) ParseNodeInputs(inputsData []interface{}) ([]models.Input, error)

ParseNodeInputs parses node inputs.

func (*BaseNodeParser) ParseNodeOutputs

func (p *BaseNodeParser) ParseNodeOutputs(outputsData []interface{}) ([]models.Output, error)

ParseNodeOutputs parses node outputs.

func (*BaseNodeParser) SavePlatformConfig

func (p *BaseNodeParser) SavePlatformConfig(node *models.Node, iflytekNode IFlytekNode)

SavePlatformConfig saves platform-specific configuration.

type ClassifierNodeParser

type ClassifierNodeParser struct {
	*BaseNodeParser
}

ClassifierNodeParser parses classification decision nodes.

func NewClassifierNodeParser

func NewClassifierNodeParser(variableRefSystem *models.VariableReferenceSystem) *ClassifierNodeParser

func (*ClassifierNodeParser) GetSupportedType

func (p *ClassifierNodeParser) GetSupportedType() string

GetSupportedType returns the supported node type.

func (*ClassifierNodeParser) ParseNode

func (p *ClassifierNodeParser) ParseNode(iflytekNode IFlytekNode) (*models.Node, error)

ParseNode parses a node.

func (*ClassifierNodeParser) ValidateNode

func (p *ClassifierNodeParser) ValidateNode(iflytekNode IFlytekNode) error

ValidateNode validates node data.

type CodeNodeParser

type CodeNodeParser struct {
	*BaseNodeParser
}

CodeNodeParser parses code nodes.

func NewCodeNodeParser

func NewCodeNodeParser(variableRefSystem *models.VariableReferenceSystem) *CodeNodeParser

func (*CodeNodeParser) GetSupportedType

func (p *CodeNodeParser) GetSupportedType() string

GetSupportedType returns the supported node type.

func (*CodeNodeParser) ParseNode

func (p *CodeNodeParser) ParseNode(iflytekNode IFlytekNode) (*models.Node, error)

ParseNode parses a node.

func (*CodeNodeParser) ValidateNode

func (p *CodeNodeParser) ValidateNode(iflytekNode IFlytekNode) error

ValidateNode validates node data.

type ConditionNodeParser

type ConditionNodeParser struct {
	*BaseNodeParser
	// contains filtered or unexported fields
}

ConditionNodeParser parses conditional branch nodes.

func NewConditionNodeParser

func NewConditionNodeParser(variableRefSystem *models.VariableReferenceSystem) *ConditionNodeParser

func NewConditionNodeParserWithTypeProvider

func NewConditionNodeParserWithTypeProvider(variableRefSystem *models.VariableReferenceSystem, typeProvider TypeProvider) *ConditionNodeParser

NewConditionNodeParserWithTypeProvider creates a condition node parser with TypeProvider support.

func (*ConditionNodeParser) GetSupportedType

func (p *ConditionNodeParser) GetSupportedType() string

GetSupportedType returns the supported node type.

func (*ConditionNodeParser) ParseNode

func (p *ConditionNodeParser) ParseNode(iflytekNode IFlytekNode) (*models.Node, error)

ParseNode parses a node.

func (*ConditionNodeParser) ValidateNode

func (p *ConditionNodeParser) ValidateNode(iflytekNode IFlytekNode) error

ValidateNode validates node data.

type EdgeParser

type EdgeParser struct {
	// contains filtered or unexported fields
}

EdgeParser parses edges.

func NewEdgeParser

func NewEdgeParser(variableRefSystem *models.VariableReferenceSystem) *EdgeParser

func (*EdgeParser) ParseEdge

func (p *EdgeParser) ParseEdge(iflytekEdge IFlytekEdge) (*models.Edge, error)

ParseEdge parses a single edge to unified format.

func (*EdgeParser) ParseEdges

func (p *EdgeParser) ParseEdges(iflytekEdges []interface{}) ([]models.Edge, error)

ParseEdges parses edge list.

type EndNodeParser

type EndNodeParser struct {
	*BaseNodeParser
}

EndNodeParser parses end nodes.

func NewEndNodeParser

func NewEndNodeParser(variableRefSystem *models.VariableReferenceSystem) *EndNodeParser

func (*EndNodeParser) GetSupportedType

func (p *EndNodeParser) GetSupportedType() string

GetSupportedType returns the supported node type.

func (*EndNodeParser) ParseNode

func (p *EndNodeParser) ParseNode(iflytekNode IFlytekNode) (*models.Node, error)

ParseNode parses a node.

func (*EndNodeParser) ValidateNode

func (p *EndNodeParser) ValidateNode(iflytekNode IFlytekNode) error

ValidateNode validates node data.

type IFlytekEdge

type IFlytekEdge struct {
	ID           string                 `yaml:"id"`
	Source       string                 `yaml:"source"`
	Target       string                 `yaml:"target"`
	Type         string                 `yaml:"type"`
	SourceHandle string                 `yaml:"sourceHandle,omitempty"`
	TargetHandle string                 `yaml:"targetHandle,omitempty"`
	MarkerEnd    map[string]interface{} `yaml:"markerEnd,omitempty"`
	Data         map[string]interface{} `yaml:"data,omitempty"`
	ZIndex       int                    `yaml:"zIndex,omitempty"`
}

IFlytekEdge represents iFlytek SparkAgent edge structure.

type IFlytekFlowData

type IFlytekFlowData struct {
	Nodes []IFlytekNode `yaml:"nodes"`
	Edges []IFlytekEdge `yaml:"edges"`
}

IFlytekFlowData represents iFlytek SparkAgent flowData structure.

type IFlytekFlowMeta

type IFlytekFlowMeta struct {
	Name           string `yaml:"name"`
	Description    string `yaml:"description"`
	AvatarIcon     string `yaml:"avatarIcon"`
	AvatarColor    string `yaml:"avatarColor"`
	AdvancedConfig string `yaml:"advancedConfig"`
	DSLVersion     string `yaml:"dslVersion"`
}

IFlytekFlowMeta represents iFlytek SparkAgent flowMeta structure.

type IFlytekNode

type IFlytekNode struct {
	ID               string                 `yaml:"id"`
	Type             string                 `yaml:"type"`
	Width            float64                `yaml:"width"`
	Height           float64                `yaml:"height"`
	Position         IFlytekPosition        `yaml:"position"`
	PositionAbsolute IFlytekPosition        `yaml:"positionAbsolute"`
	Dragging         bool                   `yaml:"dragging"`
	Selected         bool                   `yaml:"selected"`
	Data             map[string]interface{} `yaml:"data"`
	ParentID         string                 `yaml:"parentId,omitempty"`
	Extent           string                 `yaml:"extent,omitempty"`
	ZIndex           int                    `yaml:"zIndex,omitempty"`
	Draggable        bool                   `yaml:"draggable,omitempty"`
}

IFlytekNode represents iFlytek SparkAgent node structure.

type IFlytekParser

type IFlytekParser struct {
	*common.BaseParser
	// contains filtered or unexported fields
}

IFlytekParser provides DSL parsing for iFlytek Agent platform

func NewIFlytekParser

func NewIFlytekParser() *IFlytekParser

func (*IFlytekParser) GetOutputType

func (p *IFlytekParser) GetOutputType(nodeID, outputName string) models.UnifiedDataType

GetOutputType retrieves data type for specified node output (for condition node parsers)

func (*IFlytekParser) Parse

func (p *IFlytekParser) Parse(data []byte) (*models.UnifiedDSL, error)

Parse parses DSL data into unified format

func (*IFlytekParser) ParseFile

func (p *IFlytekParser) ParseFile(filename string) (*models.UnifiedDSL, error)

ParseFile parses DSL from file

func (*IFlytekParser) Validate

func (p *IFlytekParser) Validate(data []byte) error

Validate validates input data

type IFlytekPosition

type IFlytekPosition struct {
	X float64 `yaml:"x"`
	Y float64 `yaml:"y"`
}

IFlytekPosition contains position information.

type IFlytekReference

type IFlytekReference struct {
	OriginID   string             `yaml:"originId"`
	ID         string             `yaml:"id"`
	Label      string             `yaml:"label"`
	Type       string             `yaml:"type"`
	Value      string             `yaml:"value"`
	FileType   string             `yaml:"fileType"`
	Children   []IFlytekReference `yaml:"children,omitempty"`
	References []IFlytekReference `yaml:"references,omitempty"`
	ParentNode bool               `yaml:"parentNode,omitempty"`
}

IFlytekReference represents iFlytek SparkAgent reference structure.

type IFlytekReferenceGroup

type IFlytekReferenceGroup struct {
	Label      string             `yaml:"label"`
	Value      string             `yaml:"value"`
	ParentNode bool               `yaml:"parentNode,omitempty"`
	Children   []IFlytekReference `yaml:"children,omitempty"`
}

IFlytekReferenceGroup represents iFlytek SparkAgent reference group.

type IFlytekRootStructure

type IFlytekRootStructure struct {
	FlowMeta IFlytekFlowMeta `yaml:"flowMeta"`
	FlowData IFlytekFlowData `yaml:"flowData"`
}

IFlytekRootStructure represents iFlytek SparkAgent root structure.

type IterationNodeParser

type IterationNodeParser struct {
	*BaseNodeParser
}

IterationNodeParser parses iteration nodes.

func NewIterationNodeParser

func NewIterationNodeParser(variableRefSystem *models.VariableReferenceSystem) *IterationNodeParser

func (*IterationNodeParser) GetSupportedType

func (p *IterationNodeParser) GetSupportedType() string

GetSupportedType returns the supported node type.

func (*IterationNodeParser) ParseNode

func (p *IterationNodeParser) ParseNode(iflytekNode IFlytekNode) (*models.Node, error)

ParseNode parses a node.

func (*IterationNodeParser) ValidateNode

func (p *IterationNodeParser) ValidateNode(iflytekNode IFlytekNode) error

ValidateNode validates node data.

type LLMNodeParser

type LLMNodeParser struct {
	*BaseNodeParser
}

LLMNodeParser parses LLM nodes.

func NewLLMNodeParser

func NewLLMNodeParser(variableRefSystem *models.VariableReferenceSystem) *LLMNodeParser

func (*LLMNodeParser) GetSupportedType

func (p *LLMNodeParser) GetSupportedType() string

GetSupportedType returns the supported node type.

func (*LLMNodeParser) ParseNode

func (p *LLMNodeParser) ParseNode(iflytekNode IFlytekNode) (*models.Node, error)

ParseNode parses a node.

func (*LLMNodeParser) ValidateNode

func (p *LLMNodeParser) ValidateNode(iflytekNode IFlytekNode) error

ValidateNode validates node data.

type NodeParser

type NodeParser interface {
	// GetSupportedType returns the supported node type.
	GetSupportedType() string

	// ParseNode parses a node.
	ParseNode(iflytekNode IFlytekNode) (*models.Node, error)

	// ValidateNode validates node data.
	ValidateNode(iflytekNode IFlytekNode) error
}

NodeParser defines the interface for node parsing.

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 node parsers.

func NewParserFactory

func NewParserFactory() *ParserFactory

func (*ParserFactory) CreateParser

func (f *ParserFactory) CreateParser(nodeType string, variableRefSystem *models.VariableReferenceSystem, typeProvider TypeProvider) (NodeParser, error)

CreateParser creates a parser with TypeProvider support.

func (*ParserFactory) CreateParserWithFallback

func (f *ParserFactory) CreateParserWithFallback(nodeType string, variableRefSystem *models.VariableReferenceSystem, typeProvider TypeProvider) (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) ParseNode

func (f *ParserFactory) ParseNode(iflytekNode IFlytekNode, variableRefSystem *models.VariableReferenceSystem) (*models.Node, error)

ParseNode uses factory to parse a node (backward compatibility).

func (*ParserFactory) ParseNodeWithContext

func (f *ParserFactory) ParseNodeWithContext(iflytekNode IFlytekNode, variableRefSystem *models.VariableReferenceSystem, typeProvider TypeProvider) (*models.Node, error)

ParseNodeWithContext uses factory to parse a node with TypeProvider context.

func (*ParserFactory) ParseNodeWithFallback

func (f *ParserFactory) ParseNodeWithFallback(iflytekNode IFlytekNode, variableRefSystem *models.VariableReferenceSystem, typeProvider TypeProvider) (*models.Node, bool, error)

ParseNodeWithFallback parses a node using fallback mechanism

func (*ParserFactory) Register

func (f *ParserFactory) Register(nodeType string, creator func(*models.VariableReferenceSystem, TypeProvider) NodeParser)

Register registers a parser with TypeProvider support.

type ReferenceParser

type ReferenceParser struct {
	// contains filtered or unexported fields
}

ReferenceParser parses references.

func NewReferenceParser

func NewReferenceParser(variableRefSystem *models.VariableReferenceSystem) *ReferenceParser

func (*ReferenceParser) ParseInputReferences

func (p *ReferenceParser) ParseInputReferences(inputs []interface{}) (map[string]*models.VariableReference, error)

ParseInputReferences parses input references.

func (*ReferenceParser) ParseReferences

func (p *ReferenceParser) ParseReferences(referencesData interface{}) ([]*models.VariableReference, error)

ParseReferences parses reference list.

type StartNodeParser

type StartNodeParser struct {
	*BaseNodeParser
}

StartNodeParser parses start nodes.

func NewStartNodeParser

func NewStartNodeParser(variableRefSystem *models.VariableReferenceSystem) *StartNodeParser

func (*StartNodeParser) GetSupportedType

func (p *StartNodeParser) GetSupportedType() string

GetSupportedType returns the supported node type.

func (*StartNodeParser) ParseNode

func (p *StartNodeParser) ParseNode(iflytekNode IFlytekNode) (*models.Node, error)

ParseNode parses a node.

func (*StartNodeParser) ValidateNode

func (p *StartNodeParser) ValidateNode(iflytekNode IFlytekNode) error

ValidateNode validates node data.

type TypeProvider

type TypeProvider interface {
	GetOutputType(nodeID, outputName string) models.UnifiedDataType
}

TypeProvider provides node output type querying interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL