@firebase/ai 2.2.1-canary.120a30838 → 2.2.1-canary.43276b041

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -393,6 +393,53 @@ export declare interface CitationMetadata {
393
393
  citations: Citation[];
394
394
  }
395
395
 
396
+ /**
397
+ * The results of code execution run by the model.
398
+ *
399
+ * @public
400
+ */
401
+ export declare interface CodeExecutionResult {
402
+ /**
403
+ * The result of the code execution.
404
+ */
405
+ outcome?: Outcome;
406
+ /**
407
+ * The output from the code execution, or an error message
408
+ * if it failed.
409
+ */
410
+ output?: string;
411
+ }
412
+
413
+ /**
414
+ * Represents the code execution result from the model.
415
+ *
416
+ * @public
417
+ */
418
+ export declare interface CodeExecutionResultPart {
419
+ text?: never;
420
+ inlineData?: never;
421
+ functionCall?: never;
422
+ functionResponse?: never;
423
+ fileData: never;
424
+ thought?: never;
425
+ /* Excluded from this release type: thoughtSignature */
426
+ executableCode?: never;
427
+ codeExecutionResult?: CodeExecutionResult;
428
+ }
429
+
430
+ /**
431
+ * A tool that enables the model to use code execution.
432
+ *
433
+ * @public
434
+ */
435
+ export declare interface CodeExecutionTool {
436
+ /**
437
+ * Specifies the Google Search configuration.
438
+ * Currently, this is an empty object, but it's reserved for future configuration options.
439
+ */
440
+ codeExecution: {};
441
+ }
442
+
396
443
  /**
397
444
  * Content type for both prompts and response candidates.
398
445
  * @public
@@ -530,6 +577,39 @@ export declare interface ErrorDetails {
530
577
  [key: string]: unknown;
531
578
  }
532
579
 
580
+ /**
581
+ * An interface for executable code returned by the model.
582
+ *
583
+ * @public
584
+ */
585
+ export declare interface ExecutableCode {
586
+ /**
587
+ * The programming language of the code.
588
+ */
589
+ language?: Language;
590
+ /**
591
+ * The source code to be executed.
592
+ */
593
+ code?: string;
594
+ }
595
+
596
+ /**
597
+ * Represents the code that is executed by the model.
598
+ *
599
+ * @public
600
+ */
601
+ export declare interface ExecutableCodePart {
602
+ text?: never;
603
+ inlineData?: never;
604
+ functionCall?: never;
605
+ functionResponse?: never;
606
+ fileData: never;
607
+ thought?: never;
608
+ /* Excluded from this release type: thoughtSignature */
609
+ executableCode?: ExecutableCode;
610
+ codeExecutionResult?: never;
611
+ }
612
+
533
613
  /**
534
614
  * Data pointing to a file uploaded on Google Cloud Storage.
535
615
  * @public
@@ -551,6 +631,8 @@ export declare interface FileDataPart {
551
631
  fileData: FileData;
552
632
  thought?: boolean;
553
633
  /* Excluded from this release type: thoughtSignature */
634
+ executableCode?: never;
635
+ codeExecutionResult?: never;
554
636
  }
555
637
 
556
638
  /**
@@ -669,6 +751,8 @@ export declare interface FunctionCallPart {
669
751
  functionResponse?: never;
670
752
  thought?: boolean;
671
753
  /* Excluded from this release type: thoughtSignature */
754
+ executableCode?: never;
755
+ codeExecutionResult?: never;
672
756
  }
673
757
 
674
758
  /**
@@ -753,6 +837,8 @@ export declare interface FunctionResponsePart {
753
837
  functionResponse: FunctionResponse;
754
838
  thought?: boolean;
755
839
  /* Excluded from this release type: thoughtSignature */
840
+ executableCode?: never;
841
+ codeExecutionResult?: never;
756
842
  }
757
843
 
758
844
  /**
@@ -1024,8 +1110,6 @@ export declare interface GoogleSearchTool {
1024
1110
  /**
1025
1111
  * Specifies the Google Search configuration.
1026
1112
  * Currently, this is an empty object, but it's reserved for future configuration options.
1027
- * Specifies the Google Search configuration. Currently, this is an empty object, but it's
1028
- * reserved for future configuration options.
1029
1113
  *
1030
1114
  * When using this feature, you are required to comply with the "Grounding with Google Search"
1031
1115
  * usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-search | Gemini Developer API}
@@ -1766,6 +1850,8 @@ export declare interface InlineDataPart {
1766
1850
  videoMetadata?: VideoMetadata;
1767
1851
  thought?: boolean;
1768
1852
  /* Excluded from this release type: thoughtSignature */
