Documentation
¶
Overview ¶
Package agenttest provides in-memory implementations of agent-related interfaces for testing.
Index ¶
- func NewInMemorySession(id, appName, userID string, state session.State, events session.Events, ...) session.Session
- func NewSessionInvocationContext(ctx context.Context, sess session.Session) agent.InvocationContext
- func NewToolContext(ctx context.Context, state session.State, actions *session.EventActions, ...) tool.Context
- type InMemoryEvents
- type InMemorySession
- type InMemoryState
- type SessionInvocationContext
- func (c *SessionInvocationContext) Agent() agent.Agent
- func (c *SessionInvocationContext) Artifacts() agent.Artifacts
- func (c *SessionInvocationContext) Branch() string
- func (c *SessionInvocationContext) EndInvocation()
- func (c *SessionInvocationContext) Ended() bool
- func (c *SessionInvocationContext) InvocationID() string
- func (c *SessionInvocationContext) Memory() agent.Memory
- func (c *SessionInvocationContext) RunConfig() *agent.RunConfig
- func (c *SessionInvocationContext) Session() session.Session
- func (c *SessionInvocationContext) UserContent() *genai.Content
- type ToolContext
- func (c *ToolContext) Actions() *session.EventActions
- func (c *ToolContext) AgentName() string
- func (c *ToolContext) AppName() string
- func (c *ToolContext) Artifacts() agent.Artifacts
- func (c *ToolContext) Branch() string
- func (c *ToolContext) FunctionCallID() string
- func (c *ToolContext) InvocationID() string
- func (c *ToolContext) ReadonlyState() session.ReadonlyState
- func (c *ToolContext) SearchMemory(context.Context, string) (*memory.SearchResponse, error)
- func (c *ToolContext) SessionID() string
- func (c *ToolContext) State() session.State
- func (c *ToolContext) UserContent() *genai.Content
- func (c *ToolContext) UserID() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewInMemorySession ¶
func NewInMemorySession(id, appName, userID string, state session.State, events session.Events, lastUpdateTime time.Time) session.Session
NewInMemorySession creates a new InMemorySession with the given parameters.
func NewSessionInvocationContext ¶
NewSessionInvocationContext creates a new SessionInvocationContext with the given session.
func NewToolContext ¶
func NewToolContext(ctx context.Context, state session.State, actions *session.EventActions, funcCall string, readonlyState session.ReadonlyState) tool.Context
NewToolContext creates a new ToolContext with the given parameters.
Types ¶
type InMemoryEvents ¶
type InMemoryEvents struct {
// contains filtered or unexported fields
}
InMemoryEvents is a simple in-memory implementation of session.Events for testing.
func (*InMemoryEvents) All ¶
func (e *InMemoryEvents) All() iter.Seq[*session.Event]
All implements session.Events.
func (*InMemoryEvents) At ¶
func (e *InMemoryEvents) At(i int) *session.Event
At implements session.Events.
type InMemorySession ¶
type InMemorySession struct {
// contains filtered or unexported fields
}
InMemorySession is a simple in-memory implementation of session.Session for testing.
func (*InMemorySession) AppName ¶
func (s *InMemorySession) AppName() string
AppName implements session.Session.
func (*InMemorySession) Events ¶
func (s *InMemorySession) Events() session.Events
Events implements session.Session.
func (*InMemorySession) LastUpdateTime ¶
func (s *InMemorySession) LastUpdateTime() time.Time
LastUpdateTime implements session.Session.
func (*InMemorySession) State ¶
func (s *InMemorySession) State() session.State
State implements session.Session.
func (*InMemorySession) UserID ¶
func (s *InMemorySession) UserID() string
UserID implements session.Session.
type InMemoryState ¶
InMemoryState is a simple in-memory implementation of session.State for testing.
func NewInMemoryState ¶
func NewInMemoryState(v map[string]any) *InMemoryState
NewInMemoryState creates a new InMemoryState with the given initial values.
func (*InMemoryState) All ¶
func (s *InMemoryState) All() iter.Seq2[string, any]
All implements session.State.
func (*InMemoryState) Get ¶
func (s *InMemoryState) Get(key string) (any, error)
Get implements session.State.
func (*InMemoryState) Set ¶
func (s *InMemoryState) Set(key string, value any) error
Set implements session.State.
type SessionInvocationContext ¶
SessionInvocationContext is a simple implementation of agent.InvocationContext for testing.
func (*SessionInvocationContext) Agent ¶
func (c *SessionInvocationContext) Agent() agent.Agent
Agent implements agent.InvocationContext.
func (*SessionInvocationContext) Artifacts ¶
func (c *SessionInvocationContext) Artifacts() agent.Artifacts
Artifacts implements agent.InvocationContext.
func (*SessionInvocationContext) Branch ¶
func (c *SessionInvocationContext) Branch() string
Branch implements agent.InvocationContext.
func (*SessionInvocationContext) EndInvocation ¶
func (c *SessionInvocationContext) EndInvocation()
EndInvocation implements agent.InvocationContext.
func (*SessionInvocationContext) Ended ¶
func (c *SessionInvocationContext) Ended() bool
Ended implements agent.InvocationContext.
func (*SessionInvocationContext) InvocationID ¶
func (c *SessionInvocationContext) InvocationID() string
InvocationID implements agent.InvocationContext.
func (*SessionInvocationContext) Memory ¶
func (c *SessionInvocationContext) Memory() agent.Memory
Memory implements agent.InvocationContext.
func (*SessionInvocationContext) RunConfig ¶
func (c *SessionInvocationContext) RunConfig() *agent.RunConfig
RunConfig implements agent.InvocationContext.
func (*SessionInvocationContext) Session ¶
func (c *SessionInvocationContext) Session() session.Session
Session implements agent.InvocationContext.
func (*SessionInvocationContext) UserContent ¶
func (c *SessionInvocationContext) UserContent() *genai.Content
UserContent implements agent.InvocationContext.
type ToolContext ¶
ToolContext is a simple implementation of tool.Context for testing.
func (*ToolContext) Actions ¶
func (c *ToolContext) Actions() *session.EventActions
Actions implements tool.Context.
func (*ToolContext) AgentName ¶
func (c *ToolContext) AgentName() string
AgentName implements tool.Context.
func (*ToolContext) AppName ¶
func (c *ToolContext) AppName() string
AppName implements tool.Context.
func (*ToolContext) Artifacts ¶
func (c *ToolContext) Artifacts() agent.Artifacts
Artifacts implements tool.Context.
func (*ToolContext) FunctionCallID ¶
func (c *ToolContext) FunctionCallID() string
FunctionCallID implements tool.Context.
func (*ToolContext) InvocationID ¶
func (c *ToolContext) InvocationID() string
InvocationID implements tool.Context.
func (*ToolContext) ReadonlyState ¶
func (c *ToolContext) ReadonlyState() session.ReadonlyState
ReadonlyState implements tool.Context.
func (*ToolContext) SearchMemory ¶
func (c *ToolContext) SearchMemory(context.Context, string) (*memory.SearchResponse, error)
SearchMemory implements tool.Context.
func (*ToolContext) SessionID ¶
func (c *ToolContext) SessionID() string
SessionID implements tool.Context.
func (*ToolContext) State ¶
func (c *ToolContext) State() session.State
State implements tool.Context.
func (*ToolContext) UserContent ¶
func (c *ToolContext) UserContent() *genai.Content
UserContent implements tool.Context.