Changeset 0.29.2 (#197)
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit is contained in:
@@ -25,6 +25,7 @@ import (
|
||||
"git.gobha.me/xcaliber/chat-switchboard/notifications"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/providers"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/routing"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/sandbox"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/storage"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/store"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/tools"
|
||||
@@ -57,6 +58,7 @@ type CompletionHandler struct {
|
||||
healthStore HealthStatusQuerier // health status queries for routing (v0.22.2, nil = disabled)
|
||||
router *routing.Evaluator // routing policy evaluator (v0.22.2, nil = disabled)
|
||||
filterChain *filters.Chain // pre-completion filter chain (v0.29.0, nil = disabled)
|
||||
runner *sandbox.Runner // v0.29.2: Starlark extension tool dispatch (nil = disabled)
|
||||
}
|
||||
|
||||
// HealthRecorder is the interface for recording provider call outcomes.
|
||||
@@ -101,6 +103,16 @@ func (h *CompletionHandler) SetFilterChain(fc *filters.Chain) {
|
||||
h.filterChain = fc
|
||||
}
|
||||
|
||||
// SetRunner attaches the Starlark sandbox runner for extension tool dispatch (v0.29.2).
|
||||
func (h *CompletionHandler) SetRunner(r *sandbox.Runner) {
|
||||
h.runner = r
|
||||
}
|
||||
|
||||
// buildExtToolMap returns the extension tool map for the current user.
|
||||
func (h *CompletionHandler) buildExtToolMap(ctx context.Context, userID string) map[string]*store.PackageRegistration {
|
||||
return BuildExtToolMap(ctx, h.stores, userID)
|
||||
}
|
||||
|
||||
// evaluateRouting applies routing policies to select the best provider config
|
||||
// for this request. Returns the winning config details and a routing decision
|
||||
// for observability. If routing is disabled or no policies match, returns
|
||||
@@ -846,7 +858,8 @@ func (h *CompletionHandler) multiModelStream(
|
||||
}
|
||||
|
||||
// Stream this model's response using the shared streaming core
|
||||
result := streamModelResponse(c, provider, providerCfg, &provReq, model, providerID, target.DisplayName, userID, channelID, personaID, workspaceID, configID, teamID, h.hub, h.health)
|
||||
multiExtTools := h.buildExtToolMap(c.Request.Context(), userID)
|
||||
result := streamModelResponse(c, provider, providerCfg, &provReq, model, providerID, target.DisplayName, userID, channelID, personaID, workspaceID, configID, teamID, h.hub, h.health, h.runner, multiExtTools)
|
||||
|
||||
// Persist assistant message with model attribution
|
||||
if result.Content != "" {
|
||||
@@ -955,7 +968,8 @@ func (h *CompletionHandler) streamCompletion(
|
||||
hooks.PreRequest(cfg, &req)
|
||||
}
|
||||
|
||||
result := streamWithToolLoop(c, provider, cfg, &req, model, providerID, userID, channelID, personaID, workspaceID, configID, teamID, h.hub, h.health)
|
||||
extTools := h.buildExtToolMap(c.Request.Context(), userID)
|
||||
result := streamWithToolLoop(c, provider, cfg, &req, model, providerID, userID, channelID, personaID, workspaceID, configID, teamID, h.hub, h.health, h.runner, extTools)
|
||||
|
||||
// Persist assistant response
|
||||
if result.Content != "" {
|
||||
@@ -995,6 +1009,7 @@ func (h *CompletionHandler) syncCompletion(
|
||||
hooks.PreRequest(cfg, &req)
|
||||
}
|
||||
|
||||
extTools := h.buildExtToolMap(c.Request.Context(), userID)
|
||||
result := CoreToolLoop(c.Request.Context(), LoopConfig{
|
||||
Provider: provider,
|
||||
Cfg: cfg,
|
||||
@@ -1013,6 +1028,8 @@ func (h *CompletionHandler) syncCompletion(
|
||||
ConfigID: configID,
|
||||
Budget: LoopBudget{},
|
||||
Streaming: false,
|
||||
Runner: h.runner,
|
||||
ExtTools: extTools,
|
||||
}, accumSink{})
|
||||
|
||||
// Provider error
|
||||
|
||||
Reference in New Issue
Block a user