Skip to content

Commit

Permalink
Add CodeExecutionTool to Tool type (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 committed Jul 1, 2024
1 parent 5f9e393 commit 0c23bb3
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/thin-eggs-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@google/generative-ai": patch
---

Add `CodeExecutionTool` to `Tool` type.
7 changes: 6 additions & 1 deletion common/api-review/generative-ai-server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ export interface CodeExecutionResultPart {
text?: never;
}

// @public
export interface CodeExecutionTool {
codeExecution: {};
}

// @public
export interface Content {
// (undocumented)
Expand Down Expand Up @@ -462,7 +467,7 @@ export interface TextPart {
}

// @public
export type Tool = FunctionDeclarationsTool;
export type Tool = FunctionDeclarationsTool | CodeExecutionTool;

// @public
export interface ToolConfig {
Expand Down
2 changes: 1 addition & 1 deletion common/api-review/generative-ai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ export interface TextPart {
}

// @public
export type Tool = FunctionDeclarationsTool;
export type Tool = FunctionDeclarationsTool | CodeExecutionTool;

// @public
export interface ToolConfig {
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/main/generative-ai.tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Defines a tool that model can call to access external knowledge.
**Signature:**

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [CodeExecutionTool](./generative-ai.codeexecutiontool.md) &gt; [codeExecution](./generative-ai.codeexecutiontool.codeexecution.md)

## CodeExecutionTool.codeExecution property

Provide an empty object to enable code execution. This field may have subfields added in the future.

**Signature:**

```typescript
codeExecution: {};
```
20 changes: 20 additions & 0 deletions docs/reference/server/generative-ai.codeexecutiontool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [CodeExecutionTool](./generative-ai.codeexecutiontool.md)

## CodeExecutionTool interface

Enables the model to execute code as part of generation.

**Signature:**

```typescript
export interface CodeExecutionTool
```

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [codeExecution](./generative-ai.codeexecutiontool.codeexecution.md) | | {} | Provide an empty object to enable code execution. This field may have subfields added in the future. |

1 change: 1 addition & 0 deletions docs/reference/server/generative-ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
| [CachedContentUpdateParams](./generative-ai.cachedcontentupdateparams.md) | Params to pass to [GoogleAICacheManager.update()](./generative-ai.googleaicachemanager.update.md)<!-- -->. |
| [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>. |
| [CodeExecutionResultPart](./generative-ai.codeexecutionresultpart.md) | Content part containing the result of executed code. |
| [CodeExecutionTool](./generative-ai.codeexecutiontool.md) | Enables the model to execute code as part of generation. |
| [Content](./generative-ai.content.md) | Content type for both prompts and response candidates. |
| [ErrorDetails](./generative-ai.errordetails.md) | Details object that may be included in an error response. |
| [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. |
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/server/generative-ai.tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Defines a tool that model can call to access external knowledge.
**Signature:**

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

2 changes: 1 addition & 1 deletion packages/main/types/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export interface RequestOptions {
* Defines a tool that model can call to access external knowledge.
* @public
*/
export declare type Tool = FunctionDeclarationsTool;
export declare type Tool = FunctionDeclarationsTool | CodeExecutionTool;

/**
* Enables the model to execute code as part of generation.
Expand Down
2 changes: 1 addition & 1 deletion packages/main/types/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export * from "./files";
export * from "./caching";
export * from "./shared";

export { RequestOptions, Tool } from "../../types/requests";
export { RequestOptions, Tool, CodeExecutionTool } from "../../types/requests";
export * from "../../types/content";
export { FunctionCallingMode } from "../../types/enums";

0 comments on commit 0c23bb3

Please sign in to comment.