Documentation
¶
Index ¶
- Constants
- func ParseActionKey(key string) (actionType, provider, name string, err error)
- type ActionResolver
- type Environment
- type Registry
- func (r *Registry) DefineHelper(name string, fn any) error
- func (r *Registry) DefinePartial(name string, source string) error
- func (r *Registry) ListActions() []any
- func (r *Registry) ListPlugins() []any
- func (r *Registry) ListValues() map[string]any
- func (r *Registry) LookupAction(key string) any
- func (r *Registry) LookupPlugin(name string) any
- func (r *Registry) LookupValue(name string) any
- func (r *Registry) NewChild() *Registry
- func (r *Registry) RegisterAction(key string, action any)
- func (r *Registry) RegisterPlugin(name string, p any)
- func (r *Registry) RegisterSpanProcessor(sp sdktrace.SpanProcessor)
- func (r *Registry) RegisterValue(name string, value any)
- func (r *Registry) ResolveAction(key string) any
- func (r *Registry) TracingState() *tracing.State
Constants ¶
const ( DefaultModelKey = "genkit/defaultModel" PromptDirKey = "genkit/promptDir" )
Variables ¶
This section is empty.
Functions ¶
func ParseActionKey ¶ added in v0.6.2
ParseActionKey parses an action key in the format "/<action_type>/<provider>/<name>" or "/<action_type>/<name>". Returns the action type, provider (empty string if not present), and name. If the key format is invalid, returns an error.
Types ¶
type ActionResolver ¶ added in v0.6.2
ActionResolver is a function type for resolving actions dynamically
type Environment ¶
type Environment string
An Environment is the execution context in which the program is running.
const ( EnvironmentDev Environment = "dev" // development: testing, debugging, etc. EnvironmentProd Environment = "prod" // production: user data, SLOs, etc. )
func CurrentEnvironment ¶
func CurrentEnvironment() Environment
CurentEnvironment returns the currently active environment.
type Registry ¶
type Registry struct { ActionResolver ActionResolver // Function for resolving actions dynamically. Dotprompt *dotprompt.Dotprompt // contains filtered or unexported fields }
Registry holds all registered actions and associated types, and provides methods to register, query, and look up actions.
func (*Registry) DefineHelper ¶ added in v0.5.0
DefineHelper adds a helper function to the dotprompt instance
func (*Registry) DefinePartial ¶ added in v0.5.0
DefinePartial adds the partial to the list of partials to the dotprompt instance
func (*Registry) ListActions ¶
ListActions returns a list of all registered actions. This includes actions from both the current registry and its parent hierarchy. Child registry actions take precedence over parent actions with the same key.
func (*Registry) ListPlugins ¶ added in v0.6.0
ListPlugins returns a list of all registered plugins.
func (*Registry) ListValues ¶ added in v0.5.0
ListValues returns a list of values of all registered values. This includes values from both the current registry and its parent hierarchy. Child registry values take precedence over parent values with the same key.
func (*Registry) LookupAction ¶
LookupAction returns the action for the given key. It first checks the current registry, then falls back to the parent if not found.
func (*Registry) LookupPlugin ¶ added in v0.3.0
LookupPlugin returns the plugin for the given name. It first checks the current registry, then falls back to the parent if not found. Returns nil if the plugin is not found in the registry hierarchy.
func (*Registry) LookupValue ¶ added in v0.3.0
LookupValue returns the value for the given name. It first checks the current registry, then falls back to the parent if not found. Returns nil if the value is not found in the registry hierarchy.
func (*Registry) NewChild ¶ added in v0.6.0
NewChild creates a new child registry that inherits from this registry. Child registries are cheap to create and will fall back to the parent for lookups if a value is not found in the child.
func (*Registry) RegisterAction ¶
RegisterAction records the action in the registry. It panics if an action with the same type, provider and name is already registered.
func (*Registry) RegisterPlugin ¶ added in v0.3.0
RegisterPlugin records the plugin in the registry. It panics if a plugin with the same name is already registered.
func (*Registry) RegisterSpanProcessor ¶
func (r *Registry) RegisterSpanProcessor(sp sdktrace.SpanProcessor)
func (*Registry) RegisterValue ¶ added in v0.3.0
RegisterValue records an arbitrary value in the registry. It panics if a value with the same name is already registered.
func (*Registry) ResolveAction ¶ added in v0.6.2
ResolveAction looks up an action by key. If the action is not found, it attempts dynamic resolution. Returns the action if found, or nil if not found.