Skip to content

Commit 0c23bb3

Browse files
authoredJul 1, 2024··
Add CodeExecutionTool to Tool type (#191)
1 parent 5f9e393 commit 0c23bb3

10 files changed

+52
-8
lines changed
 

‎.changeset/thin-eggs-attack.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@google/generative-ai": patch
3+
---
4+
5+
Add `CodeExecutionTool` to `Tool` type.

‎common/api-review/generative-ai-server.api.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ export interface CodeExecutionResultPart {
8989
text?: never;
9090
}
9191

92+
// @public
93+
export interface CodeExecutionTool {
94+
codeExecution: {};
95+
}
96+
9297
// @public
9398
export interface Content {
9499
// (undocumented)
@@ -462,7 +467,7 @@ export interface TextPart {
462467
}
463468

464469
// @public
465-
export type Tool = FunctionDeclarationsTool;
470+
export type Tool = FunctionDeclarationsTool | CodeExecutionTool;
466471

467472
// @public
468473
export interface ToolConfig {

‎common/api-review/generative-ai.api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ export interface TextPart {
713713
}
714714

715715
// @public
716-
export type Tool = FunctionDeclarationsTool;
716+
export type Tool = FunctionDeclarationsTool | CodeExecutionTool;
717717

718718
// @public
719719
export interface ToolConfig {

‎docs/reference/main/generative-ai.tool.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Defines a tool that model can call to access external knowledge.
99
**Signature:**
1010

1111
```typescript
12-
export declare type Tool = FunctionDeclarationsTool;
12+
export declare type Tool = FunctionDeclarationsTool | CodeExecutionTool;
1313
```
14-
**References:** [FunctionDeclarationsTool](./generative-ai.functiondeclarationstool.md)
14+
**References:** [FunctionDeclarationsTool](./generative-ai.functiondeclarationstool.md)<!-- -->, [CodeExecutionTool](./generative-ai.codeexecutiontool.md)
1515

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [CodeExecutionTool](./generative-ai.codeexecutiontool.md) &gt; [codeExecution](./generative-ai.codeexecutiontool.codeexecution.md)
4+
5+
## CodeExecutionTool.codeExecution property
6+
7+
Provide an empty object to enable code execution. This field may have subfields added in the future.
8+
9+
**Signature:**
10+
11+
```typescript
12+
codeExecution: {};
13+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [CodeExecutionTool](./generative-ai.codeexecutiontool.md)
4+
5+
## CodeExecutionTool interface
6+
7+
Enables the model to execute code as part of generation.
8+
9+
**Signature:**
10+
11+
```typescript
12+
export interface CodeExecutionTool
13+
```
14+
15+
## Properties
16+
17+
| Property | Modifiers | Type | Description |
18+
| --- | --- | --- | --- |
19+
| [codeExecution](./generative-ai.codeexecutiontool.codeexecution.md) | | {} | Provide an empty object to enable code execution. This field may have subfields added in the future. |
20+

‎docs/reference/server/generative-ai.md

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
| [CachedContentUpdateParams](./generative-ai.cachedcontentupdateparams.md) | Params to pass to [GoogleAICacheManager.update()](./generative-ai.googleaicachemanager.update.md)<!-- -->. |
3333
| [CodeExecutionResult](./generative-ai.codeexecutionresult.md) | Result of executing the <code>ExecutableCode</code>. Only generated when using code execution, and always follows a <code>Part</code> containing the <code>ExecutableCode</code>. |
3434
| [CodeExecutionResultPart](./generative-ai.codeexecutionresultpart.md) | Content part containing the result of executed code. |
35+
| [CodeExecutionTool](./generative-ai.codeexecutiontool.md) | Enables the model to execute code as part of generation. |
3536
| [Content](./generative-ai.content.md) | Content type for both prompts and response candidates. |
3637
| [ErrorDetails](./generative-ai.errordetails.md) | Details object that may be included in an error response. |
3738
| [ExecutableCode](./generative-ai.executablecode.md) | Code generated by the model that is meant to be executed, where the result is returned to the model. Only generated when using the code execution tool, in which the code will be automatically executed, and a corresponding <code>CodeExecutionResult</code> will also be generated. |

‎docs/reference/server/generative-ai.tool.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Defines a tool that model can call to access external knowledge.
99
**Signature:**
1010

1111
```typescript
12-
export declare type Tool = FunctionDeclarationsTool;
12+
export declare type Tool = FunctionDeclarationsTool | CodeExecutionTool;
1313
```
14-
**References:** [FunctionDeclarationsTool](./generative-ai.functiondeclarationstool.md)
14+
**References:** [FunctionDeclarationsTool](./generative-ai.functiondeclarationstool.md)<!-- -->, [CodeExecutionTool](./generative-ai.codeexecutiontool.md)
1515

‎packages/main/types/requests.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export interface RequestOptions {
193193
* Defines a tool that model can call to access external knowledge.
194194
* @public
195195
*/
196-
export declare type Tool = FunctionDeclarationsTool;
196+
export declare type Tool = FunctionDeclarationsTool | CodeExecutionTool;
197197

198198
/**
199199
* Enables the model to execute code as part of generation.

‎packages/main/types/server/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ export * from "./files";
1919
export * from "./caching";
2020
export * from "./shared";
2121

22-
export { RequestOptions, Tool } from "../../types/requests";
22+
export { RequestOptions, Tool, CodeExecutionTool } from "../../types/requests";
2323
export * from "../../types/content";
2424
export { FunctionCallingMode } from "../../types/enums";

0 commit comments

Comments
 (0)
Please sign in to comment.