Skip to content

Commit 7f7b8ff

Browse files
committed
allow accessing cost during steps
1 parent 4f4eaaf commit 7f7b8ff

File tree

4 files changed

+0
-40
lines changed

4 files changed

+0
-40
lines changed

docs/concepts/history.mdx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,6 @@ history.addEventListener('step-response', (event) => {
225225
console.log('Step completed:', event.historyId)
226226
})
227227

228-
history.addEventListener('step-error', (event) => {
229-
console.error('Step failed:', event.error)
230-
})
231-
232228
history.addEventListener('data-reference-added', (event) => {
233229
console.log('Data added to history')
234230
})

packages/prai/src/console-logger.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,17 +150,6 @@ export function consoleLogger(history: History, options?: { abort?: AbortSignal
150150
{ signal: abortSignal },
151151
)
152152

153-
history.addEventListener(
154-
'step-error',
155-
(event) => {
156-
logHeader(event.historyId, 'Step Error', Date.now(), colors.error)
157-
console.error(' Error:')
158-
console.log(' ' + colors.error(event.error))
159-
logSeparator()
160-
},
161-
{ signal: abortSignal },
162-
)
163-
164153
history.addEventListener(
165154
'subtask-start',
166155
(event) => {

packages/prai/src/history.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export type BuildReference = () => string
6969
export type EventMap = {
7070
'step-request': StepRequestEvent
7171
'step-response': StepResponseEvent
72-
'step-error': StepErrorEvent
7372
'subtask-start': SubtaskStartEvent
7473
'data-reference-added': DataReferenceAddedEvent
7574
'subtask-response-referenced': SubtaskReponseReferencedEvent
@@ -87,12 +86,6 @@ export type StepResponseEvent = {
8786
message: Message
8887
}
8988

90-
export type StepErrorEvent = {
91-
type: 'step-error'
92-
historyId: string
93-
error: string
94-
}
95-
9689
export type SubtaskStartEvent = {
9790
type: 'subtask-start-event'
9891
historyId: string
@@ -139,9 +132,6 @@ export class History {
139132
private cost: number | undefined = 0
140133

141134
getCost() {
142-
if (this.currentlyExecutingStepId != null) {
143-
throw new Error('unable to compute the costs while still executing a step')
144-
}
145135
return this.cost
146136
}
147137

@@ -221,11 +211,6 @@ export class History {
221211
return stepId
222212
}
223213

224-
onStepError(error: any) {
225-
const errorMessage = error instanceof Error ? error.message : String(error)
226-
this.dispatchEvent('step-error', { type: 'step-error', historyId: this.id, error: errorMessage })
227-
}
228-
229214
/**
230215
* @deprecated used internally
231216
*/

packages/redis/src/index.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,6 @@ export async function redisLogger(history: History, options: RedisLoggerOptions)
7777
{ signal: abortSignal },
7878
)
7979

80-
history.addEventListener(
81-
'step-error',
82-
(event) => {
83-
addStreamEntry('step-error', event.historyId, {
84-
error: event.error,
85-
})
86-
},
87-
{ signal: abortSignal },
88-
)
89-
9080
history.addEventListener(
9181
'subtask-start',
9282
(event) => {

0 commit comments

Comments
 (0)