Skip to content

Commit 83ba3d3

Browse files
authored
Merge 5a07a34 into b97eab3
2 parents b97eab3 + 5a07a34 commit 83ba3d3

18 files changed

+678
-24
lines changed

.changeset/five-kids-grow.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'firebase': minor
3+
'@firebase/ai': minor
4+
---
5+
6+
Add support for Grounding with Google Search.

common/api-review/ai.api.md

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,15 @@ export interface GoogleAIGenerateContentResponse {
486486
usageMetadata?: UsageMetadata;
487487
}
488488

489+
// @public
490+
export interface GoogleSearch {
491+
}
492+
493+
// @public
494+
export interface GoogleSearchTool {
495+
googleSearch: GoogleSearch;
496+
}
497+
489498
// @public @deprecated (undocumented)
490499
export interface GroundingAttribution {
491500
// (undocumented)
@@ -498,16 +507,29 @@ export interface GroundingAttribution {
498507
web?: WebAttribution;
499508
}
500509

510+
// @public
511+
export interface GroundingChunk {
512+
web?: WebGroundingChunk;
513+
}
514+
501515
// @public
502516
export interface GroundingMetadata {
503517
// @deprecated (undocumented)
504518
groundingAttributions: GroundingAttribution[];
505-
// (undocumented)
519+
groundingChunks?: GroundingChunk[];
520+
groundingSupports?: GroundingSupport[];
521+
// @deprecated (undocumented)
506522
retrievalQueries?: string[];
507-
// (undocumented)
523+
searchEntryPoint?: SearchEntrypoint;
508524
webSearchQueries?: string[];
509525
}
510526

527+
// @public
528+
export interface GroundingSupport {
529+
groundingChunkIndices?: number[];
530+
segment?: Segment;
531+
}
532+
511533
// @public
512534
export enum HarmBlockMethod {
513535
PROBABILITY = "PROBABILITY",
@@ -858,14 +880,17 @@ export enum SchemaType {
858880
STRING = "string"
859881
}
860882

861-
// @public (undocumented)
883+
// @public
884+
export interface SearchEntrypoint {
885+
renderedContent?: string;
886+
}
887+
888+
// @public
862889
export interface Segment {
863-
// (undocumented)
864890
endIndex: number;
865-
// (undocumented)
866891
partIndex: number;
867-
// (undocumented)
868892
startIndex: number;
893+
text: string;
869894
}
870895

871896
// @public
@@ -902,7 +927,7 @@ export interface TextPart {
902927
}
903928

904929
// @public
905-
export type Tool = FunctionDeclarationsTool;
930+
export type Tool = FunctionDeclarationsTool | GoogleSearchTool;
906931

907932
// @public
908933
export interface ToolConfig {
@@ -962,5 +987,12 @@ export interface WebAttribution {
962987
uri: string;
963988
}
964989

990+
// @public
991+
export interface WebGroundingChunk {
992+
domain?: string;
993+
title?: string;
994+
uri?: string;
995+
}
996+
965997

966998
```

docs-devsite/_toc.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,18 @@ toc:
7676
path: /docs/reference/js/ai.generativemodel.md
7777
- title: GoogleAIBackend
7878
path: /docs/reference/js/ai.googleaibackend.md
79+
- title: GoogleSearch
80+
path: /docs/reference/js/ai.googlesearch.md
81+
- title: GoogleSearchTool
82+
path: /docs/reference/js/ai.googlesearchtool.md
7983
- title: GroundingAttribution
8084
path: /docs/reference/js/ai.groundingattribution.md
85+
- title: GroundingChunk
86+
path: /docs/reference/js/ai.groundingchunk.md
8187
- title: GroundingMetadata
8288
path: /docs/reference/js/ai.groundingmetadata.md
89+
- title: GroundingSupport
90+
path: /docs/reference/js/ai.groundingsupport.md
8391
- title: ImagenGCSImage
8492
path: /docs/reference/js/ai.imagengcsimage.md
8593
- title: ImagenGenerationConfig
@@ -130,6 +138,8 @@ toc:
130138
path: /docs/reference/js/ai.schemarequest.md
131139
- title: SchemaShared
132140
path: /docs/reference/js/ai.schemashared.md
141+
- title: SearchEntrypoint
142+
path: /docs/reference/js/ai.searchentrypoint.md
133143
- title: Segment
134144
path: /docs/reference/js/ai.segment.md
135145
- title: StartChatParams
@@ -150,6 +160,8 @@ toc:
150160
path: /docs/reference/js/ai.videometadata.md
151161
- title: WebAttribution
152162
path: /docs/reference/js/ai.webattribution.md
163+
- title: WebGroundingChunk
164+
path: /docs/reference/js/ai.webgroundingchunk.md
153165
- title: analytics
154166
path: /docs/reference/js/analytics.md
155167
section:

docs-devsite/ai.googlesearch.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Project: /docs/reference/js/_project.yaml
2+
Book: /docs/reference/_book.yaml
3+
page_type: reference
4+
5+
{% comment %}
6+
DO NOT EDIT THIS FILE!
7+
This is generated by the JS SDK team, and any local changes will be
8+
overwritten. Changes should be made in the source code at
9+
https://github.com/firebase/firebase-js-sdk
10+
{% endcomment %}
11+
12+
# GoogleSearch interface
13+
Configuration for the [GoogleSearchTool](./ai.googlesearchtool.md#googlesearchtool_interface)<!-- -->.
14+
15+
Currently, this interface is empty and serves as a placeholder for future configuration options.
16+
17+
<b>Signature:</b>
18+
19+
```typescript
20+
export declare interface GoogleSearch
21+
```

docs-devsite/ai.googlesearchtool.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Project: /docs/reference/js/_project.yaml
2+
Book: /docs/reference/_book.yaml
3+
page_type: reference
4+
5+
{% comment %}
6+
DO NOT EDIT THIS FILE!
7+
This is generated by the JS SDK team, and any local changes will be
8+
overwritten. Changes should be made in the source code at
9+
https://github.com/firebase/firebase-js-sdk
10+
{% endcomment %}
11+
12+
# GoogleSearchTool interface
13+
A tool that allows the generative model to connect to Google Search to access and incorporate up-to-date information from the web into its responses.
14+
15+
When using Grounding with Google Search, you may receive a response with data generated from Google's search engine. This response is a "Grounded Result" subject to the Grounding with Google Search terms in the [Service Specific Terms](https://cloud.google.com/terms/service-terms)<!-- -->.
16+
17+
<b>Signature:</b>
18+
19+
```typescript
20+
export declare interface GoogleSearchTool
21+
```
22+
23+
## Properties
24+
25+
| Property | Type | Description |
26+
| --- | --- | --- |
27+
| [googleSearch](./ai.googlesearchtool.md#googlesearchtoolgooglesearch) | [GoogleSearch](./ai.googlesearch.md#googlesearch_interface) | Specifies the Google Search configuration. Currently, this is an empty object, but it's reserved for future configuration options. |
28+
29+
## GoogleSearchTool.googleSearch
30+
31+
Specifies the Google Search configuration. Currently, this is an empty object, but it's reserved for future configuration options.
32+
33+
<b>Signature:</b>
34+
35+
```typescript
36+
googleSearch: GoogleSearch;
37+
```

docs-devsite/ai.groundingchunk.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Project: /docs/reference/js/_project.yaml
2+
Book: /docs/reference/_book.yaml
3+
page_type: reference
4+
5+
{% comment %}
6+
DO NOT EDIT THIS FILE!
7+
This is generated by the JS SDK team, and any local changes will be
8+
overwritten. Changes should be made in the source code at
9+
https://github.com/firebase/firebase-js-sdk
10+
{% endcomment %}
11+
12+
# GroundingChunk interface
13+
Represents a chunk of retrieved data that supports a claim in the model's response. This is part of the grounding information provided when grounding is enabled.
14+
15+
Important: If using Grounding with Google Search, you are required to comply with the [Service Specific Terms](https://cloud.google.com/terms/service-terms) for "Grounding with Google Search".
16+
17+
<b>Signature:</b>
18+
19+
```typescript
20+
export interface GroundingChunk
21+
```
22+
23+
## Properties
24+
25+
| Property | Type | Description |
26+
| --- | --- | --- |
27+
| [web](./ai.groundingchunk.md#groundingchunkweb) | [WebGroundingChunk](./ai.webgroundingchunk.md#webgroundingchunk_interface) | Contains details if the grounding chunk is from a web source. |
28+
29+
## GroundingChunk.web
30+
31+
Contains details if the grounding chunk is from a web source.
32+
33+
<b>Signature:</b>
34+
35+
```typescript
36+
web?: WebGroundingChunk;
37+
```

docs-devsite/ai.groundingmetadata.md

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ https://github.com/firebase/firebase-js-sdk
1010
{% endcomment %}
1111

1212
# GroundingMetadata interface
13-
Metadata returned to client when grounding is enabled.
13+
Metadata returned when grounding is enabled.
14+
15+
Currently, the only way to use grounding is to include a [GoogleSearchTool](./ai.googlesearchtool.md#googlesearchtool_interface) in your [GenerationConfig](./ai.generationconfig.md#generationconfig_interface)<!-- -->.
16+
17+
Important: If using Grounding with Google Search, you are required to comply with the [Service Specific Terms](https://cloud.google.com/terms/service-terms) for "Grounding with Google Search".
1418

1519
<b>Signature:</b>
1620

@@ -23,13 +27,17 @@ export interface GroundingMetadata
2327
| Property | Type | Description |
2428
| --- | --- | --- |
2529
| [groundingAttributions](./ai.groundingmetadata.md#groundingmetadatagroundingattributions) | [GroundingAttribution](./ai.groundingattribution.md#groundingattribution_interface)<!-- -->\[\] | |
30+
| [groundingChunks](./ai.groundingmetadata.md#groundingmetadatagroundingchunks) | [GroundingChunk](./ai.groundingchunk.md#groundingchunk_interface)<!-- -->\[\] | A list of [GroundingChunk](./ai.groundingchunk.md#groundingchunk_interface) objects. Each chunk represents a piece of retrieved content (e.g. from a web page). that the model used to ground its response.<!-- -->Important: If using Grounding with Google Search, you are required to comply with the [Service Specific Terms](https://cloud.google.com/terms/service-terms) for "Grounding with Google Search". |
31+
| [groundingSupports](./ai.groundingmetadata.md#groundingmetadatagroundingsupports) | [GroundingSupport](./ai.groundingsupport.md#groundingsupport_interface)<!-- -->\[\] | A list of [GroundingSupport](./ai.groundingsupport.md#groundingsupport_interface) objects. Each object details how specific segments of the model's response are supported by the <code>groundingChunks</code>.<!-- -->Important: If using Grounding with Google Search, you are required to comply with the [Service Specific Terms](https://cloud.google.com/terms/service-terms) for "Grounding with Google Search". |
2632
| [retrievalQueries](./ai.groundingmetadata.md#groundingmetadataretrievalqueries) | string\[\] | |
27-
| [webSearchQueries](./ai.groundingmetadata.md#groundingmetadatawebsearchqueries) | string\[\] | |
33+
| [searchEntryPoint](./ai.groundingmetadata.md#groundingmetadatasearchentrypoint) | [SearchEntrypoint](./ai.searchentrypoint.md#searchentrypoint_interface) | Google search entry point for web searches. This contains An HTML/CSS snippet that \*must\* be embedded in an app to display a Google Search Entry point for follow-up web searches related to the model's "Grounded Response".<!-- -->Important: If using Grounding with Google Search, you are required to comply with the [Service Specific Terms](https://cloud.google.com/terms/service-terms) for "Grounding with Google Search". |
34+
| [webSearchQueries](./ai.groundingmetadata.md#groundingmetadatawebsearchqueries) | string\[\] | A list of web search queries that the model performed to gather the grounding information. These can be used to allow users to explore the search results themselves.<!-- -->Important: If using Grounding with Google Search, you are required to comply with the [Service Specific Terms](https://cloud.google.com/terms/service-terms) for "Grounding with Google Search". |
2835

2936
## GroundingMetadata.groundingAttributions
3037

3138
> Warning: This API is now obsolete.
3239
>
40+
> Use [GroundingChunk](./ai.groundingchunk.md#groundingchunk_interface) instead.
3341
>
3442

3543
<b>Signature:</b>
@@ -38,16 +46,61 @@ export interface GroundingMetadata
3846
groundingAttributions: GroundingAttribution[];
3947
```
4048

49+
## GroundingMetadata.groundingChunks
50+
51+
A list of [GroundingChunk](./ai.groundingchunk.md#groundingchunk_interface) objects. Each chunk represents a piece of retrieved content (e.g. from a web page). that the model used to ground its response.
52+
53+
Important: If using Grounding with Google Search, you are required to comply with the [Service Specific Terms](https://cloud.google.com/terms/service-terms) for "Grounding with Google Search".
54+
55+
<b>Signature:</b>
56+
57+
```typescript
58+
groundingChunks?: GroundingChunk[];
59+
```
60+
61+
## GroundingMetadata.groundingSupports
62+
63+
A list of [GroundingSupport](./ai.groundingsupport.md#groundingsupport_interface) objects. Each object details how specific segments of the model's response are supported by the `groundingChunks`<!-- -->.
64+
65+
Important: If using Grounding with Google Search, you are required to comply with the [Service Specific Terms](https://cloud.google.com/terms/service-terms) for "Grounding with Google Search".
66+
67+
<b>Signature:</b>
68+
69+
```typescript
70+
groundingSupports?: GroundingSupport[];
71+
```
72+
4173
## GroundingMetadata.retrievalQueries
4274

75+
> Warning: This API is now obsolete.
76+
>
77+
> Use [GroundingSupport](./ai.groundingsupport.md#groundingsupport_interface) instead.
78+
>
79+
4380
<b>Signature:</b>
4481

4582
```typescript
4683
retrievalQueries?: string[];
4784
```
4885

86+
## GroundingMetadata.searchEntryPoint
87+
88+
Google search entry point for web searches. This contains An HTML/CSS snippet that \*must\* be embedded in an app to display a Google Search Entry point for follow-up web searches related to the model's "Grounded Response".
89+
90+
Important: If using Grounding with Google Search, you are required to comply with the [Service Specific Terms](https://cloud.google.com/terms/service-terms) for "Grounding with Google Search".
91+
92+
<b>Signature:</b>
93+
94+
```typescript
95+
searchEntryPoint?: SearchEntrypoint;
96+
```
97+
4998
## GroundingMetadata.webSearchQueries
5099

100+
A list of web search queries that the model performed to gather the grounding information. These can be used to allow users to explore the search results themselves.
101+
102+
Important: If using Grounding with Google Search, you are required to comply with the [Service Specific Terms](https://cloud.google.com/terms/service-terms) for "Grounding with Google Search".
103+
51104
<b>Signature:</b>
52105

53106
```typescript

docs-devsite/ai.groundingsupport.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Project: /docs/reference/js/_project.yaml
2+
Book: /docs/reference/_book.yaml
3+
page_type: reference
4+
5+
{% comment %}
6+
DO NOT EDIT THIS FILE!
7+
This is generated by the JS SDK team, and any local changes will be
8+
overwritten. Changes should be made in the source code at
9+
https://github.com/firebase/firebase-js-sdk
10+
{% endcomment %}
11+
12+
# GroundingSupport interface
13+
Provides information about how a specific segment of the model's response is supported by the retrieved grounding chunks.
14+
15+
Important: If using Grounding with Google Search, you are required to comply with the [Service Specific Terms](https://cloud.google.com/terms/service-terms) for "Grounding with Google Search".
16+
17+
<b>Signature:</b>
18+
19+
```typescript
20+
export interface GroundingSupport
21+
```
22+
23+
## Properties
24+
25+
| Property | Type | Description |
26+
| --- | --- | --- |
27+
| [groundingChunkIndices](./ai.groundingsupport.md#groundingsupportgroundingchunkindices) | number\[\] | A list of indices that refer to specific [GroundingChunk](./ai.groundingchunk.md#groundingchunk_interface) objects within the [GroundingMetadata.groundingChunks](./ai.groundingmetadata.md#groundingmetadatagroundingchunks) array. These referenced chunks are the sources that support the claim made in the associated <code>segment</code> of the response. For example, an array <code>[1, 3, 4]</code> means that <code>groundingChunks[1]</code>, <code>groundingChunks[3]</code>, and <code>groundingChunks[4]</code> are the retrieved content supporting this part of the response. |
28+
| [segment](./ai.groundingsupport.md#groundingsupportsegment) | [Segment](./ai.segment.md#segment_interface) | Specifies the segment of the model's response content that this grounding support pertains to. |
29+
30+
## GroundingSupport.groundingChunkIndices
31+
32+
A list of indices that refer to specific [GroundingChunk](./ai.groundingchunk.md#groundingchunk_interface) objects within the [GroundingMetadata.groundingChunks](./ai.groundingmetadata.md#groundingmetadatagroundingchunks) array. These referenced chunks are the sources that support the claim made in the associated `segment` of the response. For example, an array `[1, 3, 4]` means that `groundingChunks[1]`<!-- -->, `groundingChunks[3]`<!-- -->, and `groundingChunks[4]` are the retrieved content supporting this part of the response.
33+
34+
<b>Signature:</b>
35+
36+
```typescript
37+
groundingChunkIndices?: number[];
38+
```
39+
40+
## GroundingSupport.segment
41+
42+
Specifies the segment of the model's response content that this grounding support pertains to.
43+
44+
<b>Signature:</b>
45+
46+
```typescript
47+
segment?: Segment;
48+
```

0 commit comments

Comments
 (0)