Skip to content

Commit

Permalink
Update to handle text-only
Browse files Browse the repository at this point in the history
  • Loading branch information
khorwood-openai committed Oct 1, 2024
1 parent 3157798 commit 8c9d05f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/lib/realtime-api-beta/dist/lib/client.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/lib/realtime-api-beta/dist/lib/conversation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ export class RealtimeConversation {
audio: Int16Array;
};
};
'response.text.delta': (event: any) => {
item: any;
delta: {
text: any;
};
};
'response.function_call_arguments.delta': (event: any) => {
item: any;
delta: {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/realtime-api-beta/dist/lib/conversation.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/lib/realtime-api-beta/lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ export class RealtimeClient extends RealtimeEventHandler {
handlerWithDispatch,
);
this.realtime.on('server.response.audio.delta', handlerWithDispatch);
this.realtime.on('server.response.text.delta', handlerWithDispatch);
this.realtime.on(
'server.response.function_call_arguments.delta',
handlerWithDispatch,
Expand Down
10 changes: 10 additions & 0 deletions src/lib/realtime-api-beta/lib/conversation.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@ export class RealtimeConversation {
);
return { item, delta: { audio: appendValues } };
},
'response.text.delta': (event) => {
const { item_id, content_index, delta } = event;
const item = this.itemLookup[item_id];
if (!item) {
throw new Error(`response.text.delta: Item "${item_id}" not found`);
}
item.content[content_index].text += delta;
item.formatted.text += delta;
return { item, delta: { text: delta } };
},
'response.function_call_arguments.delta': (event) => {
const { item_id, delta } = event;
const item = this.itemLookup[item_id];
Expand Down
3 changes: 2 additions & 1 deletion src/utils/conversation_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ export const instructions = `System settings:
Tool use: enabled.
Instructions:
- You are an artificial intelligence agent responsible for helping test realtime voice capabilities.
- You are an artificial intelligence agent responsible for helping test realtime voice capabilities
- Please make sure to respond with a helpful voice via audio
- Be kind, helpful, and curteous
- It is okay to ask the user questions
- Use tools and functions you have available liberally, it is part of the training apparatus
Expand Down

0 comments on commit 8c9d05f

Please sign in to comment.