test

package
v1.37.6 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteSuite

func ExecuteSuite(suitesPath string) error

Types

type AgentTestRunner added in v1.19.0

type AgentTestRunner struct {
	*BaseRunner
	// contains filtered or unexported fields
}

AgentTestRunner handles the execution of agent-to-agent tests

func NewAgentTestRunner added in v1.19.0

func NewAgentTestRunner(environmentName, userID, apiKeyOverride, subdomainOverride string, logCollector *LogCollector) *AgentTestRunner

NewAgentTestRunner creates a new agent test runner

func (*AgentTestRunner) ExecuteAgentTest added in v1.19.0

func (atr *AgentTestRunner) ExecuteAgentTest(ctx context.Context, agentTest tests.AgentTest, newSessionPerTest bool) error

ExecuteAgentTest runs an agent-to-agent test

type BaseRunner added in v1.19.0

type BaseRunner struct {
	// contains filtered or unexported fields
}

BaseRunner provides common functionality for both agent runners

func NewBaseRunner added in v1.19.0

func NewBaseRunner(environmentName, userID, apiKeyOverride, subdomainOverride string, logCollector *LogCollector) *BaseRunner

NewBaseRunner creates a new base runner with common functionality

func (*BaseRunner) AddLog added in v1.19.0

func (br *BaseRunner) AddLog(message string)

AddLog logs to both the log collector and the global logger for immediate visibility

func (*BaseRunner) AddToChatHistory added in v1.19.0

func (br *BaseRunner) AddToChatHistory(role, content string)

AddToChatHistory adds a message to the chat history

func (*BaseRunner) CallOpenAI added in v1.19.0

func (br *BaseRunner) CallOpenAI(messages []ChatMessage) (string, error)

CallOpenAI makes a request to the OpenAI API

func (*BaseRunner) ExtractMessage added in v1.19.0

func (br *BaseRunner) ExtractMessage(voiceflowResponse []interact.InteractionResponse) string

ExtractMessage extracts the message text from Voiceflow response

func (*BaseRunner) GetChatHistory added in v1.19.0

func (br *BaseRunner) GetChatHistory() []ChatMessage

GetChatHistory returns the current chat history

func (*BaseRunner) HasEndResponse added in v1.34.3

func (br *BaseRunner) HasEndResponse(responses []interact.InteractionResponse) (bool, string)

HasEndResponse checks if any of the Voiceflow responses contain an "end" type trace, which indicates the agent's session has ended.

func (*BaseRunner) InteractWithVoiceflow added in v1.19.0

func (br *BaseRunner) InteractWithVoiceflow(messageType, message, environmentName, userID, apiKey string, variables map[string]interface{}) ([]interact.InteractionResponse, error)

InteractWithVoiceflow sends a message to a Voiceflow Dialog Manager

func (*BaseRunner) IsGoalAchieved added in v1.19.0

func (br *BaseRunner) IsGoalAchieved(goal string) (bool, error)

IsGoalAchieved uses OpenAI to evaluate if the goal has been achieved

func (*BaseRunner) LogOpenAIConfig added in v1.19.0

func (br *BaseRunner) LogOpenAIConfig()

LogOpenAIConfig logs the OpenAI configuration being used

func (*BaseRunner) ProcessResponses added in v1.19.0

func (br *BaseRunner) ProcessResponses(responses []interact.InteractionResponse) []interact.InteractionResponse

ProcessResponses handles multiple responses by concatenating messages. It preserves "end" type responses so callers can detect session termination.

func (*BaseRunner) SetOpenAIConfig added in v1.19.0

func (br *BaseRunner) SetOpenAIConfig(config *tests.OpenAIConfig)

SetOpenAIConfig sets the OpenAI configuration

type ChatMessage added in v1.19.0

type ChatMessage struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

ChatMessage represents a message in the conversation history

type ExecuteSuiteResult added in v1.16.0

type ExecuteSuiteResult struct {
	Success bool
	Error   error
	Logs    []string
}

ExecuteSuiteResult holds the result of test suite execution including logs

func ExecuteFromHTTPRequest added in v1.16.0

func ExecuteFromHTTPRequest(ctx context.Context, suiteReq HTTPSuiteRequest) *ExecuteSuiteResult

ExecuteFromHTTPRequest executes a test suite directly from HTTP request data

func ExecuteFromHTTPRequestWithCallback added in v1.34.0

func ExecuteFromHTTPRequestWithCallback(ctx context.Context, suiteReq HTTPSuiteRequest, onLog func(string)) *ExecuteSuiteResult

ExecuteFromHTTPRequestWithCallback executes a test suite and invokes onLog for each log line in real-time. This is used by the WebSocket handler to stream logs to the client as they happen.

type HTTPSuiteRequest added in v1.16.0

type HTTPSuiteRequest struct {
	Name                  string              `json:"name"`
	Description           string              `json:"description"`
	EnvironmentName       string              `json:"environment_name"`
	NewSessionPerTest     bool                `json:"new_session_per_test,omitempty"` // Optional flag to create a new user session for each test (default: false)
	Tests                 []HTTPTestRequest   `json:"tests"`
	ApiKey                string              `json:"api_key,omitempty"`                 // Optional token to override global.VoiceflowAPIKey
	VoiceflowSubdomain    string              `json:"voiceflow_subdomain,omitempty"`     // Optional subdomain to override global.VoiceflowSubdomain
	VoiceflowAPIURL       string              `json:"voiceflow_api_url,omitempty"`       // Optional custom base URL for the Voiceflow API (creator-api)
	VoiceflowRuntimeURL   string              `json:"voiceflow_runtime_url,omitempty"`   // Optional custom base URL for the Voiceflow general-runtime
	VoiceflowAnalyticsURL string              `json:"voiceflow_analytics_url,omitempty"` // Optional custom base URL for the Voiceflow analytics API
	OpenAIConfig          *tests.OpenAIConfig `json:"openAIConfig,omitempty"`            // Optional OpenAI configuration for agent tests
}

HTTPSuiteRequest represents a test suite from HTTP request

type HTTPTestRequest added in v1.16.0

type HTTPTestRequest struct {
	ID   string     `json:"id"`
	Test tests.Test `json:"test"`
}

HTTPTestRequest represents a test from HTTP request

type LogCollector added in v1.16.0

type LogCollector struct {
	Logs  []string
	OnLog func(message string) // Optional callback invoked on each log message (e.g. for WebSocket streaming)
}

LogCollector is used to collect logs during test execution

func (*LogCollector) AddLog added in v1.16.0

func (lc *LogCollector) AddLog(message string)

AddLog adds a log message to the collector

type VoiceflowAgentTestRunner added in v1.19.0

type VoiceflowAgentTestRunner struct {
	*BaseRunner
	// contains filtered or unexported fields
}

VoiceflowAgentTestRunner handles the execution of agent-to-agent tests using a Voiceflow agent as the tester

func NewVoiceflowAgentTestRunner added in v1.19.0

func NewVoiceflowAgentTestRunner(environmentName, userID, apiKeyOverride, subdomainOverride string, logCollector *LogCollector) *VoiceflowAgentTestRunner

NewVoiceflowAgentTestRunner creates a new Voiceflow agent test runner

func (*VoiceflowAgentTestRunner) ExecuteAgentTest added in v1.19.0

func (vatr *VoiceflowAgentTestRunner) ExecuteAgentTest(ctx context.Context, agentTest tests.AgentTest, newSessionPerTest bool) error

ExecuteAgentTest runs an agent-to-agent test using a Voiceflow agent as the tester

Jump to

Keyboard shortcuts

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