kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
feat: log warnings and errors
rodzic
c09c24ac66
commit
1273af0b06
|
@ -228,7 +228,7 @@ export class TerminalTaskTracker {
|
|||
case TaskStatus.FAILED:
|
||||
return [SYMBOLS.CROSS, red]
|
||||
case TaskStatus.RETRYING:
|
||||
return [SYMBOLS.WARNING, yellow]
|
||||
return [this.getSpinnerSymbol(), yellow]
|
||||
case TaskStatus.RUNNING:
|
||||
default:
|
||||
return [this.getSpinnerSymbol(), cyan]
|
||||
|
@ -268,20 +268,24 @@ export class TerminalTaskTracker {
|
|||
line = indent + gray(SYMBOLS.BAR_END)
|
||||
}
|
||||
|
||||
if (output) {
|
||||
if (status === TaskStatus.COMPLETED) {
|
||||
const formattedOutput = this.stringify(output)
|
||||
line +=
|
||||
indent +
|
||||
' ' +
|
||||
gray(SYMBOLS.RIGHT_ARROW + SPACE + formattedOutput)
|
||||
} else if (status === TaskStatus.FAILED) {
|
||||
line +=
|
||||
indent + ' ' + gray(SYMBOLS.RIGHT_ARROW + SPACE + red(output))
|
||||
} else if (status === TaskStatus.RETRYING) {
|
||||
line +=
|
||||
indent + ' ' + gray(SYMBOLS.RIGHT_ARROW + SPACE + yellow(output))
|
||||
}
|
||||
const formattedOutput = this.stringify(output || '')
|
||||
if (status === TaskStatus.COMPLETED) {
|
||||
line +=
|
||||
indent + ' ' + gray(SYMBOLS.RIGHT_ARROW + SPACE + formattedOutput)
|
||||
} else if (status === TaskStatus.FAILED) {
|
||||
line +=
|
||||
indent +
|
||||
' ' +
|
||||
gray(SYMBOLS.RIGHT_ARROW) +
|
||||
SPACE +
|
||||
red(formattedOutput)
|
||||
} else if (status === TaskStatus.RETRYING) {
|
||||
line +=
|
||||
indent +
|
||||
' ' +
|
||||
yellow(SYMBOLS.WARNING) +
|
||||
SPACE +
|
||||
gray(formattedOutput)
|
||||
}
|
||||
|
||||
lines.push(line)
|
||||
|
|
|
@ -360,6 +360,12 @@ export abstract class BaseTask<
|
|||
ctx.attemptNumber = err.attemptNumber + 1
|
||||
ctx.metadata.error = err
|
||||
|
||||
this._eventEmitter.emit(TaskStatus.RETRYING, {
|
||||
taskInputs: input,
|
||||
taskOutput: err,
|
||||
...ctx.metadata
|
||||
})
|
||||
|
||||
if (err instanceof errors.ZodOutputValidationError) {
|
||||
ctx.retryMessage = err.message
|
||||
return
|
||||
|
@ -383,6 +389,12 @@ export abstract class BaseTask<
|
|||
// task for now.
|
||||
return
|
||||
} else {
|
||||
this._eventEmitter.emit(TaskStatus.FAILED, {
|
||||
taskInputs: input,
|
||||
taskOutput: err,
|
||||
...ctx.metadata
|
||||
})
|
||||
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue