Documentation
¶
Overview ¶
Package internal contains code that is common to all models
Index ¶
- Variables
- func ApplySchemaOverrides(schema map[string]any, o SchemaOverrides)
- func LookupOverride[T any](overrides map[string]T, provider, id string) (T, bool)
- func MergeAdjacentText(parts []*ai.Part) []*ai.Part
- func ProviderLabel(provider, name string) string
- func SchemaAt(schema map[string]any, path string) any
- func TrimProvider(provider, id string) string
- type SchemaOverrides
Constants ¶
This section is empty.
Variables ¶
var ( // BasicText describes model capabilities for text-only models. BasicText = ai.ModelSupports{ Multiturn: true, Tools: true, ToolChoice: true, SystemRole: true, Media: false, } // Multimodal describes model capabilities for multimodal models. Multimodal = ai.ModelSupports{ Multiturn: true, Tools: true, ToolChoice: true, SystemRole: true, Media: true, Constrained: ai.ConstrainedSupportNoTools, } // MultimodalNoConstrained describes model capabilities for multimodal models without native constrained generation. MultimodalNoConstrained = ai.ModelSupports{ Multiturn: true, Tools: true, ToolChoice: true, SystemRole: true, Media: true, Constrained: ai.ConstrainedSupportNone, } )
Functions ¶
func ApplySchemaOverrides ¶ added in v1.12.0
func ApplySchemaOverrides(schema map[string]any, o SchemaOverrides)
ApplySchemaOverrides applies o to schema in place.
A hidden property is replaced by the permissive `true` schema rather than deleted. Both keep it out of the dev UI, which renders only properties whose type it recognizes, but the config schema is also enforced on every request: a hidden field must still reach the plugin's own check, which names the Genkit option to use instead. Deleting it would fail validation as an unknown property, and forcing additionalProperties open to let it back through would give up rejecting real typos anywhere in that object.
A path that does not resolve is a no-op, so an entry left stale by a renamed SDK field is not fatal. Plugins assert SchemaOverrides.UnresolvedPaths is empty in a test to catch those.
func LookupOverride ¶ added in v1.12.0
LookupOverride returns the caller's entry for id in a plugin's override map, accepting the key bare or provider-prefixed since both name the same model everywhere else. id may itself carry the prefix.
func MergeAdjacentText ¶ added in v1.14.0
MergeAdjacentText merges each run of adjacent text parts, and each run of adjacent reasoning parts, into one part. Plugins call it when they fold a stream back into the final message: a stream arrives one delta at a time, and a message with one part per delta splits the answer mid-sentence for any reader of a single part.
Only bare parts merge. A part that carries metadata or custom data is a boundary and stays as it is, so a per-part provider payload never joins or moves to another part. Gemini, for one, ends a streamed text reply with an empty text part that carries the thought signature; it stays a separate part, which a middleware that rewrites text passes through untouched. Part order is kept. The input parts are not modified, because the stream callback has already handed them out.
func ProviderLabel ¶ added in v1.12.0
ProviderLabel joins a provider's display name and a model's into the label the dev UI lists a model under, e.g. "Anthropic - Claude Opus 5".
func SchemaAt ¶ added in v1.12.0
SchemaAt returns what path addresses in schema: a subschema, the `true` of a hidden property, or nil when a step does not resolve. Paths use the notation in SchemaOverrides.
func TrimProvider ¶ added in v1.12.0
TrimProvider returns id without its leading "provider/" prefix, inverting api.NewName and leaving an id that does not carry the prefix unchanged. Prefer it to api.ParseName when the provider is already known: only the prefix is removed, so an ID with slashes of its own (a tuned Vertex endpoint, say) survives intact.
Types ¶
type SchemaOverrides ¶ added in v1.12.0
type SchemaOverrides struct {
// Descriptions maps a path to the field's dev UI help text.
Descriptions map[string]string
// Hidden lists paths to keep out of the dev UI.
Hidden []string
}
SchemaOverrides is the presentation a plugin layers onto a reflected config schema: help text for the fields a caller may set, and hiding for the ones a Genkit option owns.
Paths are property names, dotted for nesting, with "[]" to enter an array's items: "temperature", "thinking.budget_tokens", "tools[].name".
func (SchemaOverrides) UnresolvedPaths ¶ added in v1.12.0
func (o SchemaOverrides) UnresolvedPaths(schema map[string]any) []string
UnresolvedPaths returns the paths in o that schema has no property for, sorted. Applying one is a silent no-op, so it is dead weight that stopped describing anything when the SDK it was written against changed.
Directories
¶
| Path | Synopsis |
|---|---|
|
anthropiclive
Package anthropiclive is the live checklist tier for the plugins built on the shared Anthropic Messages API code: the anthropic plugin and the Model Garden Claude models.
|
Package anthropiclive is the live checklist tier for the plugins built on the shared Anthropic Messages API code: the anthropic plugin and the Model Garden Claude models. |
|
Package jsonschema contains JSON Schema helpers shared by Genkit provider plugins.
|
Package jsonschema contains JSON Schema helpers shared by Genkit provider plugins. |
|
Package livetest is the shared live checklist every model plugin runs against its provider's real API.
|
Package livetest is the shared live checklist every model plugin runs against its provider's real API. |
|
Package oailive is the live checklist tier for the OpenAI-compatible plugins.
|
Package oailive is the live checklist tier for the OpenAI-compatible plugins. |
|
Package pgengine holds the connection setup the postgresql and alloydb plugins share, so their engines connect the same way.
|
Package pgengine holds the connection setup the postgresql and alloydb plugins share, so their engines connect the same way. |
|
Package systemone implements the System One protocol that decision models speak: a state and a set of typed questions go out, and one typed answer per question comes back.
|
Package systemone implements the System One protocol that decision models speak: a state and a set of typed questions go out, and one typed answer per question comes back. |
|
systemonetest
Package systemonetest provides a fake System One endpoint for the tests of the plugins that serve decision models.
|
Package systemonetest provides a fake System One endpoint for the tests of the plugins that serve decision models. |
|
Package uri extracts the content-type and data from a media part.
|
Package uri extracts the content-type and data from a media part. |