structured

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StructToJSONSchema

func StructToJSONSchema(t reflect.Type) map[string]any

Types

type Agent

type Agent[Output any] struct {
	// contains filtered or unexported fields
}

Agent represents a simplified structured data agent that hides OpenAI SDK details

func NewAgent

func NewAgent[Output any](
	ctx context.Context,
	agentConfig agents.Config,
	modelConfig models.Config,
) (*Agent[Output], error)

NewAgent creates a new simplified structured data agent

func (*Agent[Output]) AddMessage added in v0.0.9

func (agent *Agent[Output]) AddMessage(role roles.Role, content string)

func (*Agent[Output]) AddMessages added in v1.0.4

func (agent *Agent[Output]) AddMessages(msgs []messages.Message)

AddMessages adds multiple messages to the conversation history

func (*Agent[Output]) GenerateStructuredData

func (agent *Agent[Output]) GenerateStructuredData(userMessages []messages.Message) (response *Output, finishReason string, err error)

Generate sends messages and returns structured data

func (*Agent[Output]) GetConversationHistoryJSON added in v1.0.2

func (agent *Agent[Output]) GetConversationHistoryJSON() (string, error)

GetConversationHistoryJSON returns the entire conversation history as JSON

func (*Agent[Output]) GetLastRequestContextLength added in v1.0.2

func (agent *Agent[Output]) GetLastRequestContextLength() int

GetLastRequestContextLength returns the context length of the last request

func (*Agent[Output]) GetLastRequestJSON added in v1.0.2

func (agent *Agent[Output]) GetLastRequestJSON() (string, error)

GetLastRequestJSON returns the last request sent to the LLM as JSON

func (*Agent[Output]) GetLastRequestMetadata added in v1.0.2

func (agent *Agent[Output]) GetLastRequestMetadata() base.RequestMetadata

GetLastRequestMetadata returns metadata about the last request

func (*Agent[Output]) GetLastResponseJSON added in v1.0.2

func (agent *Agent[Output]) GetLastResponseJSON() (string, error)

GetLastResponseJSON returns the last response received from the LLM as JSON

func (*Agent[Output]) GetLastResponseMetadata added in v1.0.2

func (agent *Agent[Output]) GetLastResponseMetadata() base.ResponseMetadata

GetLastResponseMetadata returns metadata about the last response

func (*Agent[Output]) GetMessages added in v0.0.8

func (agent *Agent[Output]) GetMessages() []messages.Message

GetMessages returns all conversation messages

func (*Agent[Output]) GetModelID added in v0.0.7

func (agent *Agent[Output]) GetModelID() string

func (*Agent[Output]) GetName added in v0.0.3

func (agent *Agent[Output]) GetName() string

func (*Agent[Output]) GetTotalTokensUsed added in v1.0.2

func (agent *Agent[Output]) GetTotalTokensUsed() int

GetTotalTokensUsed returns the total number of tokens used since the agent was created

func (*Agent[Output]) Kind

func (agent *Agent[Output]) Kind() agents.Kind

Kind returns the agent type

func (*Agent[Output]) ResetMessages

func (agent *Agent[Output]) ResetMessages()

ResetMessages clears all messages except the system instruction

func (*Agent[Output]) ResetTelemetry added in v1.0.2

func (agent *Agent[Output]) ResetTelemetry()

ResetTelemetry resets all telemetry counters and stored data

func (*Agent[Output]) SetTelemetryCallback added in v1.0.2

func (agent *Agent[Output]) SetTelemetryCallback(callback base.TelemetryCallback)

SetTelemetryCallback sets a callback for receiving telemetry events in real-time

type AgentOption

type AgentOption[Output any] func(*BaseAgent[Output])

type BaseAgent

type BaseAgent[Output any] struct {
	*base.Agent
}

BaseAgent wraps the shared base.Agent for structured output functionality

func NewBaseAgent

func NewBaseAgent[Output any](
	ctx context.Context,
	agentConfig agents.Config,
	modelConfig openai.ChatCompletionNewParams,
	options ...AgentOption[Output],
) (structuredAgent *BaseAgent[Output], err error)

func (*BaseAgent[Output]) GenerateStructuredData

func (agent *BaseAgent[Output]) GenerateStructuredData(messages []openai.ChatCompletionMessageParamUnion) (response *Output, finishReason string, err error)

func (*BaseAgent[Output]) Kind

func (agent *BaseAgent[Output]) Kind() (kind agents.Kind)

type StructuredResult

type StructuredResult[Output any] struct {
	Data         *Output
	FinishReason string
}

StructuredResult represents the result of structured data generation

Jump to

Keyboard shortcuts

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