diff --git a/plugins/openai/src/realtime/realtime_model.ts b/plugins/openai/src/realtime/realtime_model.ts index 9e370153..a1cd611a 100644 --- a/plugins/openai/src/realtime/realtime_model.ts +++ b/plugins/openai/src/realtime/realtime_model.ts @@ -1101,12 +1101,14 @@ export class RealtimeSession extends multimodal.RealtimeSession { return; } + const parsedArgs = JSON.parse(item.arguments); + this.emit('function_call_started', { + name: item.name, callId: item.call_id, + arguments: parsedArgs, }); - const parsedArgs = JSON.parse(item.arguments); - this.#logger.debug( `[Function Call ${item.call_id}] Executing ${item.name} with arguments ${parsedArgs}`, ); @@ -1115,7 +1117,10 @@ export class RealtimeSession extends multimodal.RealtimeSession { (content) => { this.#logger.debug(`[Function Call ${item.call_id}] ${item.name} returned ${content}`); this.emit('function_call_completed', { + name: item.name, callId: item.call_id, + arguments: parsedArgs, + result: content, }); this.conversation.item.create( llm.ChatMessage.createToolFromFunctionResult({ @@ -1131,7 +1136,10 @@ export class RealtimeSession extends multimodal.RealtimeSession { this.#logger.error(`[Function Call ${item.call_id}] ${item.name} failed with ${error}`); // TODO: send it back up as failed? this.emit('function_call_failed', { + name: item.name, callId: item.call_id, + arguments: parsedArgs, + error: error, }); }, );