Documentation
¶
Index ¶
- type DirectChatResult
- type Playground
- func (p *Playground) AddCleanUp(cleanUp func())
- func (p *Playground) CleanUp()
- func (p *Playground) DirectChat(ctx context.Context, messages []modelrepo.Message, ...) (DirectChatResult, error)
- func (p *Playground) GetBackendService() (backendservice.Service, error)
- func (p *Playground) GetChatService(ctx context.Context) (openaichatservice.Service, error)
- func (p *Playground) GetDownloadService() (downloadservice.Service, error)
- func (p *Playground) GetEmbedService() (embedservice.Service, error)
- func (p *Playground) GetError() error
- func (p *Playground) GetEventSourceService() (eventsourceservice.Service, error)
- func (p *Playground) GetExecService(ctx context.Context) (execservice.ExecService, error)
- func (p *Playground) GetFunctionService() (functionservice.Service, error)
- func (p *Playground) GetGojaExecutor() (executor.ExecutorManager, error)
- func (p *Playground) GetGroupService() (affinitygroupservice.Service, error)
- func (p *Playground) GetHookProviderService() (hookproviderservice.Service, error)
- func (p *Playground) GetModelService() (modelservice.Service, error)
- func (p *Playground) GetProviderService() (providerservice.Service, error)
- func (p *Playground) GetStateService() (stateservice.Service, error)
- func (p *Playground) GetTaskChainService() (taskchainservice.Service, error)
- func (p *Playground) GetTasksEnvService(ctx context.Context) (execservice.TasksEnvService, error)
- func (p *Playground) StartBackgroundRoutines(ctx context.Context) *Playground
- func (p *Playground) StartGojaExecutorSync(ctx context.Context, syncInterval time.Duration) *Playground
- func (p *Playground) WaitUntilModelIsReady(ctx context.Context, backendName, modelName string) error
- func (p *Playground) WithActivityTracker(tracker libtracker.ActivityTracker) *Playground
- func (p *Playground) WithDefaultChatModel(model string, provider string, contextLength int) *Playground
- func (p *Playground) WithDefaultEmbeddingsModel(model string, provider string, contextLength int) *Playground
- func (p *Playground) WithDefaultPromptModel(model string, provider string, contextLength int) *Playground
- func (p *Playground) WithEventDispatcher(ctx context.Context, onError func(context.Context, error), ...) *Playground
- func (p *Playground) WithEventSourceInit(ctx context.Context) *Playground
- func (p *Playground) WithEventSourceService(ctx context.Context) *Playground
- func (p *Playground) WithFunctionInit(ctx context.Context) *Playground
- func (p *Playground) WithFunctionService(ctx context.Context) *Playground
- func (p *Playground) WithGeminiProvider(ctx context.Context, apiKey string, replace bool) *Playground
- func (p *Playground) WithGojaExecutor(ctx context.Context) *Playground
- func (p *Playground) WithGojaExecutorBuildIns(ctx context.Context) *Playground
- func (p *Playground) WithInternalChatExecutor(ctx context.Context, modelName string, contextLen int) *Playground
- func (p *Playground) WithInternalOllamaEmbedder(ctx context.Context, modelName string, contextLen int) *Playground
- func (p *Playground) WithInternalPromptExecutor(ctx context.Context, modelName string, contextLen int) *Playground
- func (p *Playground) WithLLMRepo() *Playground
- func (p *Playground) WithMockHookRegistry() *Playground
- func (p *Playground) WithMockTokenizer() *Playground
- func (p *Playground) WithNats(ctx context.Context) *Playground
- func (p *Playground) WithNatsReal(ctx context.Context, natsURL, natsUser, natsPassword string) *Playground
- func (p *Playground) WithOllamaBackend(ctx context.Context, name, tag string, ...) *Playground
- func (p *Playground) WithOllamaBackendReal(ctx context.Context, name, uri string, ...) *Playground
- func (p *Playground) WithOpenAIProvider(ctx context.Context, apiKey string, replace bool) *Playground
- func (p *Playground) WithPostgresReal(ctx context.Context, connStr string) *Playground
- func (p *Playground) WithPostgresTestContainer(ctx context.Context) *Playground
- func (p *Playground) WithRuntimeState(ctx context.Context, withgroups bool) *Playground
- func (p *Playground) WithSQLiteDB(ctx context.Context, path string) *Playground
- func (p *Playground) WithTokenizerService(ctx context.Context, tokenizerURL string) *Playground
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DirectChatResult ¶ added in v0.2.0
type DirectChatResult struct {
// Content is the model's text response.
Content string
// Thinking is the reasoning trace — non-empty only when thinking is enabled
// and the provider supports it (Ollama ≥0.17.5, Gemini 2.5+, vLLM with reasoning parser).
Thinking string
// ToolCalls contains any tool calls requested by the model.
ToolCalls []modelrepo.ToolCall
}
DirectChatResult is the return value from DirectChat.
type Playground ¶
type Playground struct {
Error error
// contains filtered or unexported fields
}
Playground provides a fluent API for setting up a test environment. Errors are chained, and execution stops on the first failure.
func (*Playground) AddCleanUp ¶
func (p *Playground) AddCleanUp(cleanUp func())
AddCleanUp adds a cleanup function to be called by CleanUp.
func (*Playground) CleanUp ¶
func (p *Playground) CleanUp()
CleanUp runs all registered cleanup functions.
func (*Playground) DirectChat ¶ added in v0.2.0
func (p *Playground) DirectChat(ctx context.Context, messages []modelrepo.Message, args ...modelrepo.ChatArgument) (DirectChatResult, error)
DirectChat calls the LLM repo directly with the given messages and arguments. This is the primary way to validate thinking support in the playground:
result, err := p.DirectChat(ctx,
[]modelrepo.Message{{Role: "user", Content: "explain recursion"}},
modelrepo.WithThink("high"),
)
// result.Thinking contains the chain-of-thought trace
func (*Playground) GetBackendService ¶
func (p *Playground) GetBackendService() (backendservice.Service, error)
GetBackendService returns a new backend service instance.
func (*Playground) GetChatService ¶
func (p *Playground) GetChatService(ctx context.Context) (openaichatservice.Service, error)
GetChatService returns a new chat service instance.
func (*Playground) GetDownloadService ¶
func (p *Playground) GetDownloadService() (downloadservice.Service, error)
GetDownloadService returns a new download service instance.
func (*Playground) GetEmbedService ¶
func (p *Playground) GetEmbedService() (embedservice.Service, error)
GetEmbedService returns a new embed service instance.
func (*Playground) GetError ¶
func (p *Playground) GetError() error
GetError returns the first error that occurred during the setup chain.
func (*Playground) GetEventSourceService ¶
func (p *Playground) GetEventSourceService() (eventsourceservice.Service, error)
func (*Playground) GetExecService ¶
func (p *Playground) GetExecService(ctx context.Context) (execservice.ExecService, error)
GetExecService returns a new exec service instance.
func (*Playground) GetFunctionService ¶
func (p *Playground) GetFunctionService() (functionservice.Service, error)
func (*Playground) GetGojaExecutor ¶
func (p *Playground) GetGojaExecutor() (executor.ExecutorManager, error)
GetGojaExecutor returns the Goja executor instance
func (*Playground) GetGroupService ¶
func (p *Playground) GetGroupService() (affinitygroupservice.Service, error)
GetGroupService returns a new group service instance.
func (*Playground) GetHookProviderService ¶
func (p *Playground) GetHookProviderService() (hookproviderservice.Service, error)
GetHookProviderService returns a new hook provider service instance.
func (*Playground) GetModelService ¶
func (p *Playground) GetModelService() (modelservice.Service, error)
GetModelService returns a new model service instance.
func (*Playground) GetProviderService ¶
func (p *Playground) GetProviderService() (providerservice.Service, error)
GetProviderService returns a new provider service instance.
func (*Playground) GetStateService ¶
func (p *Playground) GetStateService() (stateservice.Service, error)
GetStateService returns a new state service instance.
func (*Playground) GetTaskChainService ¶
func (p *Playground) GetTaskChainService() (taskchainservice.Service, error)
GetTaskChainService returns a new task chain service instance.
func (*Playground) GetTasksEnvService ¶
func (p *Playground) GetTasksEnvService(ctx context.Context) (execservice.TasksEnvService, error)
GetTasksEnvService returns a new tasks environment service instance.
func (*Playground) StartBackgroundRoutines ¶
func (p *Playground) StartBackgroundRoutines(ctx context.Context) *Playground
StartBackgroundRoutines starts the core background processes for backend and download cycles.
func (*Playground) StartGojaExecutorSync ¶
func (p *Playground) StartGojaExecutorSync(ctx context.Context, syncInterval time.Duration) *Playground
StartGojaExecutorSync starts the background sync for the Goja executor
func (*Playground) WaitUntilModelIsReady ¶
func (p *Playground) WaitUntilModelIsReady(ctx context.Context, backendName, modelName string) error
WaitUntilModelIsReady blocks until the specified model is available on the specified backend.
func (*Playground) WithActivityTracker ¶
func (p *Playground) WithActivityTracker(tracker libtracker.ActivityTracker) *Playground
WithActivityTracker sets the activity tracker for the playground
func (*Playground) WithDefaultChatModel ¶
func (p *Playground) WithDefaultChatModel(model string, provider string, contextLength int) *Playground
WithDefaultChatModel sets the default chat model and provider.
func (*Playground) WithDefaultEmbeddingsModel ¶
func (p *Playground) WithDefaultEmbeddingsModel(model string, provider string, contextLength int) *Playground
WithDefaultEmbeddingsModel sets the default embeddings model and provider.
func (*Playground) WithDefaultPromptModel ¶
func (p *Playground) WithDefaultPromptModel(model string, provider string, contextLength int) *Playground
WithDefaultPromptModel sets the default prompt model and provider.
func (*Playground) WithEventDispatcher ¶
func (p *Playground) WithEventDispatcher(ctx context.Context, onError func(context.Context, error), syncInterval time.Duration) *Playground
func (*Playground) WithEventSourceInit ¶
func (p *Playground) WithEventSourceInit(ctx context.Context) *Playground
func (*Playground) WithEventSourceService ¶
func (p *Playground) WithEventSourceService(ctx context.Context) *Playground
func (*Playground) WithFunctionInit ¶
func (p *Playground) WithFunctionInit(ctx context.Context) *Playground
func (*Playground) WithFunctionService ¶
func (p *Playground) WithFunctionService(ctx context.Context) *Playground
func (*Playground) WithGeminiProvider ¶
func (p *Playground) WithGeminiProvider(ctx context.Context, apiKey string, replace bool) *Playground
WithGeminiProvider configures a Gemini provider with the given API key.
func (*Playground) WithGojaExecutor ¶
func (p *Playground) WithGojaExecutor(ctx context.Context) *Playground
WithGojaExecutor initializes and returns a Goja executor
func (*Playground) WithGojaExecutorBuildIns ¶
func (p *Playground) WithGojaExecutorBuildIns(ctx context.Context) *Playground
WithGojaExecutor initializes and returns a Goja executor
func (*Playground) WithInternalChatExecutor ¶
func (p *Playground) WithInternalChatExecutor(ctx context.Context, modelName string, contextLen int) *Playground
func (*Playground) WithInternalOllamaEmbedder ¶
func (p *Playground) WithInternalOllamaEmbedder(ctx context.Context, modelName string, contextLen int) *Playground
WithInternalOllamaEmbedder initializes the internal embedding model and group.
func (*Playground) WithInternalPromptExecutor ¶
func (p *Playground) WithInternalPromptExecutor(ctx context.Context, modelName string, contextLen int) *Playground
WithInternalPromptExecutor initializes the internal task/prompt model and group.
func (*Playground) WithLLMRepo ¶
func (p *Playground) WithLLMRepo() *Playground
WithLLMRepo initializes the LLM repository.
func (*Playground) WithMockHookRegistry ¶
func (p *Playground) WithMockHookRegistry() *Playground
WithMockHookRegistry sets up a mock hook registry.
func (*Playground) WithMockTokenizer ¶
func (p *Playground) WithMockTokenizer() *Playground
WithMockTokenizer sets up a mock tokenizer.
func (*Playground) WithNats ¶
func (p *Playground) WithNats(ctx context.Context) *Playground
WithNats sets up a test NATS server.
func (*Playground) WithNatsReal ¶
func (p *Playground) WithNatsReal(ctx context.Context, natsURL, natsUser, natsPassword string) *Playground
WithNatsReal sets up a connection to a real NATS server.
func (*Playground) WithOllamaBackend ¶
func (p *Playground) WithOllamaBackend(ctx context.Context, name, tag string, assignEmbeddingModel, assignTasksModel bool) *Playground
WithOllamaBackend sets up an Ollama test instance and registers it as a backend.
func (*Playground) WithOllamaBackendReal ¶
func (p *Playground) WithOllamaBackendReal(ctx context.Context, name, uri string, assignEmbeddingModel, assignTasksModel bool) *Playground
New method for real Ollama backend (complements container-based)
func (*Playground) WithOpenAIProvider ¶
func (p *Playground) WithOpenAIProvider(ctx context.Context, apiKey string, replace bool) *Playground
WithOpenAIProvider configures an OpenAI provider with the given API key.
func (*Playground) WithPostgresReal ¶
func (p *Playground) WithPostgresReal(ctx context.Context, connStr string) *Playground
WithPostgresReal connects to a real PostgreSQL instance using the provided connection string.
func (*Playground) WithPostgresTestContainer ¶
func (p *Playground) WithPostgresTestContainer(ctx context.Context) *Playground
WithPostgresTestContainer sets up a test PostgreSQL container and initializes the DB manager.
func (*Playground) WithRuntimeState ¶
func (p *Playground) WithRuntimeState(ctx context.Context, withgroups bool) *Playground
WithRuntimeState initializes the runtime state.
func (*Playground) WithSQLiteDB ¶ added in v0.2.0
func (p *Playground) WithSQLiteDB(ctx context.Context, path string) *Playground
WithSQLiteDB initializes a lightweight in-process SQLite database. Use this for CLI-style tests that don't need a Postgres container.
func (*Playground) WithTokenizerService ¶
func (p *Playground) WithTokenizerService(ctx context.Context, tokenizerURL string) *Playground
WithTokenizerService sets up the tokenizer service from a real service URL