4
4
5
5
``` ts
6
6
7
- import { AppCheckInternalComponentName } from ' @firebase/app-check-interop-types' ;
8
7
import { AppCheckTokenResult } from ' @firebase/app-check-interop-types' ;
9
- import { ComponentContainer } from ' @firebase/component' ;
10
8
import { FirebaseApp } from ' @firebase/app' ;
11
- import { FirebaseAppCheckInternal } from ' @firebase/app-check-interop-types' ;
12
- import { FirebaseAuthInternal } from ' @firebase/auth-interop-types' ;
13
- import { FirebaseAuthInternalName } from ' @firebase/auth-interop-types' ;
14
9
import { FirebaseAuthTokenData } from ' @firebase/auth-interop-types' ;
15
10
import { FirebaseError } from ' @firebase/util' ;
16
- import { _FirebaseService } from ' @firebase/app' ;
17
- import { InstanceFactoryOptions } from ' @firebase/component' ;
18
- import { Provider } from ' @firebase/component' ;
19
11
20
12
// @public
21
13
export interface AI {
@@ -41,6 +33,7 @@ export const AIErrorCode: {
41
33
readonly REQUEST_ERROR: " request-error" ;
42
34
readonly RESPONSE_ERROR: " response-error" ;
43
35
readonly FETCH_ERROR: " fetch-error" ;
36
+ readonly SESSION_CLOSED: " session-closed" ;
44
37
readonly INVALID_CONTENT: " invalid-content" ;
45
38
readonly API_NOT_ENABLED: " api-not-enabled" ;
46
39
readonly INVALID_SCHEMA: " invalid-schema" ;
@@ -94,6 +87,11 @@ export class ArraySchema extends Schema {
94
87
toJSON(): SchemaRequest ;
95
88
}
96
89
90
+ // @beta
91
+ export interface AudioConversationController {
92
+ stop: () => Promise <void >;
93
+ }
94
+
97
95
// @public
98
96
export abstract class Backend {
99
97
protected constructor (type : BackendType );
@@ -239,11 +237,6 @@ export interface ErrorDetails {
239
237
reason? : string ;
240
238
}
241
239
242
- // Warning: (ae-forgotten-export) The symbol "AIService" needs to be exported by the entry point index.d.ts
243
- //
244
- // @public (undocumented)
245
- export function factory(container : ComponentContainer , { instanceIdentifier }: InstanceFactoryOptions ): AIService ;
246
-
247
240
// @public
248
241
export interface FileData {
249
242
// (undocumented)
@@ -290,6 +283,7 @@ export type FinishReason = (typeof FinishReason)[keyof typeof FinishReason];
290
283
export interface FunctionCall {
291
284
// (undocumented)
292
285
args: object ;
286
+ id? : string ;
293
287
// (undocumented)
294
288
name: string ;
295
289
}
@@ -342,6 +336,7 @@ export interface FunctionDeclarationsTool {
342
336
343
337
// @public
344
338
export interface FunctionResponse {
339
+ id? : string ;
345
340
// (undocumented)
346
341
name: string ;
347
342
// (undocumented)
@@ -480,6 +475,9 @@ export function getGenerativeModel(ai: AI, modelParams: ModelParams | HybridPara
480
475
// @beta
481
476
export function getImagenModel(ai : AI , modelParams : ImagenModelParams , requestOptions ? : RequestOptions ): ImagenModel ;
482
477
478
+ // @beta
479
+ export function getLiveGenerativeModel(ai : AI , modelParams : LiveModelParams ): LiveGenerativeModel ;
480
+
483
481
// @public
484
482
export class GoogleAIBackend extends Backend {
485
483
constructor ();
@@ -813,6 +811,96 @@ export interface LanguageModelPromptOptions {
813
811
responseConstraint? : object ;
814
812
}
815
813
814
+ // @beta
815
+ export interface LiveGenerationConfig {
816
+ frequencyPenalty? : number ;
817
+ maxOutputTokens? : number ;
818
+ presencePenalty? : number ;
819
+ responseModalities? : ResponseModality [];
820
+ speechConfig? : SpeechConfig ;
821
+ temperature? : number ;
822
+ topK? : number ;
823
+ topP? : number ;
824
+ }
825
+
826
+ // @beta
827
+ export class LiveGenerativeModel extends AIModel {
828
+ // Warning: (ae-forgotten-export) The symbol "WebSocketHandler" needs to be exported by the entry point index.d.ts
829
+ //
830
+ // @internal
831
+ constructor (ai : AI , modelParams : LiveModelParams ,
832
+ _webSocketHandler : WebSocketHandler );
833
+ connect(): Promise <LiveSession >;
834
+ // (undocumented)
835
+ generationConfig: LiveGenerationConfig ;
836
+ // (undocumented)
837
+ systemInstruction? : Content ;
838
+ // (undocumented)
839
+ toolConfig? : ToolConfig ;
840
+ // (undocumented)
841
+ tools? : Tool [];
842
+ }
843
+
844
+ // @beta
845
+ export interface LiveModelParams {
846
+ // (undocumented)
847
+ generationConfig? : LiveGenerationConfig ;
848
+ // (undocumented)
849
+ model: string ;
850
+ // (undocumented)
851
+ systemInstruction? : string | Part | Content ;
852
+ // (undocumented)
853
+ toolConfig? : ToolConfig ;
854
+ // (undocumented)
855
+ tools? : Tool [];
856
+ }
857
+
858
+ // @beta
859
+ export const LiveResponseType: {
860
+ SERVER_CONTENT: string ;
861
+ TOOL_CALL: string ;
862
+ TOOL_CALL_CANCELLATION: string ;
863
+ };
864
+
865
+ // @beta
866
+ export type LiveResponseType = (typeof LiveResponseType )[keyof typeof LiveResponseType ];
867
+
868
+ // @beta
869
+ export interface LiveServerContent {
870
+ interrupted? : boolean ;
871
+ modelTurn? : Content ;
872
+ turnComplete? : boolean ;
873
+ // (undocumented)
874
+ type: ' serverContent' ;
875
+ }
876
+
877
+ // @beta
878
+ export interface LiveServerToolCall {
879
+ functionCalls: FunctionCall [];
880
+ // (undocumented)
881
+ type: ' toolCall' ;
882
+ }
883
+
884
+ // @beta
885
+ export interface LiveServerToolCallCancellation {
886
+ functionIds: string [];
887
+ // (undocumented)
888
+ type: ' toolCallCancellation' ;
889
+ }
890
+
891
+ // @beta
892
+ export class LiveSession {
893
+ // @internal
894
+ constructor (webSocketHandler : WebSocketHandler , serverMessages : AsyncGenerator <unknown >);
895
+ close(): Promise <void >;
896
+ inConversation: boolean ;
897
+ isClosed: boolean ;
898
+ receive(): AsyncGenerator <LiveServerContent | LiveServerToolCall | LiveServerToolCallCancellation >;
899
+ send(request : string | Array <string | Part >, turnComplete ? : boolean ): Promise <void >;
900
+ sendMediaChunks(mediaChunks : GenerativeContentBlob []): Promise <void >;
901
+ sendMediaStream(mediaChunkStream : ReadableStream <GenerativeContentBlob >): Promise <void >;
902
+ }
903
+
816
904
// @public
817
905
export const Modality: {
818
906
readonly MODALITY_UNSPECIFIED: " MODALITY_UNSPECIFIED" ;
@@ -885,6 +973,11 @@ export type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionRespon
885
973
// @public
886
974
export const POSSIBLE_ROLES: readonly [" user" , " model" , " function" , " system" ];
887
975
976
+ // @beta
977
+ export interface PrebuiltVoiceConfig {
978
+ voiceName? : string ;
979
+ }
980
+
888
981
// @public
889
982
export interface PromptFeedback {
890
983
// (undocumented)
@@ -904,6 +997,7 @@ export interface RequestOptions {
904
997
export const ResponseModality: {
905
998
readonly TEXT: " TEXT" ;
906
999
readonly IMAGE: " IMAGE" ;
1000
+ readonly AUDIO: " AUDIO" ;
907
1001
};
908
1002
909
1003
// @beta
@@ -1048,6 +1142,19 @@ export interface Segment {
1048
1142
text: string ;
1049
1143
}
1050
1144
1145
+ // @beta
1146
+ export interface SpeechConfig {
1147
+ voiceConfig? : VoiceConfig ;
1148
+ }
1149
+
1150
+ // @beta
1151
+ export function startAudioConversation(liveSession : LiveSession , options ? : StartAudioConversationOptions ): Promise <AudioConversationController >;
1152
+
1153
+ // @beta
1154
+ export interface StartAudioConversationOptions {
1155
+ functionCallingHandler? : (functionCalls : LiveServerToolCall [' functionCalls' ]) => Promise <Part >;
1156
+ }
1157
+
1051
1158
// @public
1052
1159
export interface StartChatParams extends BaseParams {
1053
1160
// (undocumented)
@@ -1130,6 +1237,11 @@ export interface VideoMetadata {
1130
1237
startOffset: string ;
1131
1238
}
1132
1239
1240
+ // @beta
1241
+ export interface VoiceConfig {
1242
+ prebuiltVoiceConfig? : PrebuiltVoiceConfig ;
1243
+ }
1244
+
1133
1245
// @public (undocumented)
1134
1246
export interface WebAttribution {
1135
1247
// (undocumented)
0 commit comments