Skip to content

Commit

Permalink
change to azure openai
Browse files Browse the repository at this point in the history
  • Loading branch information
eryzerz committed Dec 2, 2024
1 parent a5cb948 commit b7ccac1
Show file tree
Hide file tree
Showing 14 changed files with 131 additions and 123 deletions.
24 changes: 11 additions & 13 deletions dist/lib/api.d.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
export class RealtimeAPI extends RealtimeEventHandler {
/**
* Create a new RealtimeAPI instance
* @param {{url?: string, apiKey?: string, dangerouslyAllowAPIKeyInBrowser?: boolean, debug?: boolean}} [settings]
* @param {{endpoint?: string, apiKey?: string, deploymentName?: string, dangerouslyAllowAPIKeyInBrowser?: boolean, debug?: boolean}} [settings]
* @returns {RealtimeAPI}
*/
constructor({ url, apiKey, dangerouslyAllowAPIKeyInBrowser, debug }?: {
url?: string;
constructor({ endpoint, apiKey, deploymentName, dangerouslyAllowAPIKeyInBrowser, debug }?: {
endpoint?: string;
apiKey?: string;
deploymentName?: string;
dangerouslyAllowAPIKeyInBrowser?: boolean;
debug?: boolean;
});
defaultUrl: string;
url: string;
apiKey: string;
} | undefined);
endpoint: string;
apiKey: string | undefined;
deploymentName: string;
debug: boolean;
ws: any;
/**
Expand All @@ -27,19 +28,16 @@ export class RealtimeAPI extends RealtimeEventHandler {
*/
log(...args: any[]): true;
/**
* Connects to Realtime API Websocket Server
* @param {{model?: string}} [settings]
* Connects to Azure OpenAI Realtime API Websocket Server
* @returns {Promise<true>}
*/
connect({ model }?: {
model?: string;
}): Promise<true>;
connect(): Promise<true>;
/**
* Disconnects from Realtime API server
* @param {WebSocket} [ws]
* @returns {true}
*/
disconnect(ws?: WebSocket): true;
disconnect(ws?: WebSocket | undefined): true;
/**
* Receives an event from WebSocket and dispatches as "server.{eventName}" and "server.*" events
* @param {string} eventName
Expand Down
2 changes: 1 addition & 1 deletion dist/lib/api.d.ts.map

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

83 changes: 41 additions & 42 deletions dist/lib/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,16 @@ export class RealtimeClient extends RealtimeEventHandler {
apiKey?: string;
dangerouslyAllowAPIKeyInBrowser?: boolean;
debug?: boolean;
});
} | undefined);
defaultSessionConfig: {
modalities: string[];
instructions: string;
voice: string;
input_audio_format: string;
output_audio_format: string;
input_audio_transcription: any;
turn_detection: any;
tools: any[];
input_audio_transcription: null;
turn_detection: null;
tools: never[];
tool_choice: string;
temperature: number;
max_response_output_tokens: number;
Expand All @@ -199,8 +199,8 @@ export class RealtimeClient extends RealtimeEventHandler {
* @returns {true}
*/
private _resetConfig;
sessionCreated: boolean;
tools: {};
sessionCreated: boolean | undefined;
tools: {} | undefined;
inputAudioBuffer: any;
/**
* Sets up event handlers for a fully-functional application control flow
Expand Down Expand Up @@ -265,7 +265,7 @@ export class RealtimeClient extends RealtimeEventHandler {
* If the client is not yet connected, will save details and instantiate upon connection
* @param {SessionResourceType} [sessionConfig]
*/
updateSession({ modalities, instructions, voice, input_audio_format, output_audio_format, input_audio_transcription, turn_detection, tools, tool_choice, temperature, max_response_output_tokens, }?: SessionResourceType): boolean;
updateSession({ modalities, instructions, voice, input_audio_format, output_audio_format, input_audio_transcription, turn_detection, tools, tool_choice, temperature, max_response_output_tokens, }?: SessionResourceType | undefined): boolean;
/**
* Sends user message content and generates a response
* @param {Array<InputTextContentType|InputAudioContentType>} content
Expand All @@ -290,7 +290,7 @@ export class RealtimeClient extends RealtimeEventHandler {
* @param {number} [sampleCount] The number of samples to truncate past for the ongoing generation
* @returns {{item: (AssistantItemType | null)}}
*/
cancelResponse(id: string, sampleCount?: number): {
cancelResponse(id: string, sampleCount?: number | undefined): {
item: (AssistantItemType | null);
};
/**
Expand All @@ -317,38 +317,37 @@ export type AudioTranscriptionType = {
};
export type TurnDetectionServerVadType = {
type: "server_vad";
threshold?: number;
prefix_padding_ms?: number;
silence_duration_ms?: number;
threshold?: number | undefined;
prefix_padding_ms?: number | undefined;
silence_duration_ms?: number | undefined;
};
/**
* Tool definitions
*/
export type ToolDefinitionType = {
type?: "function";
type?: "function" | undefined;
name: string;
description: string;
parameters: {
[key: string]: any;
};
};
export type SessionResourceType = {
model?: string;
modalities?: string[];
instructions?: string;
voice?: "alloy"|"ash"|"ballad"|"coral"|"echo"|"sage"|"shimmer"|"verse";

input_audio_format?: AudioFormatType;
output_audio_format?: AudioFormatType;
input_audio_transcription?: AudioTranscriptionType | null;
turn_detection?: TurnDetectionServerVadType | null;
tools?: ToolDefinitionType[];
tool_choice?: "auto" | "none" | "required" | {
model?: string | undefined;
modalities?: string[] | undefined;
instructions?: string | undefined;
voice?: "alloy" | "ash" | "ballad" | "coral" | "echo" | "sage" | "shimmer" | "verse" | undefined;
input_audio_format?: AudioFormatType | undefined;
output_audio_format?: AudioFormatType | undefined;
input_audio_transcription?: AudioTranscriptionType | null | undefined;
turn_detection?: TurnDetectionServerVadType | null | undefined;
tools?: ToolDefinitionType[] | undefined;
tool_choice?: {
type: "function";
name: string;
};
temperature?: number;
max_response_output_tokens?: number | "inf";
} | "auto" | "none" | "required" | undefined;
temperature?: number | undefined;
max_response_output_tokens?: number | "inf" | undefined;
};
export type ItemStatusType = "in_progress" | "completed" | "incomplete";
export type InputTextContentType = {
Expand All @@ -360,8 +359,8 @@ export type InputAudioContentType = {
/**
* base64-encoded audio data
*/
audio?: string;
transcript?: string | null;
audio?: string | undefined;
transcript?: string | null | undefined;
};
export type TextContentType = {
type: "text";
Expand All @@ -372,40 +371,40 @@ export type AudioContentType = {
/**
* base64-encoded audio data
*/
audio?: string;
transcript?: string | null;
audio?: string | undefined;
transcript?: string | null | undefined;
};
export type SystemItemType = {
previous_item_id?: string | null;
previous_item_id?: string | null | undefined;
type: "message";
status: ItemStatusType;
role: "system";
content: Array<InputTextContentType>;
};
export type UserItemType = {
previous_item_id?: string | null;
previous_item_id?: string | null | undefined;
type: "message";
status: ItemStatusType;
role: "user";
content: Array<InputTextContentType | InputAudioContentType>;
};
export type AssistantItemType = {
previous_item_id?: string | null;
previous_item_id?: string | null | undefined;
type: "message";
status: ItemStatusType;
role: "assistant";
content: Array<TextContentType | AudioContentType>;
};
export type FunctionCallItemType = {
previous_item_id?: string | null;
previous_item_id?: string | null | undefined;
type: "function_call";
status: ItemStatusType;
call_id: string;
name: string;
arguments: string;
};
export type FunctionCallOutputItemType = {
previous_item_id?: string | null;
previous_item_id?: string | null | undefined;
type: "function_call_output";
call_id: string;
output: string;
Expand All @@ -417,17 +416,17 @@ export type FormattedToolType = {
arguments: string;
};
export type FormattedPropertyType = {
audio?: Int16Array;
text?: string;
transcript?: string;
tool?: FormattedToolType;
output?: string;
audio?: Int16Array | undefined;
text?: string | undefined;
transcript?: string | undefined;
tool?: FormattedToolType | undefined;
output?: string | undefined;
file?: any;
};
export type FormattedItemType = {
id: string;
object: string;
role?: "user" | "assistant" | "system";
role?: "user" | "assistant" | "system" | undefined;
formatted: FormattedPropertyType;
};
export type BaseItemType = SystemItemType | UserItemType | AssistantItemType | FunctionCallItemType | FunctionCallOutputItemType;
Expand Down Expand Up @@ -457,4 +456,4 @@ export type ResponseResourceType = {
import { RealtimeEventHandler } from './event_handler.js';
import { RealtimeAPI } from './api.js';
import { RealtimeConversation } from './conversation.js';
//# sourceMappingURL=client.d.ts.map
//# sourceMappingURL=client.d.ts.map
2 changes: 1 addition & 1 deletion dist/lib/client.d.ts.map

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

53 changes: 28 additions & 25 deletions dist/lib/conversation.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,48 @@ export class RealtimeConversation {
EventProcessors: {
'conversation.item.created': (event: any) => {
item: any;
delta: any;
delta: null;
};
'conversation.item.truncated': (event: any) => {
item: any;
delta: any;
delta: null;
};
'conversation.item.deleted': (event: any) => {
item: any;
delta: any;
delta: null;
};
'conversation.item.input_audio_transcription.completed': (event: any) => {
item: null;
delta: null;
} | {
item: any;
delta: {
transcript: any;
};
};
'input_audio_buffer.speech_started': (event: any) => {
item: any;
delta: any;
item: null;
delta: null;
};
'input_audio_buffer.speech_stopped': (event: any, inputAudioBuffer: any) => {
item: any;
delta: any;
item: null;
delta: null;
};
'response.created': (event: any) => {
item: any;
delta: any;
item: null;
delta: null;
};
'response.output_item.added': (event: any) => {
item: any;
delta: any;
item: null;
delta: null;
};
'response.output_item.done': (event: any) => {
item: any;
delta: any;
delta: null;
};
'response.content_part.added': (event: any) => {
item: any;
delta: any;
delta: null;
};
'response.audio_transcript.delta': (event: any) => {
item: any;
Expand All @@ -82,18 +85,18 @@ export class RealtimeConversation {
};
};
};
queuedInputAudio: Int16Array;
queuedInputAudio: Int16Array | null | undefined;
/**
* Clears the conversation history and resets to default
* @returns {true}
*/
clear(): true;
itemLookup: {};
items: any[];
responseLookup: {};
responses: any[];
queuedSpeechItems: {};
queuedTranscriptItems: {};
itemLookup: {} | undefined;
items: any[] | undefined;
responseLookup: {} | undefined;
responses: any[] | undefined;
queuedSpeechItems: {} | undefined;
queuedTranscriptItems: {} | undefined;
/**
* Queue input audio for manual speech event
* @param {Int16Array} inputAudio
Expand All @@ -106,7 +109,7 @@ export class RealtimeConversation {
* @param {...any} args
* @returns {item: import('./client.js').ItemType | null, delta: ItemContentDeltaType | null}
*/
processEvent(event: any, ...args: any[]): item;
processEvent(event: Object, ...args: any[]): item;
/**
* Retrieves a item by id
* @param {string} id
Expand All @@ -124,9 +127,9 @@ export class RealtimeConversation {
* Can also be used as a delta
*/
export type ItemContentDeltaType = {
text?: string;
audio?: Int16Array;
arguments?: string;
transcript?: string;
text?: string | undefined;
audio?: Int16Array | undefined;
arguments?: string | undefined;
transcript?: string | undefined;
};
//# sourceMappingURL=conversation.d.ts.map
Loading

0 comments on commit b7ccac1

Please sign in to comment.