1853
+ executableCode?: never;
1854
+ codeExecutionResult?: never;
1769
1855
  }
1770
1856
 
1771
1857
  /**
@@ -1776,6 +1862,23 @@ export declare class IntegerSchema extends Schema {
1776
1862
  constructor(schemaParams?: SchemaParams);
1777
1863
  }
1778
1864
 
1865
+ /**
1866
+ * The programming language of the code.
1867
+ *
1868
+ * @public
1869
+ */
1870
+ export declare const Language: {
1871
+ UNSPECIFIED: string;
1872
+ PYTHON: string;
1873
+ };
1874
+
1875
+ /**
1876
+ * The programming language of the code.
1877
+ *
1878
+ * @public
1879
+ */
1880
+ export declare type Language = (typeof Language)[keyof typeof Language];
1881
+
1779
1882
  /**
1780
1883
  * <b>(EXPERIMENTAL)</b>
1781
1884
  * Configures the creation of an on-device language model session.
@@ -2196,12 +2299,31 @@ export declare interface OnDeviceParams {
2196
2299
  promptOptions?: LanguageModelPromptOptions;
2197
2300
  }
2198
2301
 
2302
+ /**
2303
+ * Represents the result of the code execution.
2304
+ *
2305
+ * @public
2306
+ */
2307
+ export declare const Outcome: {
2308
+ UNSPECIFIED: string;
2309
+ OK: string;
2310
+ FAILED: string;
2311
+ DEADLINE_EXCEEDED: string;
2312
+ };
2313
+
2314
+ /**
2315
+ * Represents the result of the code execution.
2316
+ *
2317
+ * @public
2318
+ */
2319
+ export declare type Outcome = (typeof Outcome)[keyof typeof Outcome];
2320
+
2199
2321
  /**
2200
2322
  * Content part - includes text, image/video, or function call/response
2201
2323
  * part types.
2202
2324
  * @public
2203
2325
  */
2204
- export declare type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart;
2326
+ export declare type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart | ExecutableCodePart | CodeExecutionResultPart;
2205
2327
 
2206
2328
  /**
2207
2329
  * Possible roles.
@@ -2703,6 +2825,8 @@ export declare interface TextPart {
2703
2825
  functionResponse?: never;
2704
2826
  thought?: boolean;
2705
2827
  /* Excluded from this release type: thoughtSignature */
2828
+ executableCode?: never;
2829
+ codeExecutionResult?: never;
2706
2830
  }
2707
2831
 
2708
2832
  /**
@@ -2743,7 +2867,7 @@ export declare interface ThinkingConfig {
2743
2867
  * Defines a tool that model can call to access external knowledge.
2744
2868
  * @public
2745
2869
  */
2746
- export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool;
2870
+ export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool;
2747
2871
 
2748
2872
  /**
2749
2873
  * Tool config. This config is shared for all tools provided in the request.
package/dist/ai.d.ts CHANGED
@@ -436,6 +436,56 @@ export declare interface CitationMetadata {
436
436
  citations: Citation[];
437
437
  }
438
438
 
439
+ /**
440
+ * The results of code execution run by the model.
441
+ *
442
+ * @public
443
+ */
444
+ export declare interface CodeExecutionResult {
445
+ /**
446
+ * The result of the code execution.
447
+ */
448
+ outcome?: Outcome;
449
+ /**
450
+ * The output from the code execution, or an error message
451
+ * if it failed.
452
+ */
453
+ output?: string;
454
+ }
455
+
456
+ /**
457
+ * Represents the code execution result from the model.
458
+ *
459
+ * @public
460
+ */
461
+ export declare interface CodeExecutionResultPart {
462
+ text?: never;
463
+ inlineData?: never;
464
+ functionCall?: never;
465
+ functionResponse?: never;
466
+ fileData: never;
467
+ thought?: never;
468
+ /**
469
+ * @internal
470
+ */
471
+ thoughtSignature?: never;
472
+ executableCode?: never;
473
+ codeExecutionResult?: CodeExecutionResult;
474
+ }
475
+
476
+ /**
477
+ * A tool that enables the model to use code execution.
478
+ *
479
+ * @public
480
+ */
481
+ export declare interface CodeExecutionTool {
482
+ /**
483
+ * Specifies the Google Search configuration.
484
+ * Currently, this is an empty object, but it's reserved for future configuration options.
485
+ */
486
+ codeExecution: {};
487
+ }
488
+
439
489
  /**
440
490
  * Content type for both prompts and response candidates.
441
491
  * @public
@@ -573,6 +623,42 @@ export declare interface ErrorDetails {
573
623
  [key: string]: unknown;
574
624
  }
575
625
 
626
+ /**
627
+ * An interface for executable code returned by the model.
628
+ *
629
+ * @public
630
+ */
631
+ export declare interface ExecutableCode {
632
+ /**
633
+ * The programming language of the code.
634
+ */
635
+ language?: Language;
636
+ /**
637
+ * The source code to be executed.
638
+ */
639
+ code?: string;
640
+ }
641
+
642
+ /**
643
+ * Represents the code that is executed by the model.
644
+ *
645
+ * @public
646
+ */
647
+ export declare interface ExecutableCodePart {
648
+ text?: never;
649
+ inlineData?: never;
650
+ functionCall?: never;
651
+ functionResponse?: never;
652
+ fileData: never;
653
+ thought?: never;
654
+ /**
655
+ * @internal
656
+ */
657
+ thoughtSignature?: never;
658
+ executableCode?: ExecutableCode;
659
+ codeExecutionResult?: never;
660
+ }
661
+
576
662
  /**
577
663
  * Data pointing to a file uploaded on Google Cloud Storage.
578
664
  * @public
@@ -597,6 +683,8 @@ export declare interface FileDataPart {
597
683
  * @internal
598
684
  */
