1
- import { StreamEventTypes } from '@latitude-data/core/browser'
2
- import { LanguageModelUsage } from 'ai'
3
- import { useCallback , useRef , useState } from 'react'
4
1
import {
5
2
ContentType ,
6
- MessageRole ,
7
- ToolMessage ,
8
3
Message ,
4
+ MessageRole ,
9
5
ToolCall ,
6
+ ToolMessage ,
10
7
} from '@latitude-data/compiler'
11
8
import {
12
9
AGENT_RETURN_TOOL_NAME ,
@@ -15,7 +12,10 @@ import {
15
12
LatitudeChainCompletedEventData ,
16
13
LatitudeEventData ,
17
14
} from '@latitude-data/constants'
15
+ import { StreamEventTypes } from '@latitude-data/core/browser'
16
+ import { LanguageModelUsage } from 'ai'
18
17
import { ParsedEvent } from 'eventsource-parser/stream'
18
+ import { useCallback , useRef , useState } from 'react'
19
19
20
20
function buildMessage ( { input } : { input : string | ToolMessage [ ] } ) {
21
21
if ( typeof input === 'string' ) {
@@ -134,10 +134,6 @@ export function usePlaygroundChat({
134
134
setChainLength ( data . messages . length )
135
135
setTime ( ( prev ) => ( prev ?? 0 ) + ( performance . now ( ) - start ) )
136
136
}
137
-
138
- if ( onPromptRan ) {
139
- onPromptRan ( documentLogUuid )
140
- }
141
137
}
142
138
if ( data . type === ChainEventTypes . ToolsRequested ) {
143
139
setUnresponedToolCalls (
@@ -152,6 +148,7 @@ export function usePlaygroundChat({
152
148
153
149
setStreamingResponse ( undefined )
154
150
setIsLoading ( false )
151
+ onPromptRan ?.( documentLogUuid )
155
152
} ,
156
153
[ ] ,
157
154
)
0 commit comments