Documentation
¶
Overview ¶
Package testkit provides shared test doubles for harness and server integration tests.
Index ¶
- func ContentTokenEstimate(msgs []*tacklr.Message) int
- type RecordedError
- type RecordedResult
- type RecordingWriter
- func (r *RecordingWriter) FrameCount() int
- func (r *RecordingWriter) FramesAsMaps(t *testing.T) []map[string]any
- func (r *RecordingWriter) SnapshotFrames() [][]byte
- func (r *RecordingWriter) WriteError(id json.RawMessage, err error) error
- func (r *RecordingWriter) WriteFrame(data []byte) error
- func (r *RecordingWriter) WriteResult(id json.RawMessage, result any) error
- type ScriptedModel
- func (m *ScriptedModel) CompressContextWindow() error
- func (m *ScriptedModel) CountTokens(ctx context.Context, msgs []*tacklr.Message, tools []*tacklr.Tool) (int, error)
- func (m *ScriptedModel) Invoke(ctx context.Context, msgs []*tacklr.Message, tools []*tacklr.Tool) (chan tacklr.LLMResponseChunk, error)
- func (m *ScriptedModel) MaxContextWindow() (int, error)
- func (m *ScriptedModel) Reset()
- func (m *ScriptedModel) SetSystemPrompt(p string)
- func (m *ScriptedModel) SupportsMIME(mimeType string) bool
- func (m *ScriptedModel) WithApiKey(string) tacklr.InferenceStrategy
- func (m *ScriptedModel) WithModel(string) tacklr.InferenceStrategy
- func (m *ScriptedModel) WithReasoningLevel(string) tacklr.InferenceStrategy
- func (m *ScriptedModel) WithStructuredOutput(any) tacklr.InferenceStrategy
- func (m *ScriptedModel) WithURL(string) tacklr.InferenceStrategy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContentTokenEstimate ¶
ContentTokenEstimate is a shared length-based token stand-in for pressure tests.
Types ¶
type RecordedError ¶
type RecordedError struct {
ID json.RawMessage
Err error
}
RecordedError is one WriteError call.
type RecordedResult ¶
type RecordedResult struct {
ID json.RawMessage
Result any
}
RecordedResult is one WriteResult call.
type RecordingWriter ¶
type RecordingWriter struct {
Results []RecordedResult
Errors []RecordedError
Frames [][]byte
// contains filtered or unexported fields
}
RecordingWriter captures MessageWriter traffic for protocol tests.
func (*RecordingWriter) FrameCount ¶
func (r *RecordingWriter) FrameCount() int
FrameCount returns the number of recorded frames (safe for concurrent poll).
func (*RecordingWriter) FramesAsMaps ¶
func (r *RecordingWriter) FramesAsMaps(t *testing.T) []map[string]any
FramesAsMaps decodes recorded frames as JSON objects.
func (*RecordingWriter) SnapshotFrames ¶
func (r *RecordingWriter) SnapshotFrames() [][]byte
SnapshotFrames returns a copy of recorded frames (safe for concurrent poll).
func (*RecordingWriter) WriteError ¶
func (r *RecordingWriter) WriteError(id json.RawMessage, err error) error
func (*RecordingWriter) WriteFrame ¶
func (r *RecordingWriter) WriteFrame(data []byte) error
func (*RecordingWriter) WriteResult ¶
func (r *RecordingWriter) WriteResult(id json.RawMessage, result any) error
type ScriptedModel ¶
type ScriptedModel struct {
InvokeFn func(ctx context.Context, msgs []*tacklr.Message, tools []*tacklr.Tool, ch chan<- tacklr.LLMResponseChunk)
InvokeErr error
InvokeErrFn func(ctx context.Context, msgs []*tacklr.Message, tools []*tacklr.Tool) error
CountTokensFn func(ctx context.Context, msgs []*tacklr.Message, tools []*tacklr.Tool) (int, error)
CallNum atomic.Int64
SystemPrompts []string
LastInvokeMsgs []*tacklr.Message
LastInvokeTools []*tacklr.Tool
// contains filtered or unexported fields
}
ScriptedModel is a cancel-aware InferenceStrategy for tests. Default CountTokens is sum of message content lengths (not zero), so window-pressure paths can fire when MaxWindowSize is small. Override CountTokensFn to customize.
func (*ScriptedModel) CompressContextWindow ¶
func (m *ScriptedModel) CompressContextWindow() error
func (*ScriptedModel) CountTokens ¶
func (*ScriptedModel) Invoke ¶
func (m *ScriptedModel) Invoke(ctx context.Context, msgs []*tacklr.Message, tools []*tacklr.Tool) (chan tacklr.LLMResponseChunk, error)
func (*ScriptedModel) MaxContextWindow ¶
func (m *ScriptedModel) MaxContextWindow() (int, error)
func (*ScriptedModel) Reset ¶
func (m *ScriptedModel) Reset()
func (*ScriptedModel) SetSystemPrompt ¶
func (m *ScriptedModel) SetSystemPrompt(p string)
func (*ScriptedModel) SupportsMIME ¶
func (m *ScriptedModel) SupportsMIME(mimeType string) bool
func (*ScriptedModel) WithApiKey ¶
func (m *ScriptedModel) WithApiKey(string) tacklr.InferenceStrategy
func (*ScriptedModel) WithModel ¶
func (m *ScriptedModel) WithModel(string) tacklr.InferenceStrategy
func (*ScriptedModel) WithReasoningLevel ¶
func (m *ScriptedModel) WithReasoningLevel(string) tacklr.InferenceStrategy
func (*ScriptedModel) WithStructuredOutput ¶
func (m *ScriptedModel) WithStructuredOutput(any) tacklr.InferenceStrategy
func (*ScriptedModel) WithURL ¶
func (m *ScriptedModel) WithURL(string) tacklr.InferenceStrategy