fix(gateway): read task logs through state store
This commit is contained in:
1 parent
e9e47bc408
commit
8f7c14e5c6
4 files changed
+9
-20
No files matched your search
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/domain/storecontract"
|
||||
"github.com/samcharles93/archie-core/internal/domain/taskactions"
|
||||
"github.com/samcharles93/archie-core/internal/domain/workflow"
|
||||
"github.com/samcharles93/archie-core/internal/gateway"
|
||||
@@ -115,7 +116,7 @@ func (a chatTaskListerAdapter) ListChatTasks(ctx context.Context, identity strin
|
||||
// identity through the tool input.
|
||||
type chatTaskLogReaderAdapter struct {
|
||||
tasks func(context.Context, int64) (*workflow.Task, error)
|
||||
taskLogs *logging.TaskRegistry
|
||||
taskLogs storecontract.TaskLogStore
|
||||
}
|
||||
|
||||
func (a chatTaskLogReaderAdapter) ReadChatTaskLogs(
|
||||
@@ -141,19 +142,9 @@ func (a chatTaskLogReaderAdapter) ReadChatTaskLogs(
|
||||
if attempt <= 0 {
|
||||
attempt = task.Attempt
|
||||
}
|
||||
path := a.taskLogs.Path(taskID, attempt)
|
||||
if path == "" {
|
||||
return gateway.ChatTaskLogResult{Attempt: attempt, Entries: []gateway.ChatTaskLogEntry{}}, nil
|
||||
}
|
||||
|
||||
page, err := logging.Page(path, logging.Query{
|
||||
Component: q.Component,
|
||||
Contains: q.Contains,
|
||||
Levels: q.Levels,
|
||||
Since: q.Since,
|
||||
Until: q.Until,
|
||||
Limit: q.Limit,
|
||||
}, q.AfterID)
|
||||
page, err := a.taskLogs.TaskLog(ctx, taskID, attempt, logging.Query{
|
||||
Component: q.Component, Contains: q.Contains, Levels: q.Levels, Since: q.Since, Until: q.Until, Limit: q.Limit, BeforeID: q.AfterID,
|
||||
})
|
||||
if err != nil {
|
||||
return gateway.ChatTaskLogResult{}, err
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ func (b *server) setupGatewayChat(ctx context.Context, actor gateway.ChatTaskAct
|
||||
LLM: b.chatLLM, ChatModels: b.chatModels, ToolReg: b.toolReg,
|
||||
Soul: b.soul, ChatTasks: b.chatTasks,
|
||||
ChatTaskLister: chatTaskListerAdapter{tasks: b.stateStore.Tasks},
|
||||
ChatTaskLogs: chatTaskLogReaderAdapter{tasks: b.stateStore.TaskByID, taskLogs: b.taskLogs},
|
||||
ChatTaskLogs: chatTaskLogReaderAdapter{tasks: b.stateStore.TaskByID, taskLogs: b.stateStore},
|
||||
ChatTaskActor: actor,
|
||||
DefaultChatIdentity: b.defaultChatIdentity,
|
||||
Bus: b.bus, Log: b.log,
|
||||
|
||||
@@ -33,7 +33,6 @@ import (
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/secretengine"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/staterpc"
|
||||
"github.com/samcharles93/archie-core/internal/infrastructure/taskactions"
|
||||
"github.com/samcharles93/archie-core/internal/logging"
|
||||
"github.com/samcharles93/archie-core/internal/plugin"
|
||||
"github.com/samcharles93/archie-core/internal/ratelimit"
|
||||
"github.com/samcharles93/archie-core/internal/releaseupdate"
|
||||
@@ -63,7 +62,6 @@ type server struct {
|
||||
cfgHolder *config.Holder
|
||||
cfgPath string
|
||||
log *slog.Logger
|
||||
taskLogs *logging.TaskRegistry
|
||||
|
||||
secrets *secret.Registry
|
||||
engines *secretengine.Runner
|
||||
@@ -167,7 +165,7 @@ func (b *server) loadConfig(cfgPath, overlayPath string) error {
|
||||
b.catalog = modelcatalog.NewCatalog(cfgPath)
|
||||
b.cfgHolder = config.NewHolder(b.cfg)
|
||||
logs := servicekit.Logging(b.cfg, "gateway")
|
||||
b.log, b.taskLogs = logs.Log, logs.TaskLogs
|
||||
b.log = logs.Log
|
||||
b.addCleanup(func() { _ = logs.Closer.Close() })
|
||||
b.secrets = secret.NewRegistry()
|
||||
return nil
|
||||
|
||||
@@ -106,8 +106,8 @@ type ChatTaskLogQuery struct {
|
||||
// time disables the bound.
|
||||
Until time.Time
|
||||
// AfterID is the byte-offset cursor returned in the previous page's
|
||||
// Cursor field. Zero means "start at the beginning of the scanned
|
||||
// window". The model treats this as opaque and just passes it back
|
||||
// Cursor field, used to read the next older page. Zero selects the most
|
||||
// recent page. The model treats this as opaque and just passes it back
|
||||
// unchanged; the byte offset is not intended to be human-readable.
|
||||
AfterID int64
|
||||
// Limit caps returned entries.
|
||||
|
||||
Reference in new issue
Block a user