Documentation
¶
Overview ¶
Package assist provides an embeddable Assist Mode service.
Assist is the one-shot pipeline: speech (or text) in, a single useful result out (codeword, deterministic utility, or LLM generation), with optional TTS playback. It is the middle of the three SpeechKit modes (Dictation < Assist < Voice Agent) and the right surface when the user wants an answer back, not a transcript and not a dialogue.
Construct an instance with NewService, passing a generator (LLM) and/or a tool executor plus the strict-mode policy fields from the host config.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingHandler = errors.New("speechkit assist: generator or tool executor is required") ErrCleanModeNeedsUtility = errors.New("speechkit assist: clean mode requires a matched deterministic utility") // ErrMissingExecutor is returned when a session has an active skill // context but the service was built without a ToolExecutor. ErrMissingExecutor = errors.New("speechkit assist: no tool executor configured") )
Functions ¶
This section is empty.
Types ¶
type FollowupState ¶ added in v0.40.1
FollowupState carries skill-private multi-turn state without making ToolResult non-comparable for existing SDK consumers.
func NewFollowupState ¶ added in v0.40.1
func NewFollowupState(values map[string]string) *FollowupState
func (*FollowupState) Map ¶ added in v0.40.1
func (s *FollowupState) Map() map[string]string
type GenerateFunc ¶
type GenerateFunc func(context.Context, speechkit.AssistRequest) (speechkit.AssistResult, error)
func (GenerateFunc) GenerateAssist ¶
func (f GenerateFunc) GenerateAssist(ctx context.Context, req speechkit.AssistRequest) (speechkit.AssistResult, error)
type Generator ¶
type Generator interface {
GenerateAssist(context.Context, speechkit.AssistRequest) (speechkit.AssistResult, error)
}
type Options ¶
type Options struct {
Behavior speechkit.ModeBehavior
Generator Generator
Matcher ToolMatcher
Executor ToolExecutor
SkillContexts SkillContextStore
TTSRouter TTSRouter
TTSEnabled bool
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) Process ¶
func (s *Service) Process(ctx context.Context, req speechkit.AssistRequest) (speechkit.AssistResult, error)
Example ¶
ExampleService_Process shows the Assist boundary: a deterministic utility (the ToolMatcher/ToolExecutor pair) handles what it recognises and the Generator — normally an LLM — takes everything else. The result is one-shot text; the host decides where it goes.
package main
import (
"context"
"fmt"
"log"
"strings"
"github.com/kombifyio/SpeechKit/pkg/speechkit"
"github.com/kombifyio/SpeechKit/pkg/speechkit/assist"
)
func main() {
svc, err := assist.NewService(assist.Options{
Matcher: assist.ToolMatcherFunc(func(_ context.Context, req speechkit.AssistRequest) (assist.ToolCall, bool, error) {
if strings.HasPrefix(req.Text, "uppercase ") {
return assist.ToolCall{Intent: "uppercase", Payload: strings.TrimPrefix(req.Text, "uppercase ")}, true, nil
}
return assist.ToolCall{}, false, nil
}),
Executor: assist.ToolExecutorFunc(func(_ context.Context, call assist.ToolCall) (assist.ToolResult, error) {
return assist.ToolResult{Text: strings.ToUpper(call.Payload), Surface: speechkit.AssistSurfaceReplace}, nil
}),
Generator: assist.GenerateFunc(func(_ context.Context, req speechkit.AssistRequest) (speechkit.AssistResult, error) {
return speechkit.AssistResult{Text: "llm: " + req.Text, Surface: speechkit.AssistSurfacePanel}, nil
}),
})
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
res, _ := svc.Process(ctx, speechkit.AssistRequest{Text: "uppercase make this loud", Locale: "en"})
fmt.Println(res.Text, res.Surface, res.ShortcutID)
res, _ = svc.Process(ctx, speechkit.AssistRequest{Text: "summarise the meeting", Locale: "en"})
fmt.Println(res.Text, res.Surface)
}
Output: MAKE THIS LOUD replace uppercase llm: summarise the meeting panel
Example (CleanMode) ¶
ExampleService_Process_cleanMode restricts Assist to deterministic utilities only: no request ever reaches an LLM. Hosts use this for privacy-sensitive deployments and test the branch with errors.Is.
package main
import (
"context"
"errors"
"fmt"
"log"
"github.com/kombifyio/SpeechKit/pkg/speechkit"
"github.com/kombifyio/SpeechKit/pkg/speechkit/assist"
)
func main() {
svc, err := assist.NewService(assist.Options{
Behavior: speechkit.ModeBehaviorClean,
Executor: assist.ToolExecutorFunc(func(context.Context, assist.ToolCall) (assist.ToolResult, error) {
return assist.ToolResult{}, nil
}),
})
if err != nil {
log.Fatal(err)
}
_, err = svc.Process(context.Background(), speechkit.AssistRequest{Text: "write me a poem"})
fmt.Println(errors.Is(err, assist.ErrCleanModeNeedsUtility))
}
Output: true
type SkillContext ¶ added in v0.40.1
type SkillContextStore ¶ added in v0.40.1
type ToolCall ¶
type ToolCall struct {
Intent string
Payload string
Locale string
Selection string
Context string
// Target is the host destination for insertion or execution, carried
// unchanged from the recording that triggered the call. Pass a value
// implementing [speechkit.OutputTarget]; untyped values are accepted until
// the field becomes OutputTarget in v0.69.0.
Target any
}
type ToolExecutor ¶
type ToolExecutor interface {
ExecuteTool(context.Context, ToolCall) (ToolResult, error)
}
type ToolExecutorFunc ¶
type ToolExecutorFunc func(context.Context, ToolCall) (ToolResult, error)
func (ToolExecutorFunc) ExecuteTool ¶
func (f ToolExecutorFunc) ExecuteTool(ctx context.Context, call ToolCall) (ToolResult, error)
type ToolMatcher ¶
type ToolMatcherFunc ¶
func (ToolMatcherFunc) MatchTool ¶
func (f ToolMatcherFunc) MatchTool(ctx context.Context, req speechkit.AssistRequest) (ToolCall, bool, error)
type ToolResult ¶
type ToolResult struct {
Text string
SpeakText string
Action string
Kind string
Surface speechkit.AssistSurfaceDecision
Locale string
MessageID localization.MessageID
ReasonCode string
FollowupNeeded bool
FollowupState *FollowupState
}
Directories
¶
| Path | Synopsis |
|---|---|
|
Package genkitadapter keeps Genkit-specific Assist wiring out of the core public assist package.
|
Package genkitadapter keeps Genkit-specific Assist wiring out of the core public assist package. |
|
Package skills exposes SpeechKit's Voice-Companion skill catalog — Time, Date, Math, Weather, Timer, Reminder, Wikipedia, plus a fail-closed Home Assistant boundary — as a public assist.ToolMatcher + assist.ToolExecutor pair, ready to plug into an assist.Service.
|
Package skills exposes SpeechKit's Voice-Companion skill catalog — Time, Date, Math, Weather, Timer, Reminder, Wikipedia, plus a fail-closed Home Assistant boundary — as a public assist.ToolMatcher + assist.ToolExecutor pair, ready to plug into an assist.Service. |
|
Package toolbridge adapts Assist-mode tools (assist.ToolMatcher / assist.ToolExecutor — the deterministic skill layer, e.g.
|
Package toolbridge adapts Assist-mode tools (assist.ToolMatcher / assist.ToolExecutor — the deterministic skill layer, e.g. |