@firebase/ai 2.2.1 → 2.3.0-canary.cb3bdd812
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.
- package/dist/ai-public.d.ts +162 -32
- package/dist/ai.d.ts +168 -32
- package/dist/esm/index.esm.js +618 -508
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/factory-browser.d.ts +19 -0
- package/dist/esm/src/requests/hybrid-helpers.d.ts +28 -0
- package/dist/esm/src/types/chrome-adapter.d.ts +2 -2
- package/dist/esm/src/types/content.d.ts +81 -2
- package/dist/esm/src/types/enums.d.ts +53 -4
- package/dist/esm/src/types/language-model.d.ts +10 -20
- package/dist/esm/src/types/requests.d.ts +15 -7
- package/dist/index.cjs.js +619 -507
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +116 -21
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +115 -22
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/factory-browser.d.ts +19 -0
- package/dist/src/requests/hybrid-helpers.d.ts +28 -0
- package/dist/src/types/chrome-adapter.d.ts +2 -2
- package/dist/src/types/content.d.ts +81 -2
- package/dist/src/types/enums.d.ts +53 -4
- package/dist/src/types/language-model.d.ts +10 -20
- package/dist/src/types/requests.d.ts +15 -7
- package/package.json +10 -9
package/dist/ai-public.d.ts
CHANGED
|
@@ -326,13 +326,13 @@ export declare class ChatSession {
|
|
|
326
326
|
}
|
|
327
327
|
|
|
328
328
|
/**
|
|
329
|
-
*
|
|
329
|
+
* Defines an inference "backend" that uses Chrome's on-device model,
|
|
330
330
|
* and encapsulates logic for detecting when on-device inference is
|
|
331
331
|
* possible.
|
|
332
332
|
*
|
|
333
333
|
* These methods should not be called directly by the user.
|
|
334
334
|
*
|
|
335
|
-
* @
|
|
335
|
+
* @beta
|
|
336
336
|
*/
|
|
337
337
|
export declare interface ChromeAdapter {
|
|
338
338
|
/**
|
|
@@ -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}
|
|
@@ -1249,9 +1333,8 @@ export declare const HarmSeverity: {
|
|
|
1249
1333
|
export declare type HarmSeverity = (typeof HarmSeverity)[keyof typeof HarmSeverity];
|
|
1250
1334
|
|
|
1251
1335
|
/**
|
|
1252
|
-
* <b>(EXPERIMENTAL)</b>
|
|
1253
1336
|
* Configures hybrid inference.
|
|
1254
|
-
* @
|
|
1337
|
+
* @beta
|
|
1255
1338
|
*/
|
|
1256
1339
|
export declare interface HybridParams {
|
|
1257
1340
|
/**
|
|
@@ -1715,20 +1798,37 @@ export declare interface ImagenSafetySettings {
|
|
|
1715
1798
|
}
|
|
1716
1799
|
|
|
1717
1800
|
/**
|
|
1718
|
-
* <b>(EXPERIMENTAL)</b>
|
|
1719
1801
|
* Determines whether inference happens on-device or in-cloud.
|
|
1720
|
-
*
|
|
1802
|
+
*
|
|
1803
|
+
* @remarks
|
|
1804
|
+
* <b>PREFER_ON_DEVICE:</b> Attempt to make inference calls using an
|
|
1805
|
+
* on-device model. If on-device inference is not available, the SDK
|
|
1806
|
+
* will fall back to using a cloud-hosted model.
|
|
1807
|
+
* <br/>
|
|
1808
|
+
* <b>ONLY_ON_DEVICE:</b> Only attempt to make inference calls using an
|
|
1809
|
+
* on-device model. The SDK will not fall back to a cloud-hosted model.
|
|
1810
|
+
* If on-device inference is not available, inference methods will throw.
|
|
1811
|
+
* <br/>
|
|
1812
|
+
* <b>ONLY_IN_CLOUD:</b> Only attempt to make inference calls using a
|
|
1813
|
+
* cloud-hosted model. The SDK will not fall back to an on-device model.
|
|
1814
|
+
* <br/>
|
|
1815
|
+
* <b>PREFER_IN_CLOUD:</b> Attempt to make inference calls to a
|
|
1816
|
+
* cloud-hosted model. If not available, the SDK will fall back to an
|
|
1817
|
+
* on-device model.
|
|
1818
|
+
*
|
|
1819
|
+
* @beta
|
|
1721
1820
|
*/
|
|
1722
1821
|
export declare const InferenceMode: {
|
|
1723
1822
|
readonly PREFER_ON_DEVICE: "prefer_on_device";
|
|
1724
1823
|
readonly ONLY_ON_DEVICE: "only_on_device";
|
|
1725
1824
|
readonly ONLY_IN_CLOUD: "only_in_cloud";
|
|
1825
|
+
readonly PREFER_IN_CLOUD: "prefer_in_cloud";
|
|
1726
1826
|
};
|
|
1727
1827
|
|
|
1728
1828
|
/**
|
|
1729
|
-
* <b>(EXPERIMENTAL)</b>
|
|
1730
1829
|
* Determines whether inference happens on-device or in-cloud.
|
|
1731
|
-
*
|
|
1830
|
+
*
|
|
1831
|
+
* @beta
|
|
1732
1832
|
*/
|
|
1733
1833
|
export declare type InferenceMode = (typeof InferenceMode)[keyof typeof InferenceMode];
|
|
1734
1834
|
|
|
@@ -1747,6 +1847,8 @@ export declare interface InlineDataPart {
|
|
|
1747
1847
|
videoMetadata?: VideoMetadata;
|
|
1748
1848
|
thought?: boolean;
|
|
1749
1849
|
/* Excluded from this release type: thoughtSignature */
|
|
1850
|
+
executableCode?: never;
|
|
1851
|
+
codeExecutionResult?: never;
|
|
1750
1852
|
}
|
|
1751
1853
|
|
|
1752
1854
|
/**
|
|
@@ -1758,10 +1860,26 @@ export declare class IntegerSchema extends Schema {
|
|
|
1758
1860
|
}
|
|
1759
1861
|
|
|
1760
1862
|
/**
|
|
1761
|
-
*
|
|
1762
|
-
*
|
|
1863
|
+
* The programming language of the code.
|
|
1864
|
+
*
|
|
1865
|
+
* @public
|
|
1866
|
+
*/
|
|
1867
|
+
export declare const Language: {
|
|
1868
|
+
UNSPECIFIED: string;
|
|
1869
|
+
PYTHON: string;
|
|
1870
|
+
};
|
|
1871
|
+
|
|
1872
|
+
/**
|
|
1873
|
+
* The programming language of the code.
|
|
1874
|
+
*
|
|
1763
1875
|
* @public
|
|
1764
1876
|
*/
|
|
1877
|
+
export declare type Language = (typeof Language)[keyof typeof Language];
|
|
1878
|
+
|
|
1879
|
+
/**
|
|
1880
|
+
* Configures the creation of an on-device language model session.
|
|
1881
|
+
* @beta
|
|
1882
|
+
*/
|
|
1765
1883
|
export declare interface LanguageModelCreateCoreOptions {
|
|
1766
1884
|
topK?: number;
|
|
1767
1885
|
temperature?: number;
|
|
@@ -1769,9 +1887,8 @@ export declare interface LanguageModelCreateCoreOptions {
|
|
|
1769
1887
|
}
|
|
1770
1888
|
|
|
1771
1889
|
/**
|
|
1772
|
-
* <b>(EXPERIMENTAL)</b>
|
|
1773
1890
|
* Configures the creation of an on-device language model session.
|
|
1774
|
-
* @
|
|
1891
|
+
* @beta
|
|
1775
1892
|
*/
|
|
1776
1893
|
export declare interface LanguageModelCreateOptions extends LanguageModelCreateCoreOptions {
|
|
1777
1894
|
signal?: AbortSignal;
|
|
@@ -1779,18 +1896,16 @@ export declare interface LanguageModelCreateOptions extends LanguageModelCreateC
|
|
|
1779
1896
|
}
|
|
1780
1897
|
|
|
1781
1898
|
/**
|
|
1782
|
-
* <b>(EXPERIMENTAL)</b>
|
|
1783
1899
|
* Options for the expected inputs for an on-device language model.
|
|
1784
|
-
* @
|
|
1900
|
+
* @beta
|
|
1785
1901
|
*/ export declare interface LanguageModelExpected {
|
|
1786
1902
|
type: LanguageModelMessageType;
|
|
1787
1903
|
languages?: string[];
|
|
1788
1904
|
}
|
|
1789
1905
|
|
|
1790
1906
|
/**
|
|
1791
|
-
* <b>(EXPERIMENTAL)</b>
|
|
1792
1907
|
* An on-device language model message.
|
|
1793
|
-
* @
|
|
1908
|
+
* @beta
|
|
1794
1909
|
*/
|
|
1795
1910
|
export declare interface LanguageModelMessage {
|
|
1796
1911
|
role: LanguageModelMessageRole;
|
|
@@ -1798,9 +1913,8 @@ export declare interface LanguageModelMessage {
|
|
|
1798
1913
|
}
|
|
1799
1914
|
|
|
1800
1915
|
/**
|
|
1801
|
-
* <b>(EXPERIMENTAL)</b>
|
|
1802
1916
|
* An on-device language model content object.
|
|
1803
|
-
* @
|
|
1917
|
+
* @beta
|
|
1804
1918
|
*/
|
|
1805
1919
|
export declare interface LanguageModelMessageContent {
|
|
1806
1920
|
type: LanguageModelMessageType;
|
|
@@ -1808,30 +1922,26 @@ export declare interface LanguageModelMessageContent {
|
|
|
1808
1922
|
}
|
|
1809
1923
|
|
|
1810
1924
|
/**
|
|
1811
|
-
* <b>(EXPERIMENTAL)</b>
|
|
1812
1925
|
* Content formats that can be provided as on-device message content.
|
|
1813
|
-
* @
|
|
1926
|
+
* @beta
|
|
1814
1927
|
*/
|
|
1815
1928
|
export declare type LanguageModelMessageContentValue = ImageBitmapSource | AudioBuffer | BufferSource | string;
|
|
1816
1929
|
|
|
1817
1930
|
/**
|
|
1818
|
-
* <b>(EXPERIMENTAL)</b>
|
|
1819
1931
|
* Allowable roles for on-device language model usage.
|
|
1820
|
-
* @
|
|
1932
|
+
* @beta
|
|
1821
1933
|
*/
|
|
1822
1934
|
export declare type LanguageModelMessageRole = 'system' | 'user' | 'assistant';
|
|
1823
1935
|
|
|
1824
1936
|
/**
|
|
1825
|
-
* <b>(EXPERIMENTAL)</b>
|
|
1826
1937
|
* Allowable types for on-device language model messages.
|
|
1827
|
-
* @
|
|
1938
|
+
* @beta
|
|
1828
1939
|
*/
|
|
1829
1940
|
export declare type LanguageModelMessageType = 'text' | 'image' | 'audio';
|
|
1830
1941
|
|
|
1831
1942
|
/**
|
|
1832
|
-
* <b>(EXPERIMENTAL)</b>
|
|
1833
1943
|
* Options for an on-device language model prompt.
|
|
1834
|
-
* @
|
|
1944
|
+
* @beta
|
|
1835
1945
|
*/
|
|
1836
1946
|
export declare interface LanguageModelPromptOptions {
|
|
1837
1947
|
responseConstraint?: object;
|
|
@@ -2167,22 +2277,40 @@ export declare interface ObjectSchemaRequest extends SchemaRequest {
|
|
|
2167
2277
|
}
|
|
2168
2278
|
|
|
2169
2279
|
/**
|
|
2170
|
-
* <b>(EXPERIMENTAL)</b>
|
|
2171
2280
|
* Encapsulates configuration for on-device inference.
|
|
2172
2281
|
*
|
|
2173
|
-
* @
|
|
2282
|
+
* @beta
|
|
2174
2283
|
*/
|
|
2175
2284
|
export declare interface OnDeviceParams {
|
|
2176
2285
|
createOptions?: LanguageModelCreateOptions;
|
|
2177
2286
|
promptOptions?: LanguageModelPromptOptions;
|
|
2178
2287
|
}
|
|
2179
2288
|
|
|
2289
|
+
/**
|
|
2290
|
+
* Represents the result of the code execution.
|
|
2291
|
+
*
|
|
2292
|
+
* @public
|
|
2293
|
+
*/
|
|
2294
|
+
export declare const Outcome: {
|
|
2295
|
+
UNSPECIFIED: string;
|
|
2296
|
+
OK: string;
|
|
2297
|
+
FAILED: string;
|
|
2298
|
+
DEADLINE_EXCEEDED: string;
|
|
2299
|
+
};
|
|
2300
|
+
|
|
2301
|
+
/**
|
|
2302
|
+
* Represents the result of the code execution.
|
|
2303
|
+
*
|
|
2304
|
+
* @public
|
|
2305
|
+
*/
|
|
2306
|
+
export declare type Outcome = (typeof Outcome)[keyof typeof Outcome];
|
|
2307
|
+
|
|
2180
2308
|
/**
|
|
2181
2309
|
* Content part - includes text, image/video, or function call/response
|
|
2182
2310
|
* part types.
|
|
2183
2311
|
* @public
|
|
2184
2312
|
*/
|
|
2185
|
-
export declare type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart;
|
|
2313
|
+
export declare type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart | ExecutableCodePart | CodeExecutionResultPart;
|
|
2186
2314
|
|
|
2187
2315
|
/**
|
|
2188
2316
|
* Possible roles.
|
|
@@ -2684,6 +2812,8 @@ export declare interface TextPart {
|
|
|
2684
2812
|
functionResponse?: never;
|
|
2685
2813
|
thought?: boolean;
|
|
2686
2814
|
/* Excluded from this release type: thoughtSignature */
|
|
2815
|
+
executableCode?: never;
|
|
2816
|
+
codeExecutionResult?: never;
|
|
2687
2817
|
}
|
|
2688
2818
|
|
|
2689
2819
|
/**
|
|
@@ -2724,7 +2854,7 @@ export declare interface ThinkingConfig {
|
|
|
2724
2854
|
* Defines a tool that model can call to access external knowledge.
|
|
2725
2855
|
* @public
|
|
2726
2856
|
*/
|
|
2727
|
-
export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool;
|
|
2857
|
+
export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool;
|
|
2728
2858
|
|
|
2729
2859
|
/**
|
|
2730
2860
|
* Tool config. This config is shared for all tools provided in the request.
|