WIP: Implement Realtime Ephemeral Token functionality and update related components

This commit is contained in:
Marco Beretta 2024-12-19 14:58:15 +01:00
parent 40c8b8fd75
commit ea5cb4bc2b
No known key found for this signature in database
GPG key ID: D918033D8E74CC11
13 changed files with 1113 additions and 14 deletions

View file

@ -171,7 +171,9 @@ export const textToSpeechManual = () => `${textToSpeech()}/manual`;
export const textToSpeechVoices = () => `${textToSpeech()}/voices`;
export const getCustomConfigSpeech = () => `${speech()}/config/get`;
export const getCustomConfigSpeech = () => `${speech()}/config`;
export const getRealtimeEphemeralToken = () => `${speech()}/realtime`;
export const getPromptGroup = (_id: string) => `${prompts()}/groups/${_id}`;

View file

@ -408,6 +408,18 @@ const speechTab = z
})
.optional();
const realtime = z
.object({
openai: z
.object({
url: z.string().optional(),
apiKey: z.string().optional(),
voices: z.array(z.string()).optional(),
})
.optional(),
})
.optional();
export enum RateLimitPrefix {
FILE_UPLOAD = 'FILE_UPLOAD',
IMPORT = 'IMPORT',
@ -595,6 +607,7 @@ export const configSchema = z.object({
tts: ttsSchema.optional(),
stt: sttSchema.optional(),
speechTab: speechTab.optional(),
realtime: realtime.optional(),
})
.optional(),
rateLimits: rateLimitSchema.optional(),
@ -1216,6 +1229,13 @@ export enum TTSProviders {
LOCALAI = 'localai',
}
export enum RealtimeVoiceProviders {
/**
* Provider for OpenAI Realtime Voice API
*/
OPENAI = 'openai',
}
/** Enum for app-wide constants */
export enum Constants {
/** Key for the app's version. */

View file

@ -576,6 +576,12 @@ export const getCustomConfigSpeech = (): Promise<t.TCustomConfigSpeechResponse>
return request.get(endpoints.getCustomConfigSpeech());
};
export const getRealtimeEphemeralToken = (
data: t.TRealtimeEphemeralTokenRequest,
): Promise<t.TRealtimeEphemeralTokenResponse> => {
return request.get(endpoints.getRealtimeEphemeralToken(), { params: data });
};
/* conversations */
export function duplicateConversation(

View file

@ -69,4 +69,5 @@ export enum MutationKeys {
updateRole = 'updateRole',
enableTwoFactor = 'enableTwoFactor',
verifyTwoFactor = 'verifyTwoFactor',
realtimeEphemeralToken = 'realtimeEphemeralToken',
}

View file

@ -10,7 +10,7 @@ import type {
TConversationTag,
TBanner,
} from './schemas';
export type TOpenAIMessage = OpenAI.Chat.ChatCompletionMessageParam;
import { string } from 'zod';
export * from './schemas';
@ -532,3 +532,12 @@ export type TAcceptTermsResponse = {
};
export type TBannerResponse = TBanner | null;
export type TRealtimeEphemeralTokenRequest = {
voice: string;
};
export type TRealtimeEphemeralTokenResponse = {
token: string;
url: string;
};