Documentation
¶
Index ¶
- type Agent
- func (agent *Agent) AddMessage(role roles.Role, content string)
- func (agent *Agent) AddMessages(msgs []messages.Message)
- func (agent *Agent) ExportMessagesToJSON() (string, error)
- func (agent *Agent) GenerateCompletion(userMessages []messages.Message) (*CompletionResult, error)
- func (agent *Agent) GenerateCompletionWithReasoning(userMessages []messages.Message) (*ReasoningResult, error)
- func (agent *Agent) GenerateStreamCompletion(userMessages []messages.Message, callback StreamCallback) (*CompletionResult, error)
- func (agent *Agent) GenerateStreamCompletionWithReasoning(userMessages []messages.Message, reasoningCallback StreamCallback, ...) (*ReasoningResult, error)
- func (agent *Agent) GetConfig() agents.Config
- func (agent *Agent) GetContext() context.Context
- func (agent *Agent) GetContextSize() int
- func (agent *Agent) GetLastRequestJSON() (string, error)
- func (agent *Agent) GetLastRequestRawJSON() string
- func (agent *Agent) GetLastResponseJSON() (string, error)
- func (agent *Agent) GetLastResponseRawJSON() string
- func (agent *Agent) GetMessages() []messages.Message
- func (agent *Agent) GetModelConfig() models.Config
- func (agent *Agent) GetModelID() string
- func (agent *Agent) GetName() string
- func (agent *Agent) GetUserMessagePostDirectives() string
- func (agent *Agent) GetUserMessagePreDirectives() string
- func (agent *Agent) Kind() agents.Kind
- func (agent *Agent) RemoveLastNMessages(n int)
- func (agent *Agent) ResetMessages()
- func (agent *Agent) SetConfig(config agents.Config)
- func (agent *Agent) SetContext(ctx context.Context)
- func (agent *Agent) SetModelConfig(config models.Config)
- func (agent *Agent) SetSystemInstructions(instructions string)
- func (agent *Agent) SetUserMessagePostDirectives(directives string)
- func (agent *Agent) SetUserMessagePreDirectives(directives string)
- func (agent *Agent) StopStream()
- type AgentOption
- type BaseAgent
- type ChatAgentOption
- type CompletionResult
- type ReasoningResult
- type StreamCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent represents a simplified chat agent that hides OpenAI SDK details
func NewAgent ¶
func NewAgent( ctx context.Context, agentConfig agents.Config, modelConfig models.Config, opts ...ChatAgentOption, ) (*Agent, error)
NewAgent creates a new simplified chat agent
func (*Agent) AddMessage ¶
AddMessage adds a message to the conversation history
func (*Agent) AddMessages ¶ added in v1.0.4
AddMessages adds multiple messages to the conversation history
func (*Agent) ExportMessagesToJSON ¶
ExportMessagesToJSON exports the conversation history to JSON
func (*Agent) GenerateCompletion ¶
func (agent *Agent) GenerateCompletion(userMessages []messages.Message) (*CompletionResult, error)
GenerateCompletion sends messages and returns the completion result
func (*Agent) GenerateCompletionWithReasoning ¶
func (agent *Agent) GenerateCompletionWithReasoning(userMessages []messages.Message) (*ReasoningResult, error)
GenerateCompletionWithReasoning sends messages and returns the completion result with reasoning
func (*Agent) GenerateStreamCompletion ¶
func (agent *Agent) GenerateStreamCompletion( userMessages []messages.Message, callback StreamCallback, ) (*CompletionResult, error)
GenerateStreamCompletion sends messages and streams the response via callback
func (*Agent) GenerateStreamCompletionWithReasoning ¶
func (agent *Agent) GenerateStreamCompletionWithReasoning( userMessages []messages.Message, reasoningCallback StreamCallback, responseCallback StreamCallback, ) (*ReasoningResult, error)
GenerateStreamCompletionWithReasoning sends messages and streams both reasoning and response
func (*Agent) GetContext ¶ added in v1.2.2
GetContext returns the agent's context
func (*Agent) GetContextSize ¶
GetContextSize returns the approximate size of the current context
func (*Agent) GetLastRequestJSON ¶ added in v1.0.2
func (*Agent) GetLastRequestRawJSON ¶ added in v1.1.2
func (*Agent) GetLastResponseJSON ¶ added in v1.0.2
func (*Agent) GetLastResponseRawJSON ¶ added in v1.1.2
func (*Agent) GetMessages ¶
GetMessages returns all conversation messages
func (*Agent) GetModelConfig ¶ added in v1.0.8
GetModelConfig returns the model configuration
func (*Agent) GetModelID ¶ added in v0.0.7
func (*Agent) GetUserMessagePostDirectives ¶ added in v1.2.4
GetUserMessagePostDirectives returns the user message post-directives
func (*Agent) GetUserMessagePreDirectives ¶ added in v1.2.4
GetUserMessagePreDirectives returns the user message pre-directives
func (*Agent) RemoveLastNMessages ¶ added in v1.0.2
RemoveLastNMessages removes the last N messages from the conversation history It will not remove the system message
func (*Agent) ResetMessages ¶
func (agent *Agent) ResetMessages()
ResetMessages clears all messages except the system instruction
func (*Agent) SetContext ¶ added in v1.2.2
SetContext updates the agent's context
func (*Agent) SetModelConfig ¶ added in v1.0.8
SetModelConfig updates the model configuration Note: This updates the stored config but doesn't regenerate the internal OpenAI params For most parameters to take effect, create a new agent with the new config
func (*Agent) SetSystemInstructions ¶ added in v1.0.2
SetSystemInstructions updates the system instructions for the agent
func (*Agent) SetUserMessagePostDirectives ¶ added in v1.2.4
SetUserMessagePostDirectives sets the user message post-directives
func (*Agent) SetUserMessagePreDirectives ¶ added in v1.2.4
IMPORTANT:
Why having user message pre and post directives? These directives can be used to consistently frame user messages, providing context or instructions that apply to every user input. This helps guide the agent's responses in a more controlled manner.
SetUserMessagePreDirectives sets the user message pre-directives
func (*Agent) StopStream ¶
func (agent *Agent) StopStream()
StopStream interrupts the current streaming operation
type AgentOption ¶
type AgentOption func(*BaseAgent)
type BaseAgent ¶
BaseAgent wraps the shared base.Agent for chat-specific functionality
func NewBaseAgent ¶
func NewBaseAgent( ctx context.Context, agentConfig agents.Config, modelConfig openai.ChatCompletionNewParams, options ...AgentOption, ) (chatAgent *BaseAgent, err error)
NewBaseAgent creates a new ChatAgent instance using the shared base agent
type ChatAgentOption ¶ added in v1.2.9
type ChatAgentOption func(*Agent)
ChatAgentOption is a functional option for configuring an Agent during creation
func AfterCompletion ¶ added in v1.2.9
func AfterCompletion(fn func(*Agent)) ChatAgentOption
AfterCompletion sets a hook that is called after each completion (standard and streaming)
func BeforeCompletion ¶ added in v1.2.9
func BeforeCompletion(fn func(*Agent)) ChatAgentOption
BeforeCompletion sets a hook that is called before each completion (standard and streaming)
type CompletionResult ¶
CompletionResult represents the result of a chat completion
type ReasoningResult ¶
ReasoningResult represents the result of a chat completion with reasoning
type StreamCallback ¶
StreamCallback is a function called for each chunk of streaming response