599
685
  thoughtSignature?: never;
686
+ executableCode?: never;
687
+ codeExecutionResult?: never;
600
688
  }
601
689
 
602
690
  /**
@@ -718,6 +806,8 @@ export declare interface FunctionCallPart {
718
806
  * @internal
719
807
  */
720
808
  thoughtSignature?: never;
809
+ executableCode?: never;
810
+ codeExecutionResult?: never;
721
811
  }
722
812
 
723
813
  /**
@@ -805,6 +895,8 @@ export declare interface FunctionResponsePart {
805
895
  * @internal
806
896
  */
807
897
  thoughtSignature?: never;
898
+ executableCode?: never;
899
+ codeExecutionResult?: never;
808
900
  }
809
901
 
810
902
  /**
@@ -1110,8 +1202,6 @@ export declare interface GoogleSearchTool {
1110
1202
  /**
1111
1203
  * Specifies the Google Search configuration.
1112
1204
  * Currently, this is an empty object, but it's reserved for future configuration options.
1113
- * Specifies the Google Search configuration. Currently, this is an empty object, but it's
1114
- * reserved for future configuration options.
1115
1205
  *
1116
1206
  * When using this feature, you are required to comply with the "Grounding with Google Search"
1117
1207
  * usage requirements for your chosen API provider: {@link https://ai.google.dev/gemini-api/terms#grounding-with-google-search | Gemini Developer API}
@@ -1874,6 +1964,8 @@ export declare interface InlineDataPart {
1874
1964
  * @internal
1875
1965
  */
1876
1966
  thoughtSignature?: never;
1967
+ executableCode?: never;
1968
+ codeExecutionResult?: never;
1877
1969
  }
1878
1970
 
1879
1971
  /**
@@ -1884,6 +1976,23 @@ export declare class IntegerSchema extends Schema {
1884
1976
  constructor(schemaParams?: SchemaParams);
1885
1977
  }
1886
1978
 
1979
+ /**
1980
+ * The programming language of the code.
1981
+ *
1982
+ * @public
1983
+ */
1984
+ export declare const Language: {
1985
+ UNSPECIFIED: string;
1986
+ PYTHON: string;
1987
+ };
1988
+
1989
+ /**
1990
+ * The programming language of the code.
1991
+ *
1992
+ * @public
1993
+ */
1994
+ export declare type Language = (typeof Language)[keyof typeof Language];
1995
+
1887
1996
  /**
1888
1997
  * <b>(EXPERIMENTAL)</b>
1889
1998
  * Configures the creation of an on-device language model session.
@@ -2320,12 +2429,31 @@ export declare interface OnDeviceParams {
2320
2429
  promptOptions?: LanguageModelPromptOptions;
2321
2430
  }
2322
2431
 
2432
+ /**
2433
+ * Represents the result of the code execution.
2434
+ *
2435
+ * @public
2436
+ */
2437
+ export declare const Outcome: {
2438
+ UNSPECIFIED: string;
2439
+ OK: string;
2440
+ FAILED: string;
2441
+ DEADLINE_EXCEEDED: string;
2442
+ };
2443
+
2444
+ /**
2445
+ * Represents the result of the code execution.
2446
+ *
2447
+ * @public
2448
+ */
2449
+ export declare type Outcome = (typeof Outcome)[keyof typeof Outcome];
2450
+
2323
2451
  /**
2324
2452
  * Content part - includes text, image/video, or function call/response
2325
2453
  * part types.
2326
2454
  * @public
2327
2455
  */
