Documentation
¶
Index ¶
- type Agent
- func (agent *Agent) AddMessage(role roles.Role, content string)
- 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) GetContextSize() int
- func (agent *Agent) GetMessages() []messages.Message
- func (agent *Agent) GetModelID() string
- func (agent *Agent) GetName() string
- func (agent *Agent) Kind() agents.Kind
- func (agent *Agent) ResetMessages()
- func (agent *Agent) StopStream()
- type AgentOption
- type BaseAgent
- func (agent *BaseAgent) AddMessage(message openai.ChatCompletionMessageParamUnion)
- func (agent *BaseAgent) GenerateCompletion(messages []openai.ChatCompletionMessageParamUnion) (response string, finishReason string, err error)
- func (agent *BaseAgent) GenerateCompletionWithReasoning(messages []openai.ChatCompletionMessageParamUnion) (response string, reasoning string, finishReason string, err error)
- func (agent *BaseAgent) GenerateStreamCompletion(messages []openai.ChatCompletionMessageParamUnion, ...) (response string, finishReason string, err error)
- func (agent *BaseAgent) GenerateStreamCompletionWithReasoning(messages []openai.ChatCompletionMessageParamUnion, ...) (response string, reasoning string, finishReason string, err error)
- func (agent *BaseAgent) GetCurrentContextSize() (contextSize int)
- func (agent *BaseAgent) GetMessages() (messages []openai.ChatCompletionMessageParamUnion)
- func (agent *BaseAgent) GetStringMessages() (stringMessages []messages.Message)
- func (agent *BaseAgent) Kind() (kind agents.Kind)
- func (agent *BaseAgent) ResetMessages()
- func (agent *BaseAgent) StopStream()
- 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, ) (*Agent, error)
NewAgent creates a new simplified chat agent
func (*Agent) AddMessage ¶
AddMessage adds a message 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) GetContextSize ¶
GetContextSize returns the approximate size of the current context
func (*Agent) GetMessages ¶
GetMessages returns all conversation messages
func (*Agent) GetModelID ¶ added in v0.0.7
func (*Agent) ResetMessages ¶
func (agent *Agent) ResetMessages()
ResetMessages clears all messages except the system instruction
func (*Agent) StopStream ¶
func (agent *Agent) StopStream()
StopStream interrupts the current streaming operation
type AgentOption ¶
type AgentOption func(*BaseAgent)
type BaseAgent ¶
type BaseAgent struct {
// contains filtered or unexported fields
}
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
func (*BaseAgent) AddMessage ¶
func (agent *BaseAgent) AddMessage(message openai.ChatCompletionMessageParamUnion)
AddMessage adds a new message to the agent's message history
func (*BaseAgent) GenerateCompletion ¶
func (*BaseAgent) GenerateCompletionWithReasoning ¶
func (agent *BaseAgent) GenerateCompletionWithReasoning(messages []openai.ChatCompletionMessageParamUnion) (response string, reasoning string, finishReason string, err error)
GenerateCompletionWithReasoning executes a chat completion with the provided messages. It sends the messages to the model and returns the first choice's content and reasoning.
Parameters:
- messages: The conversation messages to send to the model
Returns:
- string: The content of the first choice from the model's response
- string: The reasoning content from the model's response
func (*BaseAgent) GenerateStreamCompletion ¶
func (*BaseAgent) GenerateStreamCompletionWithReasoning ¶
func (agent *BaseAgent) GenerateStreamCompletionWithReasoning( messages []openai.ChatCompletionMessageParamUnion, reasoningCallback func(partialReasoning string, finishReason string) error, responseCallback func(partialResponse string, finishReason string) error, ) (response string, reasoning string, finishReason string, err error)
func (*BaseAgent) GetCurrentContextSize ¶
func (*BaseAgent) GetMessages ¶
func (agent *BaseAgent) GetMessages() (messages []openai.ChatCompletionMessageParamUnion)
func (*BaseAgent) GetStringMessages ¶
GetStringMessages converts all messages to a slice of StringMessage with role and content as strings
func (*BaseAgent) ResetMessages ¶
func (agent *BaseAgent) ResetMessages()
ResetMessages clears the agent's message history except for the initial system message
func (*BaseAgent) StopStream ¶
func (agent *BaseAgent) StopStream()
StopStream interrupts the current streaming operation
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