mirror of
https://github.com/j3ssie/osmedeus.git
synced 2026-08-30 11:49:44 +02:00
- Add LLM executor supporting OpenAI vision, tool calling, embeddings, and structured outputs - Introduce event emitter/receiver workflows with deduplication and filtering (generate_event functions) - Add workflow extends/override system enabling inheritance chains and step merge modes - Update function naming to snake_case across all testdata (fileExists→file_exists, etc.) - Add comprehensive test fixtures for linter, events, CDN, step dependencies, and extends workflows
65 lines
2.4 KiB
Go
65 lines
2.4 KiB
Go
package template
|
|
|
|
// TemplateEngine defines the interface for template rendering engines.
|
|
// This allows for different implementations (standard, sharded) to be used
|
|
// interchangeably throughout the codebase.
|
|
type TemplateEngine interface {
|
|
// Render renders a template string with the given context.
|
|
// Returns the rendered string or an error if rendering fails.
|
|
Render(template string, ctx map[string]any) (string, error)
|
|
|
|
// RenderMap renders all template values in a map.
|
|
// Returns a new map with rendered values.
|
|
RenderMap(m map[string]string, ctx map[string]any) (map[string]string, error)
|
|
|
|
// RenderSlice renders all template values in a slice.
|
|
// Returns a new slice with rendered values.
|
|
RenderSlice(s []string, ctx map[string]any) ([]string, error)
|
|
|
|
// RenderSecondary renders templates using [[ ]] delimiters.
|
|
// Used for variables that only exist at runtime (e.g., foreach loop variables).
|
|
RenderSecondary(template string, ctx map[string]any) (string, error)
|
|
|
|
// HasSecondaryVariable checks if template contains [[ ]] delimiters.
|
|
HasSecondaryVariable(template string) bool
|
|
|
|
// ExecuteGenerator executes a generator function expression.
|
|
ExecuteGenerator(expr string) (string, error)
|
|
|
|
// RegisterGenerator registers a custom generator function.
|
|
RegisterGenerator(name string, fn GeneratorFunc)
|
|
}
|
|
|
|
// BatchRenderer extends TemplateEngine with batch rendering capability
|
|
// for improved performance under high concurrency.
|
|
type BatchRenderer interface {
|
|
TemplateEngine
|
|
|
|
// RenderBatch renders multiple templates in a single operation.
|
|
// This reduces lock contention by grouping templates and acquiring
|
|
// locks fewer times.
|
|
RenderBatch(requests []RenderRequest, ctx map[string]any) (map[string]string, error)
|
|
}
|
|
|
|
// RenderRequest represents a single template to render in a batch operation.
|
|
type RenderRequest struct {
|
|
// Key is the identifier for this template (e.g., field name)
|
|
Key string
|
|
|
|
// Template is the template string to render
|
|
Template string
|
|
}
|
|
|
|
// Precompiler provides access to pre-compiled templates for workflows.
|
|
type Precompiler interface {
|
|
// PrecompileWorkflow scans a workflow and pre-compiles all template strings.
|
|
PrecompileWorkflow(workflowName string, templates map[string]string) error
|
|
|
|
// GetPrecompiled retrieves a pre-compiled template if available.
|
|
// Returns nil if not found.
|
|
GetPrecompiled(workflowName, key string) any
|
|
|
|
// ClearPrecompiled removes pre-compiled templates for a workflow.
|
|
ClearPrecompiled(workflowName string)
|
|
}
|