utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendInstructions

func AppendInstructions(r *model.LLMRequest, instructions ...string)

func Content

func Content(ev *session.Event) *genai.Content

Content is a convenience function that returns the genai.Content in the event.

func FunctionCalls

func FunctionCalls(c *genai.Content) (ret []*genai.FunctionCall)

Belows are useful utilities that help working with genai.Content included in types.Event. TODO: Use generics. FunctionCalls extracts all FunctionCall parts from the content.

func FunctionDecls

func FunctionDecls(c *genai.GenerateContentConfig) (ret []*genai.FunctionDeclaration)

FunctionDecls extracts all Function declarations from the GenerateContentConfig.

func FunctionResponses

func FunctionResponses(c *genai.Content) (ret []*genai.FunctionResponse)

FunctionResponses extracts all FunctionResponse parts from the content.

func Must

func Must[T agent.Agent](a T, err error) T

func PopulateClientFunctionCallID

func PopulateClientFunctionCallID(c *genai.Content)

PopulateClientFunctionCallID sets the function call ID field if it is empty. Since the ID field is optional, some models don't fill the field, but the LLMAgent depends on the IDs to map FunctionCall and FunctionResponse events in the event stream.

func RemoveClientFunctionCallID

func RemoveClientFunctionCallID(c *genai.Content)

RemoveClientFunctionCallID removes the function call ID field that was set by populateClientFunctionCallID. This is necessary when FunctionCall or FunctionResponse are sent back to the model.

func TextParts

func TextParts(c *genai.Content) (ret []string)

TextParts extracts all Text parts from the content.

func ValidateMapOnSchema

func ValidateMapOnSchema(args map[string]any, schema *genai.Schema, isInput bool) error

ValidateMapOnSchema validates a map against a schema.

func ValidateOutputSchema

func ValidateOutputSchema(output string, schema *genai.Schema) (map[string]any, error)

ValidateOutputSchema validates an output JSON string against a schema.

Types

This section is empty.

Jump to

Keyboard shortcuts

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