chat

package
v0.0.0-...-99d71fe Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChatAgent

type ChatAgent struct {
	Name               string
	SystemInstructions string
	ModelID            string
	Messages           []*ai.Message

	Config models.ModelConfig
	// contains filtered or unexported fields
}

func NewChatAgent

func NewChatAgent(
	ctx context.Context,
	agentConfig agents.AgentConfig,
	modelConfig models.ModelConfig,
	opts ...ChatAgentOption) (*ChatAgent, error)

func (*ChatAgent) AddSystemMessage

func (agent *ChatAgent) AddSystemMessage(context string) error

func (*ChatAgent) Ask

func (agent *ChatAgent) Ask(question string) (agents.ChatResponse, error)

IMPORTANT: this function uses the chat flow WITHOUT memory

func (*ChatAgent) AskStream

func (agent *ChatAgent) AskStream(question string, callback func(agents.ChatResponse) error) (agents.ChatResponse, error)

IMPORTANT: this function uses the chat stream flow WITHOUT memory

func (*ChatAgent) AskStreamWithMemory

func (agent *ChatAgent) AskStreamWithMemory(question string, callback func(agents.ChatResponse) error) (agents.ChatResponse, error)

IMPORTANT: this function uses the chat stream flow with memory

func (*ChatAgent) AskWithMemory

func (agent *ChatAgent) AskWithMemory(question string) (agents.ChatResponse, error)

IMPORTANT: this function uses the chat flow with memory

func (*ChatAgent) GetChatFlowWithMemory

func (agent *ChatAgent) GetChatFlowWithMemory() *core.Flow[*agents.ChatRequest, *agents.ChatResponse, struct{}]

func (*ChatAgent) GetChatStreamFlowWithMemory

func (agent *ChatAgent) GetChatStreamFlowWithMemory() *core.Flow[*agents.ChatRequest, *agents.ChatResponse, agents.ChatResponse]

func (*ChatAgent) GetCurrentContextSize

func (agent *ChatAgent) GetCurrentContextSize() int

func (*ChatAgent) GetInfo

func (agent *ChatAgent) GetInfo() (agents.AgentInfo, error)

func (*ChatAgent) GetMessages

func (agent *ChatAgent) GetMessages() []*ai.Message

func (*ChatAgent) GetName

func (agent *ChatAgent) GetName() string

func (*ChatAgent) GetStreamCancel

func (agent *ChatAgent) GetStreamCancel() context.CancelFunc

func (*ChatAgent) Kind

func (agent *ChatAgent) Kind() agents.AgentKind

func (*ChatAgent) ReplaceMessagesWith

func (agent *ChatAgent) ReplaceMessagesWith(messages []*ai.Message) error

func (*ChatAgent) ReplaceMessagesWithSystemMessages

func (agent *ChatAgent) ReplaceMessagesWithSystemMessages(systemMessages []string) error

type ChatAgentOption

type ChatAgentOption func(*ChatAgent)

AgentServerOption defines a functional option for configuring the agent

func EnableChatFlow

func EnableChatFlow() ChatAgentOption

EnableChatFlowWithMemory initializes the chat flow for the agent

func EnableChatFlowWithMemory

func EnableChatFlowWithMemory() ChatAgentOption

EnableChatFlowWithMemory initializes the chat flow for the agent

func EnableChatStreamFlow

func EnableChatStreamFlow() ChatAgentOption

EnableChatStreamFlowWithMemory initializes the chat stream flow for the agent

func EnableChatStreamFlowWithMemory

func EnableChatStreamFlowWithMemory() ChatAgentOption

EnableChatStreamFlowWithMemory initializes the chat stream flow for the agent with conversational memory support.

func WithLogLevel

func WithLogLevel(level logger.LogLevel) ChatAgentOption

WithLogLevel sets the log level for the agent

func WithLogger

func WithLogger(log logger.Logger) ChatAgentOption

WithLogger sets a custom logger for the agent

func WithVerbose

func WithVerbose(verbose bool) ChatAgentOption

WithVerbose enables verbose logging (INFO level) with agent name prefix