MCPcopy Create free account
hub / github.com/TanStack/ai / addActivityEvent

Function addActivityEvent

packages/ai-devtools/src/store/ai-context.tsx:1081–1113  ·  view source on GitHub ↗
(
    conversationId: string,
    activity:
      | 'imageEvents'
      | 'audioEvents'
      | 'speechEvents'
      | 'transcriptionEvents'
      | 'videoEvents',
    event: ActivityEvent,
  )

Source from the content-addressed store, hash-verified

1079 }
1080
1081 function addActivityEvent(
1082 conversationId: string,
1083 activity:
1084 | 'imageEvents'
1085 | 'audioEvents'
1086 | 'speechEvents'
1087 | 'transcriptionEvents'
1088 | 'videoEvents',
1089 event: ActivityEvent,
1090 ): void {
1091 if (!state.conversations[conversationId]) return
1092
1093 setState(
1094 'conversations',
1095 conversationId,
1096 activity,
1097 produce((events: Array<ActivityEvent> | undefined) => {
1098 if (!events) return [event]
1099 events.push(event)
1100 return events
1101 }),
1102 )
1103
1104 const activityFlagMap: Record<typeof activity, keyof Conversation> = {
1105 imageEvents: 'hasImage',
1106 audioEvents: 'hasAudio',
1107 speechEvents: 'hasSpeech',
1108 transcriptionEvents: 'hasTranscription',
1109 videoEvents: 'hasVideo',
1110 }
1111
1112 setState('conversations', conversationId, activityFlagMap[activity], true)
1113 }
1114
1115 /**
1116 * For server conversations, ensure a message exists for the given messageId.

Callers 1

AIProviderFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected