Skip to content
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

Add the Content caching feature #167

Merged
merged 15 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 13 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
406 changes: 406 additions & 0 deletions common/api-review/generative-ai-server.api.md

Large diffs are not rendered by default.

648 changes: 648 additions & 0 deletions common/api-review/generative-ai.api.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
/**
* (REQUIRED) Whether to generate an API report.
*/
"enabled": false,
"enabled": true,

/**
* The filename for the API report files. It will be combined with "reportFolder" or "reportTempFolder" to produce
Expand Down
13 changes: 13 additions & 0 deletions docs/reference/main/generative-ai.cachedcontent.createtime.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; [CachedContent](./generative-ai.cachedcontent.md) &gt; [createTime](./generative-ai.cachedcontent.createtime.md)

## CachedContent.createTime property

`CachedContent` creation time in ISO string format.

**Signature:**

```typescript
createTime?: string;
```
24 changes: 24 additions & 0 deletions docs/reference/main/generative-ai.cachedcontent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

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

## CachedContent interface

Describes `CachedContent` interface for sending to the server (if creating) or received from the server (using getters or list methods).

**Signature:**

```typescript
export interface CachedContent extends CachedContentBase
```
**Extends:** [CachedContentBase](./generative-ai.cachedcontentbase.md)

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [createTime?](./generative-ai.cachedcontent.createtime.md) | | string | _(Optional)_ <code>CachedContent</code> creation time in ISO string format. |
| [name?](./generative-ai.cachedcontent.name.md) | | string | _(Optional)_ |
| [ttl?](./generative-ai.cachedcontent.ttl.md) | | string | _(Optional)_ protobuf.Duration format (ex. "3.0001s"). |
| [updateTime?](./generative-ai.cachedcontent.updatetime.md) | | string | _(Optional)_ <code>CachedContent</code> update time in ISO string format. |

11 changes: 11 additions & 0 deletions docs/reference/main/generative-ai.cachedcontent.name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [CachedContent](./generative-ai.cachedcontent.md) &gt; [name](./generative-ai.cachedcontent.name.md)

## CachedContent.name property

**Signature:**

```typescript
name?: string;
```
13 changes: 13 additions & 0 deletions docs/reference/main/generative-ai.cachedcontent.ttl.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; [CachedContent](./generative-ai.cachedcontent.md) &gt; [ttl](./generative-ai.cachedcontent.ttl.md)

## CachedContent.ttl property

protobuf.Duration format (ex. "3.0001s").

**Signature:**

```typescript
ttl?: string;
```
13 changes: 13 additions & 0 deletions docs/reference/main/generative-ai.cachedcontent.updatetime.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; [CachedContent](./generative-ai.cachedcontent.md) &gt; [updateTime](./generative-ai.cachedcontent.updatetime.md)

## CachedContent.updateTime property

`CachedContent` update time in ISO string format.

**Signature:**

```typescript
updateTime?: string;
```
11 changes: 11 additions & 0 deletions docs/reference/main/generative-ai.cachedcontentbase.contents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [CachedContentBase](./generative-ai.cachedcontentbase.md) &gt; [contents](./generative-ai.cachedcontentbase.contents.md)

## CachedContentBase.contents property

**Signature:**

```typescript
contents: Content[];
```
11 changes: 11 additions & 0 deletions docs/reference/main/generative-ai.cachedcontentbase.displayname.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [CachedContentBase](./generative-ai.cachedcontentbase.md) &gt; [displayName](./generative-ai.cachedcontentbase.displayname.md)

## CachedContentBase.displayName property

**Signature:**

```typescript
displayName?: string;
```
13 changes: 13 additions & 0 deletions docs/reference/main/generative-ai.cachedcontentbase.expiretime.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; [CachedContentBase](./generative-ai.cachedcontentbase.md) &gt; [expireTime](./generative-ai.cachedcontentbase.expiretime.md)

## CachedContentBase.expireTime property

Expiration time in ISO string format. Specify either this or `ttlSeconds` when creating a `CachedContent`<!-- -->.

**Signature:**

```typescript
expireTime?: string;
```
25 changes: 25 additions & 0 deletions docs/reference/main/generative-ai.cachedcontentbase.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

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

## CachedContentBase interface


**Signature:**

```typescript
export interface CachedContentBase
```

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [contents](./generative-ai.cachedcontentbase.contents.md) | | [Content](./generative-ai.content.md)<!-- -->\[\] | |
| [displayName?](./generative-ai.cachedcontentbase.displayname.md) | | string | _(Optional)_ |
| [expireTime?](./generative-ai.cachedcontentbase.expiretime.md) | | string | _(Optional)_ Expiration time in ISO string format. Specify either this or <code>ttlSeconds</code> when creating a <code>CachedContent</code>. |
| [model?](./generative-ai.cachedcontentbase.model.md) | | string | _(Optional)_ |
| [systemInstruction?](./generative-ai.cachedcontentbase.systeminstruction.md) | | string \| [Part](./generative-ai.part.md) \| [Content](./generative-ai.content.md) | _(Optional)_ |
| [toolConfig?](./generative-ai.cachedcontentbase.toolconfig.md) | | [ToolConfig](./generative-ai.toolconfig.md) | _(Optional)_ |
| [tools?](./generative-ai.cachedcontentbase.tools.md) | | [Tool](./generative-ai.tool.md)<!-- -->\[\] | _(Optional)_ |

11 changes: 11 additions & 0 deletions docs/reference/main/generative-ai.cachedcontentbase.model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [CachedContentBase](./generative-ai.cachedcontentbase.md) &gt; [model](./generative-ai.cachedcontentbase.model.md)

## CachedContentBase.model property

**Signature:**

```typescript
model?: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [CachedContentBase](./generative-ai.cachedcontentbase.md) &gt; [systemInstruction](./generative-ai.cachedcontentbase.systeminstruction.md)

## CachedContentBase.systemInstruction property

**Signature:**

```typescript
systemInstruction?: string | Part | Content;
```
11 changes: 11 additions & 0 deletions docs/reference/main/generative-ai.cachedcontentbase.toolconfig.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [CachedContentBase](./generative-ai.cachedcontentbase.md) &gt; [toolConfig](./generative-ai.cachedcontentbase.toolconfig.md)

## CachedContentBase.toolConfig property

**Signature:**

```typescript
toolConfig?: ToolConfig;
```
11 changes: 11 additions & 0 deletions docs/reference/main/generative-ai.cachedcontentbase.tools.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [CachedContentBase](./generative-ai.cachedcontentbase.md) &gt; [tools](./generative-ai.cachedcontentbase.tools.md)

## CachedContentBase.tools property

**Signature:**

```typescript
tools?: Tool[];
```
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; [GenerateContentRequest](./generative-ai.generatecontentrequest.md) &gt; [cachedContent](./generative-ai.generatecontentrequest.cachedcontent.md)

## GenerateContentRequest.cachedContent property

This is the name of a `CachedContent` and not the cache object itself.

**Signature:**

```typescript
cachedContent?: string;
```
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface GenerateContentRequest extends BaseParams

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [cachedContent?](./generative-ai.generatecontentrequest.cachedcontent.md) | | string | _(Optional)_ This is the name of a <code>CachedContent</code> and not the cache object itself. |
| [contents](./generative-ai.generatecontentrequest.contents.md) | | [Content](./generative-ai.content.md)<!-- -->\[\] | |
| [systemInstruction?](./generative-ai.generatecontentrequest.systeminstruction.md) | | string \| [Part](./generative-ai.part.md) \| [Content](./generative-ai.content.md) | _(Optional)_ |
| [toolConfig?](./generative-ai.generatecontentrequest.toolconfig.md) | | [ToolConfig](./generative-ai.toolconfig.md) | _(Optional)_ |
Expand Down
11 changes: 11 additions & 0 deletions docs/reference/main/generative-ai.generativemodel.cachedcontent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [GenerativeModel](./generative-ai.generativemodel.md) &gt; [cachedContent](./generative-ai.generativemodel.cachedcontent.md)

## GenerativeModel.cachedContent property

**Signature:**

```typescript
cachedContent: CachedContent;
```
1 change: 1 addition & 0 deletions docs/reference/main/generative-ai.generativemodel.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export declare class GenerativeModel
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [apiKey](./generative-ai.generativemodel.apikey.md) | | string | |
| [cachedContent](./generative-ai.generativemodel.cachedcontent.md) | | [CachedContent](./generative-ai.cachedcontent.md) | |
| [generationConfig](./generative-ai.generativemodel.generationconfig.md) | | [GenerationConfig](./generative-ai.generationconfig.md) | |
| [model](./generative-ai.generativemodel.model.md) | | string | |
| [requestOptions](./generative-ai.generativemodel.requestoptions.md) | | [RequestOptions](./generative-ai.requestoptions.md) | |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [GoogleGenerativeAI](./generative-ai.googlegenerativeai.md) &gt; [getGenerativeModelFromCachedContent](./generative-ai.googlegenerativeai.getgenerativemodelfromcachedcontent.md)

## GoogleGenerativeAI.getGenerativeModelFromCachedContent() method

Creates a [GenerativeModel](./generative-ai.generativemodel.md) instance from provided content cache.

**Signature:**

```typescript
getGenerativeModelFromCachedContent(cachedContent: CachedContent, requestOptions?: RequestOptions): GenerativeModel;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| cachedContent | [CachedContent](./generative-ai.cachedcontent.md) | |
| requestOptions | [RequestOptions](./generative-ai.requestoptions.md) | _(Optional)_ |

**Returns:**

[GenerativeModel](./generative-ai.generativemodel.md)

1 change: 1 addition & 0 deletions docs/reference/main/generative-ai.googlegenerativeai.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ export declare class GoogleGenerativeAI
| Method | Modifiers | Description |
| --- | --- | --- |
| [getGenerativeModel(modelParams, requestOptions)](./generative-ai.googlegenerativeai.getgenerativemodel.md) | | Gets a [GenerativeModel](./generative-ai.generativemodel.md) instance for the provided model name. |
| [getGenerativeModelFromCachedContent(cachedContent, requestOptions)](./generative-ai.googlegenerativeai.getgenerativemodelfromcachedcontent.md) | | Creates a [GenerativeModel](./generative-ai.generativemodel.md) instance from provided content cache. |

4 changes: 3 additions & 1 deletion docs/reference/main/generative-ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
| [BaseParams](./generative-ai.baseparams.md) | Base parameters for a number of methods. |
| [BatchEmbedContentsRequest](./generative-ai.batchembedcontentsrequest.md) | Params for calling [GenerativeModel.batchEmbedContents()](./generative-ai.generativemodel.batchembedcontents.md) |
| [BatchEmbedContentsResponse](./generative-ai.batchembedcontentsresponse.md) | Response from calling [GenerativeModel.batchEmbedContents()](./generative-ai.generativemodel.batchembedcontents.md)<!-- -->. |
| [CachedContent](./generative-ai.cachedcontent.md) | Describes <code>CachedContent</code> interface for sending to the server (if creating) or received from the server (using getters or list methods). |
| [CachedContentBase](./generative-ai.cachedcontentbase.md) | |
| [CitationMetadata](./generative-ai.citationmetadata.md) | Citation metadata that may be found on a [GenerateContentCandidate](./generative-ai.generatecontentcandidate.md)<!-- -->. |
| [CitationSource](./generative-ai.citationsource.md) | A single citation source. |
| [Content](./generative-ai.content.md) | Content type for both prompts and response candidates. |
Expand Down Expand Up @@ -68,7 +70,7 @@
| [ModelParams](./generative-ai.modelparams.md) | Params passed to [GoogleGenerativeAI.getGenerativeModel()](./generative-ai.googlegenerativeai.getgenerativemodel.md)<!-- -->. |
| [PromptFeedback](./generative-ai.promptfeedback.md) | If the prompt was blocked, this will be populated with <code>blockReason</code> and the relevant <code>safetyRatings</code>. |
| [RequestOptions](./generative-ai.requestoptions.md) | Params passed to getGenerativeModel() or GoogleAIFileManager(). |
| [ResponseSchema](./generative-ai.responseschema.md) | Schema passed to [GenerationConfig.responseSchema](./generative-ai.generationconfig.responseschema.md) |
| [ResponseSchema](./generative-ai.responseschema.md) | Schema passed to <code>GenerationConfig.responseSchema</code> |
| [SafetyRating](./generative-ai.safetyrating.md) | A safety rating associated with a [GenerateContentCandidate](./generative-ai.generatecontentcandidate.md) |
| [SafetySetting](./generative-ai.safetysetting.md) | Safety setting that can be sent as part of request parameters. |
| [Schema](./generative-ai.schema.md) | Schema is used to define the format of input/output data. Represents a select subset of an OpenAPI 3.0 schema object. More fields may be added in the future as needed. |
Expand Down
11 changes: 11 additions & 0 deletions docs/reference/main/generative-ai.modelparams.cachedcontent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ModelParams](./generative-ai.modelparams.md) &gt; [cachedContent](./generative-ai.modelparams.cachedcontent.md)

## ModelParams.cachedContent property

**Signature:**

```typescript
cachedContent?: CachedContent;
```
1 change: 1 addition & 0 deletions docs/reference/main/generative-ai.modelparams.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface ModelParams extends BaseParams

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [cachedContent?](./generative-ai.modelparams.cachedcontent.md) | | [CachedContent](./generative-ai.cachedcontent.md) | _(Optional)_ |
| [model](./generative-ai.modelparams.model.md) | | string | |
| [systemInstruction?](./generative-ai.modelparams.systeminstruction.md) | | string \| [Part](./generative-ai.part.md) \| [Content](./generative-ai.content.md) | _(Optional)_ |
| [toolConfig?](./generative-ai.modelparams.toolconfig.md) | | [ToolConfig](./generative-ai.toolconfig.md) | _(Optional)_ |
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/main/generative-ai.responseschema.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## ResponseSchema interface

Schema passed to [GenerationConfig.responseSchema](./generative-ai.generationconfig.responseschema.md)
Schema passed to `GenerationConfig.responseSchema`

**Signature:**

Expand Down
13 changes: 13 additions & 0 deletions docs/reference/main/generative-ai.startchatparams.cachedcontent.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; [StartChatParams](./generative-ai.startchatparams.md) &gt; [cachedContent](./generative-ai.startchatparams.cachedcontent.md)

## StartChatParams.cachedContent property

This is the name of a `CachedContent` and not the cache object itself.

**Signature:**

```typescript
cachedContent?: string;
```
1 change: 1 addition & 0 deletions docs/reference/main/generative-ai.startchatparams.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface StartChatParams extends BaseParams

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [cachedContent?](./generative-ai.startchatparams.cachedcontent.md) | | string | _(Optional)_ This is the name of a <code>CachedContent</code> and not the cache object itself. |
| [history?](./generative-ai.startchatparams.history.md) | | [Content](./generative-ai.content.md)<!-- -->\[\] | _(Optional)_ |
| [systemInstruction?](./generative-ai.startchatparams.systeminstruction.md) | | string \| [Part](./generative-ai.part.md) \| [Content](./generative-ai.content.md) | _(Optional)_ |
| [toolConfig?](./generative-ai.startchatparams.toolconfig.md) | | [ToolConfig](./generative-ai.toolconfig.md) | _(Optional)_ |
Expand Down
13 changes: 13 additions & 0 deletions docs/reference/server/generative-ai.cachedcontent.createtime.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; [CachedContent](./generative-ai.cachedcontent.md) &gt; [createTime](./generative-ai.cachedcontent.createtime.md)

## CachedContent.createTime property

`CachedContent` creation time in ISO string format.

**Signature:**

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

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

## CachedContent interface

Describes `CachedContent` interface for sending to the server (if creating) or received from the server (using getters or list methods).

**Signature:**

```typescript
export interface CachedContent extends CachedContentBase
```
**Extends:** [CachedContentBase](./generative-ai.cachedcontentbase.md)

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [createTime?](./generative-ai.cachedcontent.createtime.md) | | string | _(Optional)_ <code>CachedContent</code> creation time in ISO string format. |
| [name?](./generative-ai.cachedcontent.name.md) | | string | _(Optional)_ |
| [ttl?](./generative-ai.cachedcontent.ttl.md) | | string | _(Optional)_ protobuf.Duration format (ex. "3.0001s"). |
| [updateTime?](./generative-ai.cachedcontent.updatetime.md) | | string | _(Optional)_ <code>CachedContent</code> update time in ISO string format. |

11 changes: 11 additions & 0 deletions docs/reference/server/generative-ai.cachedcontent.name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [CachedContent](./generative-ai.cachedcontent.md) &gt; [name](./generative-ai.cachedcontent.name.md)

## CachedContent.name property

**Signature:**

```typescript
name?: string;
```
Loading
Loading