Skip to content

Compatible with new response formats, supporting "Text", "Audio", "Image" arrays #434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/api-review/generative-ai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ export interface GenerationConfig {
presencePenalty?: number;
responseLogprobs?: boolean;
responseMimeType?: string;
responseModalities?: string[];
responseSchema?: ResponseSchema;
// (undocumented)
stopSequences?: string[];
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@google/generative-ai",
"version": "0.24.0",
"version": "0.24.1",
"description": "Google AI JavaScript SDK",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
8 changes: 7 additions & 1 deletion src/methods/chat-session-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ const VALID_PART_FIELDS: Array<keyof Part> = [
const VALID_PARTS_PER_ROLE: { [key in Role]: Array<keyof Part> } = {
user: ["text", "inlineData"],
function: ["functionResponse"],
model: ["text", "functionCall", "executableCode", "codeExecutionResult"],
model: [
"text",
"inlineData",
"functionCall",
"executableCode",
"codeExecutionResult",
],
// System instructions shouldn't be in history anyway.
system: ["text"],
};
Expand Down
4 changes: 4 additions & 0 deletions types/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ export interface GenerationConfig {
* logprobs to return at each decoding step in the logprobsResult.
*/
logprobs?: number;
/**
* Compatible with new response formats, supporting "Text", "Audio", "Image" arrays.
*/
responseModalities?: string[];
}

/**
Expand Down