2328
- export declare type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart;
2456
+ export declare type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart | ExecutableCodePart | CodeExecutionResultPart;
2329
2457
 
2330
2458
  /**
2331
2459
  * Possible roles.
@@ -2838,6 +2966,8 @@ export declare interface TextPart {
2838
2966
  * @internal
2839
2967
  */
2840
2968
  thoughtSignature?: string;
2969
+ executableCode?: never;
2970
+ codeExecutionResult?: never;
2841
2971
  }
2842
2972
 
2843
2973
  /**
@@ -2878,7 +3008,7 @@ export declare interface ThinkingConfig {
2878
3008
  * Defines a tool that model can call to access external knowledge.
2879
3009
  * @public
2880
3010
  */
2881
- export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool;
3011
+ export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool;
2882
3012
 
2883
3013
  /**
2884
3014
  * Tool config. This config is shared for all tools provided in the request.
@@ -4,7 +4,7 @@ import { FirebaseError, Deferred, getModularInstance } from '@firebase/util';
4
4
  import { Logger } from '@firebase/logger';
5
5
 
6
6
  var name = "@firebase/ai";
7
- var version = "2.2.1-canary.120a30838";
7
+ var version = "2.2.1-canary.43276b041";
8
8
 
9
9
  /**
10
10
  * @license
@@ -380,6 +380,26 @@ const InferenceMode = {
380
380
  'ONLY_IN_CLOUD': 'only_in_cloud',
381
381
  'PREFER_IN_CLOUD': 'prefer_in_cloud'
382
382
  };
383
+ /**
384
+ * Represents the result of the code execution.
385
+ *
386
+ * @public
387
+ */
388
+ const Outcome = {
389
+ UNSPECIFIED: 'OUTCOME_UNSPECIFIED',
390
+ OK: 'OUTCOME_OK',
391
+ FAILED: 'OUTCOME_FAILED',
392
+ DEADLINE_EXCEEDED: 'OUTCOME_DEADLINE_EXCEEDED'
393
+ };
394
+ /**
395
+ * The programming language of the code.
396
+ *
397
+ * @public
398
+ */
399
+ const Language = {
400
+ UNSPECIFIED: 'LANGUAGE_UNSPECIFIED',
401
+ PYTHON: 'PYTHON'
402
+ };
383
403
 
384
404
  /**
385
405
  * @license
@@ -2386,7 +2406,9 @@ function validateChatHistory(history) {
2386
2406
  functionCall: 0,
2387
2407
  functionResponse: 0,
2388
2408
  thought: 0,
2389
- thoughtSignature: 0
2409
+ thoughtSignature: 0,
2410
+ executableCode: 0,
2411
+ codeExecutionResult: 0
2390
2412
  };
2391
2413
  for (const part of parts) {
2392
2414
  for (const key of VALID_PART_FIELDS) {
@@ -4014,5 +4036,5 @@ function registerAI() {
4014
4036
  }
4015
4037
  registerAI();
4016
4038
 
4017
- export { AIError, AIErrorCode, AIModel, AnyOfSchema, ArraySchema, Backend, BackendType, BlockReason, BooleanSchema, ChatSession, FinishReason, FunctionCallingMode, GenerativeModel, GoogleAIBackend, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, ImagenAspectRatio, ImagenImageFormat, ImagenModel, ImagenPersonFilterLevel, ImagenSafetyFilterLevel, InferenceMode, IntegerSchema, LiveGenerativeModel, LiveResponseType, LiveSession, Modality, NumberSchema, ObjectSchema, POSSIBLE_ROLES, ResponseModality, Schema, SchemaType, StringSchema, VertexAIBackend, getAI, getGenerativeModel, getImagenModel, getLiveGenerativeModel, startAudioConversation };
4039
+ export { AIError, AIErrorCode, AIModel, AnyOfSchema, ArraySchema, Backend, BackendType, BlockReason, BooleanSchema, ChatSession, FinishReason, FunctionCallingMode, GenerativeModel, GoogleAIBackend, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, ImagenAspectRatio, ImagenImageFormat, ImagenModel, ImagenPersonFilterLevel, ImagenSafetyFilterLevel, InferenceMode, IntegerSchema, Language, LiveGenerativeModel, LiveResponseType, LiveSession, Modality, NumberSchema, ObjectSchema, Outcome, POSSIBLE_ROLES, ResponseModality, Schema, SchemaType, StringSchema, VertexAIBackend, getAI, getGenerativeModel, getImagenModel, getLiveGenerativeModel, startAudioConversation };
4018
4040
  //# sourceMappingURL=index.esm.js.map