Skip to content

Commit 81ab450

Browse files
russellwheatleymikehardy
authored andcommitted
request.ts types
1 parent 945912e commit 81ab450

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

packages/ai/lib/types/requests.ts

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717

1818
import { TypedSchema } from '../requests/schema-builder';
1919
import { Content, Part } from './content';
20-
import { FunctionCallingMode, HarmBlockMethod, HarmBlockThreshold, HarmCategory } from './enums';
20+
import {
21+
FunctionCallingMode,
22+
HarmBlockMethod,
23+
HarmBlockThreshold,
24+
HarmCategory,
25+
ResponseModality,
26+
} from './enums';
2127
import { ObjectSchemaInterface, SchemaRequest } from './schema';
2228

2329
/**
@@ -30,7 +36,7 @@ export interface BaseParams {
3036
}
3137

3238
/**
33-
* Params passed to <code>{@link getGenerativeModel}</code>.
39+
* Params passed to {@link getGenerativeModel}.
3440
* @public
3541
*/
3642
export interface ModelParams extends BaseParams {
@@ -58,6 +64,13 @@ export interface GenerateContentRequest extends BaseParams {
5864
export interface SafetySetting {
5965
category: HarmCategory;
6066
threshold: HarmBlockThreshold;
67+
/**
68+
* The harm block method.
69+
*
70+
* This property is only supported in the Vertex AI Gemini API ({@link VertexAIBackend}).
71+
* When using the Gemini Developer API ({@link GoogleAIBackend}), an {@link AIError} will be
72+
* thrown if this property is defined.
73+
*/
6174
method?: HarmBlockMethod;
6275
}
6376

@@ -83,13 +96,23 @@ export interface GenerationConfig {
8396
responseMimeType?: string;
8497
/**
8598
* Output response schema of the generated candidate text. This
86-
* value can be a class generated with a <code>{@link Schema}</code> static method
99+
* value can be a class generated with a {@link Schema} static method
87100
* like `Schema.string()` or `Schema.object()` or it can be a plain
88-
* JS object matching the <code>{@link SchemaRequest}</code> interface.
101+
* JS object matching the {@link SchemaRequest} interface.
89102
* <br/>Note: This only applies when the specified `responseMIMEType` supports a schema; currently
90103
* this is limited to `application/json` and `text/x.enum`.
91104
*/
92105
responseSchema?: TypedSchema | SchemaRequest;
106+
/**
107+
* Generation modalities to be returned in generation responses.
108+
*
109+
* @remarks
110+
* - Multimodal response generation is only supported by some Gemini models and versions; see {@link https://firebase.google.com/docs/vertex-ai/models | model versions}.
111+
* - Only image generation (`ResponseModality.IMAGE`) is supported.
112+
*
113+
* @beta
114+
*/
115+
responseModalities?: ResponseModality[];
93116
}
94117

95118
/**
@@ -109,10 +132,22 @@ export interface StartChatParams extends BaseParams {
109132
*/
110133
export interface CountTokensRequest {
111134
contents: Content[];
135+
/**
136+
* Instructions that direct the model to behave a certain way.
137+
*/
138+
systemInstruction?: string | Part | Content;
139+
/**
140+
* {@link Tool} configuration.
141+
*/
142+
tools?: Tool[];
143+
/**
144+
* Configuration options that control how the model generates a response.
145+
*/
146+
generationConfig?: GenerationConfig;
112147
}
113148

114149
/**
115-
* Params passed to <code>{@link getGenerativeModel}</code>.
150+
* Params passed to {@link getGenerativeModel}.
116151
* @public
117152
*/
118153
export interface RequestOptions {
@@ -172,8 +207,8 @@ export declare interface FunctionDeclarationsTool {
172207
* Optional. One or more function declarations
173208
* to be passed to the model along with the current user query. Model may
174209
* decide to call a subset of these functions by populating
175-
* <code>{@link FunctionCall}</code> in the response. User should
176-
* provide a <code>{@link FunctionResponse}</code> for each
210+
* {@link FunctionCall} in the response. User should
211+
* provide a {@link FunctionResponse} for each
177212
* function call in the next turn. Based on the function responses, the model will
178213
* generate the final response back to the user. Maximum 64 function
179214
* declarations can be provided.

0 commit comments

Comments
 (0)