Skip to content
Merged
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
6 changes: 6 additions & 0 deletions .changeset/poor-rings-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'firebase': minor
'@firebase/ai': minor
---

Added support for the URL context tool, which allows the model to access content from provided public web URLs to inform and enhance its responses.
44 changes: 43 additions & 1 deletion common/api-review/ai.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@ export interface GenerateContentCandidate {
index: number;
// (undocumented)
safetyRatings?: SafetyRating[];
// Warning: (ae-incompatible-release-tags) The symbol "urlContextMetadata" is marked as @public, but its signature references "URLContextMetadata" which is marked as @beta
//
// (undocumented)
urlContextMetadata?: URLContextMetadata;
}

// @public
Expand Down Expand Up @@ -596,6 +600,8 @@ export interface GoogleAIGenerateContentCandidate {
index: number;
// (undocumented)
safetyRatings?: SafetyRating[];
// (undocumented)
urlContextMetadata?: URLContextMetadata;
}

// Warning: (ae-internal-missing-underscore) The name "GoogleAIGenerateContentResponse" should be prefixed with an underscore because the declaration is marked as @internal
Expand Down Expand Up @@ -1300,8 +1306,10 @@ export interface ThinkingConfig {
thinkingBudget?: number;
}

// Warning: (ae-incompatible-release-tags) The symbol "Tool" is marked as @public, but its signature references "URLContextTool" which is marked as @beta
//
// @public
export type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool;
export type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool | URLContextTool;

