From 8bd59a65090157a6f80069e81bfb08fb641b24da Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Sat, 18 Jul 2026 17:21:50 +0200 Subject: [PATCH] dbus: add Generate and Route methods Generate: stateless one-shot LLM call (prompt, system, backend, model) Route: classify task, return best backend+model from available models Both delegate to core backend.Generate() and backend.Route(). KDE frontends can use Route as a preprocessing step before CreateSession. --- main.go | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) 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 = ` + + + + + + + + + + + +