diff --git a/main.go b/main.go index 004994c..292954f 100644 --- a/main.go +++ b/main.go @@ -1019,6 +1019,32 @@ func (m *SessionManager) restoreSession(ps *agent.PersistedSession) error { // --- Completion --- +// Generate performs a stateless one-shot LLM generation. +func (m *SessionManager) Generate(prompt, system, backendName, model string) (string, *dbus.Error) { + result, err := backend.Generate(context.Background(), backend.GenerateRequest{ + Prompt: prompt, + System: system, + Backend: backendName, + Model: model, + }) + if err != nil { + return "", dbus.MakeFailedError(err) + } + return result, nil +} + +// Route classifies a task and selects the best available backend+model. +func (m *SessionManager) Route(task, backendName string) (string, *dbus.Error) { + result, err := backend.Route(context.Background(), backend.RouteRequest{ + Task: task, + Backend: backendName, + }) + if err != nil { + return "", dbus.MakeFailedError(err) + } + return fmt.Sprintf("backend=%s model=%s", result.Backend, result.Model), nil +} + // Complete performs a single-shot code completion using a dedicated copilot session. // It takes context about the cursor position and returns raw completion text. func (m *SessionManager) Complete(cwd, filePath, prefix, suffix, extraContext string) (string, *dbus.Error) { @@ -1328,6 +1354,18 @@ const introspectXML = ` + + + + + + + + + + + +