@google/genai 0.4.0 → 0.6.0

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/web/web.d.ts CHANGED
@@ -261,10 +261,12 @@ export declare interface Candidate {
261
261
  /** Number of tokens for this candidate.
262
262
  */
263
263
  tokenCount?: number;
264
+ /** The reason why the model stopped generating tokens.
265
+ If empty, the model has not stopped generating the tokens.
266
+ */
267
+ finishReason?: FinishReason;
264
268
  /** Output only. Average log probability score of the candidate. */
265
269
  avgLogprobs?: number;
266
- /** Output only. The reason why the model stopped generating tokens. If empty, the model has not stopped generating the tokens. */
267
- finishReason?: FinishReason;
268
270
  /** Output only. Metadata specifies sources used to ground generated content. */
269
271
  groundingMetadata?: GroundingMetadata;
270
272
  /** Output only. Index of the candidate. */
@@ -375,7 +377,7 @@ export declare class Chats {
375
377
  * @remarks
376
378
  * The config in the params will be used for all requests within the chat
377
379
  * session unless overridden by a per-request `config` in
378
- * {@link ./types.SendMessageParameters}.
380
+ * @see {@link types.SendMessageParameters#config}.
379
381
  *
380
382
  * @param params - Parameters for creating a chat session.
381
383
  * @returns A new chat session.
@@ -496,12 +498,6 @@ export declare interface ContentEmbeddingStatistics {
496
498
 
497
499
  export declare type ContentListUnion = ContentUnion[] | ContentUnion;
498
500
 
499
- /** @internal */
500
- export declare function contentToMldev(apiClient: ApiClient, fromObject: types.Content): Record<string, unknown>;
501
-
502
- /** @internal */
503
- export declare function contentToVertex(apiClient: ApiClient, fromObject: types.Content): Record<string, unknown>;
504
-
505
501
  export declare type ContentUnion = Content | PartUnion[] | PartUnion;
506
502
 
507
503
  /** Configuration for a Control reference image. */
@@ -989,7 +985,8 @@ export declare enum FinishReason {
989
985
  BLOCKLIST = "BLOCKLIST",
990
986
  PROHIBITED_CONTENT = "PROHIBITED_CONTENT",
991
987
  SPII = "SPII",
992
- MALFORMED_FUNCTION_CALL = "MALFORMED_FUNCTION_CALL"
988
+ MALFORMED_FUNCTION_CALL = "MALFORMED_FUNCTION_CALL",
989
+ IMAGE_SAFETY = "IMAGE_SAFETY"
993
990
  }
994
991
 
995
992
  declare function formatMap(templateString: string, valueMap: Record<string, unknown>): string;
@@ -1317,13 +1314,25 @@ export declare class GenerateContentResponsePromptFeedback {
1317
1314
 
1318
1315
  /** Usage metadata about response(s). */
1319
1316
  export declare class GenerateContentResponseUsageMetadata {
1317
+ /** Output only. List of modalities of the cached content in the request input. */
1318
+ cacheTokensDetails?: ModalityTokenCount[];
1320
1319
  /** Output only. Number of tokens in the cached part in the input (the cached content). */
1321
1320
  cachedContentTokenCount?: number;
1322
1321
  /** Number of tokens in the response(s). */
1323
1322
  candidatesTokenCount?: number;
1323
+ /** Output only. List of modalities that were returned in the response. */
1324
+ candidatesTokensDetails?: ModalityTokenCount[];
1324
1325
  /** Number of tokens in the request. When `cached_content` is set, this is still the total effective prompt size meaning this includes the number of tokens in the cached content. */
1325
1326
  promptTokenCount?: number;
1326
- /** Total token count for prompt and response candidates. */
1327
+ /** Output only. List of modalities that were processed in the request input. */
1328
+ promptTokensDetails?: ModalityTokenCount[];
1329
+ /** Output only. Number of tokens present in thoughts output. */
1330
+ thoughtsTokenCount?: number;
1331
+ /** Output only. Number of tokens present in tool-use prompt(s). */
1332
+ toolUsePromptTokenCount?: number;
1333
+ /** Output only. List of modalities that were processed for tool-use request inputs. */
1334
+ toolUsePromptTokensDetails?: ModalityTokenCount[];
1335
+ /** Total token count for prompt, response candidates, and tool-use prompts (if present). */
1327
1336
  totalTokenCount?: number;
1328
1337
  }
1329
1338
 
@@ -1512,13 +1521,18 @@ declare function getValueByPath(data: unknown, keys: string[]): unknown;
1512
1521
  * The Google GenAI SDK.
1513
1522
  *
1514
1523
  * @remarks
1515
- * Provides access to the GenAI features through either the {@link https://cloud.google.com/vertex-ai/docs/reference/rest | Gemini API}
1516
- * or the {@link https://cloud.google.com/vertex-ai/docs/reference/rest | Vertex AI API}.
1524
+ * Provides access to the GenAI features through either the {@link
1525
+ * https://cloud.google.com/vertex-ai/docs/reference/rest | Gemini API} or
1526
+ * the {@link https://cloud.google.com/vertex-ai/docs/reference/rest | Vertex AI
1527
+ * API}.
1517
1528
  *
1518
- * The {@link GoogleGenAIOptions.vertexai} value determines which of the API services to use.
1529
+ * The {@link GoogleGenAIOptions.vertexai} value determines which of the API
1530
+ * services to use.
1519
1531
  *
1520
- * When using the Gemini API, a {@link GoogleGenAIOptions.apiKey} must also be set,
1521
- * when using Vertex AI {@link GoogleGenAIOptions.project} and {@link GoogleGenAIOptions.location} must also be set.
1532
+ * When using the Gemini API, a {@link GoogleGenAIOptions.apiKey} must also be
1533
+ * set. When using Vertex AI, currently only {@link GoogleGenAIOptions.apiKey}
1534
+ * is supported via Express mode. {@link GoogleGenAIOptions.project} and {@link
1535
+ * GoogleGenAIOptions.location} should not be set.
1522
1536
  *
1523
1537
  * @example
1524
1538
  * Initializing the SDK for using the Gemini API:
@@ -1883,6 +1897,11 @@ export declare class Live {
1883
1897
 
1884
1898
  @experimental
1885
1899
 
1900
+ @remarks
1901
+ If using the Gemini API, Live is currently only supported behind API
1902
+ version `v1alpha`. Ensure that the API version is set to `v1alpha` when
1903
+ initializing the SDK if relying on the Gemini API.
1904
+
1886
1905
  @param params - The parameters for establishing a connection to the model.
1887
1906
  @return A live session.
1888
1907
 
@@ -2055,6 +2074,28 @@ export declare interface LiveConnectParameters {
2055
2074
  config?: LiveConnectConfig;
2056
2075
  }
2057
2076
 
2077
+ /** Parameters for sending client content to the live API. */
2078
+ export declare interface LiveSendClientContentParameters {
2079
+ /** Client content to send to the session. */
2080
+ turns?: ContentListUnion;
2081
+ /** If true, indicates that the server content generation should start with
2082
+ the currently accumulated prompt. Otherwise, the server will await
2083
+ additional messages before starting generation. */
2084
+ turnComplete?: boolean;
2085
+ }
2086
+
2087
+ /** Parameters for sending realtime input to the live API. */
2088
+ export declare interface LiveSendRealtimeInputParameters {
2089
+ /** Realtime input to send to the session. */
2090
+ media: Blob_2;
2091
+ }
2092
+
2093
+ /** Parameters for sending tool responses to the live API. */
2094
+ export declare class LiveSendToolResponseParameters {
2095
+ /** Tool responses to send to the session. */
2096
+ functionResponses: FunctionResponse[] | FunctionResponse;
2097
+ }
2098
+
2058
2099
  /** Incremental server update generated by the model in response to client messages.
2059
2100
 
2060
2101
  Content is generated as quickly as possible, and not in real time. Clients
@@ -2182,6 +2223,14 @@ export declare enum Modality {
2182
2223
  AUDIO = "AUDIO"
2183
2224
  }
2184
2225
 
2226
+ /** Represents token counting info for a single modality. */
2227
+ export declare interface ModalityTokenCount {
2228
+ /** The modality associated with this token count. */
2229
+ modality?: Modality;
2230
+ /** Number of tokens. */
2231
+ tokenCount?: number;
2232
+ }
2233
+
2185
2234
  export declare enum Mode {
2186
2235
  MODE_UNSPECIFIED = "MODE_UNSPECIFIED",
2187
2236
  MODE_DYNAMIC = "MODE_DYNAMIC"
@@ -2371,7 +2420,7 @@ export declare enum Outcome {
2371
2420
  * SPDX-License-Identifier: Apache-2.0
2372
2421
  */
2373
2422
  /**
2374
- * @fileoverview Pagers for the GenAI List APIs.
2423
+ * Pagers for the GenAI List APIs.
2375
2424
  */
2376
2425
  declare enum PagedItem {
2377
2426
  PAGED_ITEM_BATCH_JOBS = "batchJobs",
@@ -2752,12 +2801,13 @@ export declare class Session {
2752
2801
  `turnComplete`.
2753
2802
 
2754
2803
  - `turns` will be converted to a `Content[]`
2755
- - `turnComplete: true` indicates that you are done sending content and
2756
- expect a response.
2804
+ - `turnComplete: true` [default] indicates that you are done sending
2805
+ content and expect a response. If `turnComplete: false`, the server
2806
+ will wait for additional messages before starting generation.
2757
2807
 
2758
2808
  @experimental
2759
2809
 
2760
- @remanks
2810
+ @remarks
2761
2811
  There are two ways to send messages to the live API:
2762
2812
  `sendClientContent` and `sendRealtimeInput`.
2763
2813
 
@@ -2793,7 +2843,7 @@ export declare class Session {
2793
2843
  ```
2794
2844
  @experimental
2795
2845
  */
2796
- sendClientContent(params: types.SessionSendClientContentParameters): void;
2846
+ sendClientContent(params: types.LiveSendClientContentParameters): void;
2797
2847
  /**
2798
2848
  Send a realtime message over the established connection.
2799
2849
 
@@ -2803,7 +2853,7 @@ export declare class Session {
2803
2853
 
2804
2854
  @experimental
2805
2855
 
2806
- @remanks
2856
+ @remarks
2807
2857
  Use `sendRealtimeInput` for realtime audio chunks and video frames (images).
2808
2858
 
2809
2859
  With `sendRealtimeInput` the api will respond to audio automatically
@@ -2816,7 +2866,7 @@ export declare class Session {
2816
2866
  Note: The Call signature expects a `Blob` object, but only a subset
2817
2867
  of audio and image mimetypes are allowed.
2818
2868
  */
2819
- sendRealtimeInput(params: types.SessionSendRealtimeInputParameters): void;
2869
+ sendRealtimeInput(params: types.LiveSendRealtimeInputParameters): void;
2820
2870
  /**
2821
2871
  Send a function response message over the established connection.
2822
2872
 
@@ -2824,14 +2874,14 @@ export declare class Session {
2824
2874
 
2825
2875
  - `functionResponses` will be converted to a `functionResponses[]`
2826
2876
 
2827
- @remanks
2877
+ @remarks
2828
2878
  Use `sendFunctionResponse` to reply to `LiveServerToolCall` from the server.
2829
2879
 
2830
- Use {@link LiveConnectConfig#tools} to configure the callable functions.
2880
+ Use {@link types.LiveConnectConfig#tools} to configure the callable functions.
2831
2881
 
2832
2882
  @experimental
2833
2883
  */
2834
- sendToolResponse(params: types.SessionSendToolResponseParameters): void;
2884
+ sendToolResponse(params: types.LiveSendToolResponseParameters): void;
2835
2885
  /**
2836
2886
  Terminates the WebSocket connection.
2837
2887
 
@@ -2852,28 +2902,6 @@ export declare class Session {
2852
2902
  close(): void;
2853
2903
  }
2854
2904
 
2855
- /** Parameters for sending client content to the live API. */
2856
- export declare interface SessionSendClientContentParameters {
2857
- /** Client content to send to the session. */
2858
- turns?: ContentListUnion;
2859
- /** If true, indicates that the server content generation should start with
2860
- the currently accumulated prompt. Otherwise, the server will await
2861
- additional messages before starting generation. */
2862
- turnComplete?: boolean;
2863
- }
2864
-
2865
- /** Parameters for sending realtime input to the live API. */
2866
- export declare interface SessionSendRealtimeInputParameters {
2867
- /** Realtime input to send to the session. */
2868
- media: Blob_2;
2869
- }
2870
-
2871
- /** Parameters for sending tool responses to the live API. */
2872
- export declare class SessionSendToolResponseParameters {
2873
- /** Tool responses to send to the session. */
2874
- functionResponses: FunctionResponse | FunctionResponse[];
2875
- }
2876
-
2877
2905
  declare function setValueByPath(data: Record<string, unknown>, keys: string[], value: unknown): void;
2878
2906
 
2879
2907
  /** The speech generation configuration. */
@@ -3021,12 +3049,6 @@ export declare interface ToolConfig {
3021
3049
 
3022
3050
  export declare type ToolListUnion = Tool[];
3023
3051
 
3024
- /** @internal */
3025
- export declare function toolToMldev(apiClient: ApiClient, fromObject: types.Tool): Record<string, unknown>;
3026
-
3027
- /** @internal */
3028
- export declare function toolToVertex(apiClient: ApiClient, fromObject: types.Tool): Record<string, unknown>;
3029
-
3030
3052
  export declare enum Type {
3031
3053
  TYPE_UNSPECIFIED = "TYPE_UNSPECIFIED",
3032
3054
  STRING = "STRING",
@@ -3059,6 +3081,7 @@ declare namespace types {
3059
3081
  HarmProbability,
3060
3082
  HarmSeverity,
3061
3083
  BlockedReason,
3084
+ Modality,
3062
3085
  State,
3063
3086
  DynamicRetrievalConfigMode,
3064
3087
  FunctionCallingConfigMode,
@@ -3071,7 +3094,6 @@ declare namespace types {
3071
3094
  MaskReferenceMode,
3072
3095
  ControlReferenceType,
3073
3096
  SubjectReferenceType,
3074
- Modality,
3075
3097
  VideoMetadata,
3076
3098
  CodeExecutionResult,
3077
3099
  ExecutableCode,
@@ -3122,6 +3144,7 @@ declare namespace types {
3122
3144
  SafetyRating,
3123
3145
  Candidate,
3124
3146
  GenerateContentResponsePromptFeedback,
3147
+ ModalityTokenCount,
3125
3148
  GenerateContentResponseUsageMetadata,
3126
3149
  GenerateContentResponse,
3127
3150
  EmbedContentConfig,
@@ -3203,9 +3226,9 @@ declare namespace types {
3203
3226
  LiveConnectParameters,
3204
3227
  CreateChatParameters,
3205
3228
  SendMessageParameters,
3206
- SessionSendClientContentParameters,
3207
- SessionSendRealtimeInputParameters,
3208
- SessionSendToolResponseParameters,
3229
+ LiveSendClientContentParameters,
3230
+ LiveSendRealtimeInputParameters,
3231
+ LiveSendToolResponseParameters,
3209
3232
  PartUnion,
3210
3233
  PartListUnion,
3211
3234
  ContentUnion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/genai",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "",
5
5
  "main": "dist/node/index.js",
6
6
  "module": "dist/web/index.mjs",
@@ -37,9 +37,9 @@
37
37
  "scripts": {
38
38
  "build": "rollup -c && api-extractor run --local --verbose && api-extractor run -c api-extractor.node.json --local --verbose&& api-extractor run -c api-extractor.web.json --local --verbose",
39
39
  "build-prod": "rollup -c && api-extractor run --verbose && api-extractor run -c api-extractor.node.json --verbose && api-extractor run -c api-extractor.web.json --verbose",
40
- "unit-test": "ts-node node_modules/jasmine/bin/jasmine test/unit/**/*_test.ts test/unit/*_test.ts",
40
+ "unit-test": "ts-node node_modules/jasmine/bin/jasmine test/unit/web/*_test.ts test/unit/node/*_test.ts test/unit/*_test.ts",
41
41
  "system-test": "ts-node node_modules/jasmine/bin/jasmine test/system/**/*_test.ts",
42
- "docs": "typedoc && scripts/add_typedoc_headers.sh",
42
+ "docs": "typedoc && ts-node scripts/add_docsite_license_headers.ts",
43
43
  "format": "prettier '**/*.ts' '**/*.mjs' '**/*.json' --write",
44
44
  "lint": "eslint '**/*.ts'",
45
45
  "lint-fix": "eslint --fix '**/*.ts'"