fix(archiegateway): curators resolve the default chat model per pass, not at boot (#1818)
This commit is contained in:
2 files changed
+11
-20
No files matched your search
@@ -26,11 +26,6 @@ import (
|
||||
|
||||
func (b *server) setupCurators(ctx context.Context) error {
|
||||
log := b.log.With("component", "curator")
|
||||
model, err := b.chatModels.ModelFor(ctx)
|
||||
if err != nil {
|
||||
log.WarnContext(ctx, "curators disabled: chat model unavailable; configure a chat model and restart the gateway", "err", err)
|
||||
return fmt.Errorf("curators disabled until the gateway restarts with a chat model: %w", err)
|
||||
}
|
||||
skillsRoot := b.cfg.SkillsDir
|
||||
if skillsRoot == "" {
|
||||
skillsRoot = b.cfg.WorkDir
|
||||
@@ -42,8 +37,7 @@ func (b *server) setupCurators(ctx context.Context) error {
|
||||
MemoryEngines: b.memEngines,
|
||||
Skills: skillcurator.NewStore(skillsRoot),
|
||||
Conversations: sessioncurator.NewAdapter(b.chatSessionStore, b.cfg.BotUser),
|
||||
LLM: actingPrincipalRunner{inner: curatorLLMRunner{llm: b.chatLLM, outcomes: b.providerOutcomes, usage: b.usage}, resolve: b.actingPrincipal},
|
||||
Model: model,
|
||||
LLM: actingPrincipalRunner{inner: curatorLLMRunner{llm: b.chatLLM, outcomes: b.providerOutcomes, usage: b.usage, defaultModel: b.chatModels.ModelFor}, resolve: b.actingPrincipal},
|
||||
})
|
||||
|
||||
if err := b.curatorRegistry.Register(skillcurator.New(skillcurator.DefaultInterval)); err != nil {
|
||||
@@ -153,6 +147,9 @@ type curatorLLMRunner struct {
|
||||
// older chat outcome as current.
|
||||
outcomes *providerOutcomeRecorder
|
||||
usage *usageSink
|
||||
// defaultModel resolves the model for a curator whose manifest names none,
|
||||
// at each call, so a chat model configured after boot reaches the next pass.
|
||||
defaultModel func(context.Context) (string, error)
|
||||
}
|
||||
|
||||
func (r curatorLLMRunner) Chat(ctx context.Context, req curator.ChatRequest) (curator.ChatResult, error) {
|
||||
@@ -167,6 +164,13 @@ func (r curatorLLMRunner) Chat(ctx context.Context, req curator.ChatRequest) (cu
|
||||
if llm == nil {
|
||||
return curator.ChatResult{}, fmt.Errorf("curator chat: no model runtime is configured")
|
||||
}
|
||||
if req.Model == "" {
|
||||
model, err := r.defaultModel(ctx)
|
||||
if err != nil {
|
||||
return curator.ChatResult{}, fmt.Errorf("curator chat: no chat model configured: %w", err)
|
||||
}
|
||||
req.Model = model
|
||||
}
|
||||
msgs := make([]chat.Message, 0, len(req.Messages))
|
||||
for _, m := range req.Messages {
|
||||
msgs = append(msgs, chat.Message{Role: chat.Role(m.Role), Content: m.Content})
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package archiegateway
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCuratorsWithoutChatModel(t *testing.T) {
|
||||
b := &server{log: slog.New(slog.DiscardHandler), chatModels: newChatModelManager(nil)}
|
||||
if err := b.startCurators(t.Context()); err != nil {
|
||||
t.Fatalf("unconfigured curators must not stop the gateway: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user