// @public
export interface ToolConfig {
Expand All @@ -1312,6 +1320,38 @@ export interface ToolConfig {
// @public
export type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema | AnyOfSchema;

// @beta
export interface URLContext {
}

// @beta
export interface URLContextMetadata {
urlMetadata: URLMetadata[];
}

// @beta
export interface URLContextTool {
urlContext: URLContext;
}

// @beta
export interface URLMetadata {
retrievedUrl?: string;
urlRetrievalStatus?: URLRetrievalStatus;
}

// @beta
export const URLRetrievalStatus: {
URL_RETRIEVAL_STATUS_UNSPECIFIED: string;
URL_RETRIEVAL_STATUS_SUCCESS: string;
URL_RETRIEVAL_STATUS_ERROR: string;
URL_RETRIEVAL_STATUS_PAYWALL: string;
URL_RETRIEVAL_STATUS_UNSAFE: string;
};

// @beta
export type URLRetrievalStatus = (typeof URLRetrievalStatus)[keyof typeof URLRetrievalStatus];

// @public
export interface UsageMetadata {
// (undocumented)
Expand All @@ -1323,6 +1363,8 @@ export interface UsageMetadata {
// (undocumented)
promptTokensDetails?: ModalityTokenCount[];
thoughtsTokenCount?: number;
toolUsePromptTokenCount?: number;
toolUsePromptTokensDetails?: ModalityTokenCount[];
// (undocumented)
totalTokenCount: number;
}
Expand Down
8 changes: 8 additions & 0 deletions docs-devsite/_toc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ toc:
path: /docs/reference/js/ai.thinkingconfig.md
- title: ToolConfig
path: /docs/reference/js/ai.toolconfig.md
- title: URLContext
path: /docs/reference/js/ai.urlcontext.md
- title: URLContextMetadata
path: /docs/reference/js/ai.urlcontextmetadata.md
- title: URLContextTool
path: /docs/reference/js/ai.urlcontexttool.md
- title: URLMetadata
path: /docs/reference/js/ai.urlmetadata.md
- title: UsageMetadata
path: /docs/reference/js/ai.usagemetadata.md
- title: VertexAIBackend
Expand Down
9 changes: 9 additions & 0 deletions docs-devsite/ai.generatecontentcandidate.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface GenerateContentCandidate
| [groundingMetadata](./ai.generatecontentcandidate.md#generatecontentcandidategroundingmetadata) | [GroundingMetadata](./ai.groundingmetadata.md#groundingmetadata_interface) | |
| [index](./ai.generatecontentcandidate.md#generatecontentcandidateindex) | number | |
| [safetyRatings](./ai.generatecontentcandidate.md#generatecontentcandidatesafetyratings) | [SafetyRating](./ai.safetyrating.md#safetyrating_interface)<!-- -->\[\] | |
| [urlContextMetadata](./ai.generatecontentcandidate.md#generatecontentcandidateurlcontextmetadata) | [URLContextMetadata](./ai.urlcontextmetadata.md#urlcontextmetadata_interface) | |

## GenerateContentCandidate.citationMetadata

Expand Down Expand Up @@ -85,3 +86,11 @@ index: number;
```typescript
safetyRatings?: SafetyRating[];
```

## GenerateContentCandidate.urlContextMetadata

<b>Signature:</b>

```typescript
urlContextMetadata?: URLContextMetadata;
```
44 changes: 43 additions & 1 deletion docs-devsite/ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ The Firebase AI Web SDK.
| [TextPart](./ai.textpart.md#textpart_interface) | Content part interface if the part represents a text string. |
| [ThinkingConfig](./ai.thinkingconfig.md#thinkingconfig_interface) | Configuration for "thinking" behavior of compatible Gemini models.<!-- -->Certain models utilize a thinking process before generating a response. This allows them to reason through complex problems and plan a more coherent and accurate answer. |
| [ToolConfig](./ai.toolconfig.md#toolconfig_interface) | Tool config. This config is shared for all tools provided in the request. |
| [URLContext](./ai.urlcontext.md#urlcontext_interface) | <b><i>(Public Preview)</i></b> Specifies the URL Context configuration. |
| [URLContextMetadata](./ai.urlcontextmetadata.md#urlcontextmetadata_interface) | <b><i>(Public Preview)</i></b> Metadata related to [URLContextTool](./ai.urlcontexttool.md#urlcontexttool_interface)<!-- -->. |
| [URLContextTool](./ai.urlcontexttool.md#urlcontexttool_interface) | <b><i>(Public Preview)</i></b> A tool that allows you to provide additional context to the models in the form of public web URLs. By including URLs in your request, the Gemini model will access the content from those pages to inform and enhance its response. |
| [URLMetadata](./ai.urlmetadata.md#urlmetadata_interface) | <b><i>(Public Preview)</i></b> Metadata for a single URL retrieved by the [URLContextTool](./ai.urlcontexttool.md#urlcontexttool_interface) tool. |
| [UsageMetadata](./ai.usagemetadata.md#usagemetadata_interface) | Usage metadata about a [GenerateContentResponse](./ai.generatecontentresponse.md#generatecontentresponse_interface)<!-- -->. |
| [VideoMetadata](./ai.videometadata.md#videometadata_interface) | Describes the input video content. |
| [VoiceConfig](./ai.voiceconfig.md#voiceconfig_interface) | <b><i>(Public Preview)</i></b> Configuration for the voice to used in speech synthesis. |
Expand Down Expand Up @@ -165,6 +169,7 @@ The Firebase AI Web SDK.
| [POSSIBLE\_ROLES](./ai.md#possible_roles) | Possible roles. |
| [ResponseModality](./ai.md#responsemodality) | <b><i>(Public Preview)</i></b> Generation modalities to be returned in generation responses. |
| [SchemaType](./ai.md#schematype) | Contains the list of OpenAPI data types as defined by the [OpenAPI specification](https://swagger.io/docs/specification/data-models/data-types/) |
| [URLRetrievalStatus](./ai.md#urlretrievalstatus) | <b><i>(Public Preview)</i></b> The status of a URL retrieval. |

## Type Aliases

Expand Down Expand Up @@ -197,6 +202,7 @@ The Firebase AI Web SDK.
| [SchemaType](./ai.md#schematype) | Contains the list of OpenAPI data types as defined by the [OpenAPI specification](https://swagger.io/docs/specification/data-models/data-types/) |
| [Tool](./ai.md#tool) | Defines a tool that model can call to access external knowledge. |
| [TypedSchema](./ai.md#typedschema) | A type that includes all specific Schema types. |
| [URLRetrievalStatus](./ai.md#urlretrievalstatus) | <b><i>(Public Preview)</i></b> The status of a URL retrieval. |

## function(app, ...)

Expand Down Expand Up @@ -752,6 +758,27 @@ SchemaType: {
}
```

## URLRetrievalStatus

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

The status of a URL retrieval.

<b>URL\_RETRIEVAL\_STATUS\_UNSPECIFIED:</b> Unspecified retrieval status. <br/> <b>URL\_RETRIEVAL\_STATUS\_SUCCESS:</b> The URL retrieval was successful. <br/> <b>URL\_RETRIEVAL\_STATUS\_ERROR:</b> The URL retrieval failed. <br/> <b>URL\_RETRIEVAL\_STATUS\_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall. <br/> <b>URL\_RETRIEVAL\_STATUS\_UNSAFE:</b> The URL retrieval failed because the content is unsafe. <br/>

<b>Signature:</b>

```typescript
URLRetrievalStatus: {
URL_RETRIEVAL_STATUS_UNSPECIFIED: string;
URL_RETRIEVAL_STATUS_SUCCESS: string;
URL_RETRIEVAL_STATUS_ERROR: string;
URL_RETRIEVAL_STATUS_PAYWALL: string;
URL_RETRIEVAL_STATUS_UNSAFE: string;
}
```

## AIErrorCode

Standardized error codes that [AIError](./ai.aierror.md#aierror_class) can have.
Expand Down Expand Up @@ -1031,7 +1058,7 @@ Defines a tool that model can call to access external knowledge.
<b>Signature:</b>

```typescript
export type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool;
export type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool | URLContextTool;
```

## TypedSchema
Expand All @@ -1043,3 +1070,18 @@ A type that includes all specific Schema types.
```typescript
export type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema | AnyOfSchema;
```

## URLRetrievalStatus

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

The status of a URL retrieval.

<b>URL\_RETRIEVAL\_STATUS\_UNSPECIFIED:</b> Unspecified retrieval status. <br/> <b>URL\_RETRIEVAL\_STATUS\_SUCCESS:</b> The URL retrieval was successful. <br/> <b>URL\_RETRIEVAL\_STATUS\_ERROR:</b> The URL retrieval failed. <br/> <b>URL\_RETRIEVAL\_STATUS\_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall. <br/> <b>URL\_RETRIEVAL\_STATUS\_UNSAFE:</b> The URL retrieval failed because the content is unsafe. <br/>

<b>Signature:</b>

```typescript
export type URLRetrievalStatus = (typeof URLRetrievalStatus)[keyof typeof URLRetrievalStatus];
```
22 changes: 22 additions & 0 deletions docs-devsite/ai.urlcontext.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Project: /docs/reference/js/_project.yaml
Book: /docs/reference/_book.yaml
page_type: reference

{% comment %}
DO NOT EDIT THIS FILE!
This is generated by the JS SDK team, and any local changes will be
overwritten. Changes should be made in the source code at
https://github.com/firebase/firebase-js-sdk
{% endcomment %}

# URLContext interface
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

Specifies the URL Context configuration.

<b>Signature:</b>

```typescript
export interface URLContext
```
41 changes: 41 additions & 0 deletions docs-devsite/ai.urlcontextmetadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Project: /docs/reference/js/_project.yaml
Book: /docs/reference/_book.yaml
page_type: reference

{% comment %}
DO NOT EDIT THIS FILE!
This is generated by the JS SDK team, and any local changes will be
overwritten. Changes should be made in the source code at
https://github.com/firebase/firebase-js-sdk
{% endcomment %}

# URLContextMetadata interface
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

Metadata related to [URLContextTool](./ai.urlcontexttool.md#urlcontexttool_interface)<!-- -->.

<b>Signature:</b>

```typescript
export interface URLContextMetadata
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [urlMetadata](./ai.urlcontextmetadata.md#urlcontextmetadataurlmetadata) | [URLMetadata](./ai.urlmetadata.md#urlmetadata_interface)<!-- -->\[\] | <b><i>(Public Preview)</i></b> List of URL metadata used to provide context to the Gemini model. |

## URLContextMetadata.urlMetadata

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

List of URL metadata used to provide context to the Gemini model.

<b>Signature:</b>

```typescript
urlMetadata: URLMetadata[];
```
41 changes: 41 additions & 0 deletions docs-devsite/ai.urlcontexttool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Project: /docs/reference/js/_project.yaml
Book: /docs/reference/_book.yaml
page_type: reference

{% comment %}
DO NOT EDIT THIS FILE!
This is generated by the JS SDK team, and any local changes will be
overwritten. Changes should be made in the source code at
https://github.com/firebase/firebase-js-sdk
{% endcomment %}

# URLContextTool interface
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

A tool that allows you to provide additional context to the models in the form of public web URLs. By including URLs in your request, the Gemini model will access the content from those pages to inform and enhance its response.

<b>Signature:</b>

```typescript
export interface URLContextTool
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [urlContext](./ai.urlcontexttool.md#urlcontexttoolurlcontext) | [URLContext](./ai.urlcontext.md#urlcontext_interface) | <b><i>(Public Preview)</i></b> Specifies the URL Context configuration. |

## URLContextTool.urlContext

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

Specifies the URL Context configuration.

<b>Signature:</b>

```typescript
urlContext: URLContext;
```
55 changes: 55 additions & 0 deletions docs-devsite/ai.urlmetadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Project: /docs/reference/js/_project.yaml
Book: /docs/reference/_book.yaml
page_type: reference

{% comment %}
DO NOT EDIT THIS FILE!
This is generated by the JS SDK team, and any local changes will be
overwritten. Changes should be made in the source code at
https://github.com/firebase/firebase-js-sdk
{% endcomment %}

# URLMetadata interface
> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

Metadata for a single URL retrieved by the [URLContextTool](./ai.urlcontexttool.md#urlcontexttool_interface) tool.

<b>Signature:</b>

```typescript
export interface URLMetadata
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [retrievedUrl](./ai.urlmetadata.md#urlmetadataretrievedurl) | string | <b><i>(Public Preview)</i></b> The retrieved URL. |
| [urlRetrievalStatus](./ai.urlmetadata.md#urlmetadataurlretrievalstatus) | [URLRetrievalStatus](./ai.md#urlretrievalstatus) | <b><i>(Public Preview)</i></b> The status of the URL retrieval. |

## URLMetadata.retrievedUrl

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

The retrieved URL.

<b>Signature:</b>

```typescript
retrievedUrl?: string;
```

## URLMetadata.urlRetrievalStatus

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

The status of the URL retrieval.

<b>Signature:</b>

```typescript
urlRetrievalStatus?: URLRetrievalStatus;
```
Loading
Loading