1
1
import { getClientConfig } from "../config/client" ;
2
2
import {
3
3
ACCESS_CODE_PREFIX ,
4
- Azure ,
5
4
ModelProvider ,
6
5
ServiceProvider ,
7
6
} from "../constant" ;
@@ -26,6 +25,7 @@ export const ROLES = ["system", "user", "assistant"] as const;
26
25
export type MessageRole = ( typeof ROLES ) [ number ] ;
27
26
28
27
export const Models = [ "gpt-3.5-turbo" , "gpt-4" ] as const ;
28
+ export const TTSModels = [ "tts-1" , "tts-1-hd" ] as const ;
29
29
export type ChatModel = ModelType ;
30
30
31
31
export interface MultimodalContent {
@@ -54,6 +54,15 @@ export interface LLMConfig {
54
54
style ?: DalleRequestPayload [ "style" ] ;
55
55
}
56
56
57
+ export interface SpeechOptions {
58
+ model : string ;
59
+ input : string ;
60
+ voice : string ;
61
+ response_format ?: string ;
62
+ speed ?: number ;
63
+ onController ?: ( controller : AbortController ) => void ;
64
+ }
65
+
57
66
export interface ChatOptions {
58
67
messages : RequestMessage [ ] ;
59
68
config : LLMConfig ;
@@ -88,6 +97,7 @@ export interface LLMModelProvider {
88
97
89
98
export abstract class LLMApi {
90
99
abstract chat ( options : ChatOptions ) : Promise < void > ;
100
+ abstract speech ( options : SpeechOptions ) : Promise < ArrayBuffer > ;
91
101
abstract usage ( ) : Promise < LLMUsage > ;
92
102
abstract models ( ) : Promise < LLMModel [ ] > ;
93
103
}
@@ -206,13 +216,16 @@ export function validString(x: string): boolean {
206
216
return x ?. length > 0 ;
207
217
}
208
218
209
- export function getHeaders ( ) {
219
+ export function getHeaders ( ignoreHeaders : boolean = false ) {
210
220
const accessStore = useAccessStore . getState ( ) ;
211
221
const chatStore = useChatStore . getState ( ) ;
212
- const headers : Record < string , string > = {
213
- "Content-Type" : "application/json" ,
214
- Accept : "application/json" ,
215
- } ;
222
+ let headers : Record < string , string > = { } ;
223
+ if ( ! ignoreHeaders ) {
224
+ headers = {
225
+ "Content-Type" : "application/json" ,
226
+ Accept : "application/json" ,
227
+ } ;
228
+ }
216
229
217
230
const clientConfig = getClientConfig ( ) ;
218
231
0 commit comments