feat(*): 模型生成链路 - 完善 Agnes 结果兼容、价格展示与请求日志追踪
This commit is contained in:
1 parent
2c02f5ef3d
commit
bd0d0fd4fd
20 files changed
+671
-108
No files matched your search
@@ -22,6 +22,7 @@ type taskTerminalCoordinator struct {
|
||||
logger taskLifecycleLogger
|
||||
outputs taskOutputLifecycle
|
||||
userFacingMessage func(error) string
|
||||
logFailedAttempt func(model.Task, error)
|
||||
}
|
||||
|
||||
type taskTerminalRepository interface {
|
||||
@@ -61,6 +62,7 @@ func newTaskTerminalCoordinator(s *Service) *taskTerminalCoordinator {
|
||||
logger: s,
|
||||
outputs: s,
|
||||
userFacingMessage: s.UserFacingErrorMessage,
|
||||
logFailedAttempt: s.ensureFailedProviderAttemptLogged,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +75,7 @@ func (s *Service) terminalCoordinator() *taskTerminalCoordinator {
|
||||
}
|
||||
|
||||
func (c *taskTerminalCoordinator) markPreparationFailure(task *model.Task, stage string, err error, billingUncertain bool, refundReason string) error {
|
||||
c.ensureFailedAttemptLogged(task, err)
|
||||
task.Status = model.TaskStatusFailed
|
||||
task.Stage = stage
|
||||
task.Error = c.userFacingMessage(err)
|
||||
@@ -126,6 +129,7 @@ func (c *taskTerminalCoordinator) handleExecutionFailure(task *model.Task, err e
|
||||
}
|
||||
|
||||
task.Status = model.TaskStatusFailed
|
||||
c.ensureFailedAttemptLogged(task, err)
|
||||
task.Stage = "任务失败"
|
||||
task.Error = c.userFacingMessage(err)
|
||||
if terminalErr := c.markTerminalState(task); terminalErr != nil {
|
||||
@@ -208,6 +212,13 @@ func (c *taskTerminalCoordinator) handleResultPersistenceFailure(task *model.Tas
|
||||
return false, resultErr
|
||||
}
|
||||
|
||||
func (c *taskTerminalCoordinator) ensureFailedAttemptLogged(task *model.Task, err error) {
|
||||
if c.logFailedAttempt == nil || task == nil || err == nil {
|
||||
return
|
||||
}
|
||||
c.logFailedAttempt(*task, err)
|
||||
}
|
||||
|
||||
func (c *taskTerminalCoordinator) handleSuccess(task *model.Task) error {
|
||||
c.finalizeReplay(task, model.TaskStatusSucceeded, "文本回放窗口更新失败")
|
||||
var completionErr error
|
||||
|
||||
Reference in new issue
Block a user