Skip to content

Commit 6ba035c

Browse files
authored
Chore/include action metadata from API responses (#6204)
include action metadata from API responses
1 parent 4c0223a commit 6ba035c

4 files changed

Lines changed: 8 additions & 0 deletions

File tree

packages/server/src/queue/RedisEventPublisher.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ export class RedisEventPublisher implements IServerSideEventStreamer {
198198
if (apiResponse.memoryType) {
199199
metadataJson['memoryType'] = apiResponse.memoryType
200200
}
201+
if (apiResponse.action) {
202+
metadataJson['action'] = typeof apiResponse.action === 'string' ? JSON.parse(apiResponse.action) : apiResponse.action
203+
}
201204
if (Object.keys(metadataJson).length > 0) {
202205
this.streamCustomEvent(chatId, 'metadata', metadataJson)
203206
}

packages/server/src/utils/SSEStreamer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ export class SSEStreamer implements IServerSideEventStreamer {
231231
metadataJson['flowVariables'] =
232232
typeof apiResponse.flowVariables === 'string' ? JSON.parse(apiResponse.flowVariables) : apiResponse.flowVariables
233233
}
234+
if (apiResponse.action) {
235+
metadataJson['action'] = typeof apiResponse.action === 'string' ? JSON.parse(apiResponse.action) : apiResponse.action
236+
}
234237
if (Object.keys(metadataJson).length > 0) {
235238
this.streamCustomEvent(chatId, 'metadata', metadataJson)
236239
}

packages/server/src/utils/buildAgentflow.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,6 +2331,7 @@ export const executeAgentFlow = async ({
23312331
result.followUpPrompts = JSON.stringify(apiMessage.followUpPrompts)
23322332
result.executionId = newExecution.id
23332333
result.agentFlowExecutedData = agentFlowExecutedData
2334+
if (apiMessage.action) result.action = JSON.parse(apiMessage.action)
23342335

23352336
if (sessionId) result.sessionId = sessionId
23362337

packages/server/src/utils/buildChatflow.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ export const executeFlow = async ({
871871
if (result?.usedTools) apiMessage.usedTools = JSON.stringify(result.usedTools)
872872
if (result?.fileAnnotations) apiMessage.fileAnnotations = JSON.stringify(result.fileAnnotations)
873873
if (result?.artifacts) apiMessage.artifacts = JSON.stringify(result.artifacts)
874+
if (result?.action) apiMessage.action = typeof result.action === 'string' ? result.action : JSON.stringify(result.action)
874875
if (chatflow.followUpPrompts) {
875876
const followUpPromptsConfig = JSON.parse(chatflow.followUpPrompts)
876877
const followUpPrompts = await generateFollowUpPrompts(followUpPromptsConfig, apiMessage.content, {

0 commit comments

Comments
 (0)