genaischema

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 10 Imported by: 1

README

genaischema

Go Reference

Generate genai.Schema from struct tags powered by swaggest/jsonschema-go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForValue

func ForValue(value any) (*jsonschema.Schema, error)

ForValue returns a JSON Schema for the given value, with custom struct tag post-processing applied.

func GenerateEnumContent

func GenerateEnumContent[T interface {
	~string
	Enum() []any
}](ctx context.Context, client *genai.Client, model string, contents []*genai.Content, config *genai.GenerateContentConfig) (T, error)

GenerateEnumContent returns the first enum candidate from the model using T as response schema of controlled generation. It uses ResponseSchema with text/x.enum MIME type (not ResponseJsonSchema) since the enum API requires this combination.

func GenerateObjectContent

func GenerateObjectContent[T any](ctx context.Context, client *genai.Client, model string, contents []*genai.Content, config *genai.GenerateContentConfig) (T, error)

GenerateObjectContent returns the first candidate object from the model using T as response schema of controlled generation.

func GenerateObjectContents

func GenerateObjectContents[T any](ctx context.Context, client *genai.Client, model string, contents []*genai.Content, config *genai.GenerateContentConfig) ([]T, error)

GenerateObjectContents returns the candidate objects from the model using T as response schema of controlled generation.

func GenerateRawContents

func GenerateRawContents[T any](ctx context.Context, client *genai.Client, model string, contents []*genai.Content, config *genai.GenerateContentConfig) (*genai.GenerateContentResponse, error)

GenerateRawContents returns the raw response from the model using T as response schema of controlled generation.

func GenerateTextContent

func GenerateTextContent[T any](ctx context.Context, client *genai.Client, model string, contents []*genai.Content, config *genai.GenerateContentConfig) (string, error)

GenerateTextContent returns the first text candidate from the model using T as response schema of controlled generation.

func GenerateTextContents

func GenerateTextContents[T any](ctx context.Context, client *genai.Client, model string, contents []*genai.Content, config *genai.GenerateContentConfig) ([]string, error)

GenerateTextContents returns the text candidates from the model using T as response schema of controlled generation.

func SchemaFor added in v0.2.0

func SchemaFor[T any]() (*jsonschema.Schema, error)

SchemaFor returns a JSON Schema for T, with custom struct tag post-processing applied.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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