Skip to content

Commit

Permalink
add usage to the response_done event (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
martysaxton authored Nov 2, 2024
1 parent d8de754 commit 374d214
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plugins/openai/src/realtime/realtime_model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface RealtimeResponse {
id: string;
status: api_proto.ResponseStatus;
statusDetails: api_proto.ResponseStatusDetails | null;
usage: api_proto.ResponseResource['usage'] | null;
output: RealtimeOutput[];
doneFut: Future;
}
Expand Down Expand Up @@ -787,6 +788,7 @@ export class RealtimeSession extends multimodal.RealtimeSession {
id: response.id,
status: response.status,
statusDetails: response.status_details,
usage: null,
output: [],
doneFut: doneFut,
};
Expand All @@ -800,6 +802,7 @@ export class RealtimeSession extends multimodal.RealtimeSession {
const response = this.#pendingResponses[responseId];
response.status = responseData.status;
response.statusDetails = responseData.status_details;
response.usage = responseData.usage;
this.#pendingResponses[responseId] = response;
response.doneFut.resolve();
this.emit('response_done', response);
Expand Down

0 comments on commit 374d214

Please sign in to comment.