Skip to content

Commit

Permalink
BREAKING_CHANGE: Remove disableAttribution and groundingAttributions …
Browse files Browse the repository at this point in the history
…from SDK interfaces

FUTURE_COPYBARA_INTEGRATE_REVIEW=#399 from googleapis:release-please--branches--main--components--vertexai d3e0deb
PiperOrigin-RevId: 662707816
  • Loading branch information
happy-qiao authored and copybara-github committed Aug 14, 2024
1 parent b27fcca commit c70d9e4
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 152 deletions.
7 changes: 0 additions & 7 deletions src/functions/post_fetch_processing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ function aggregateGroundingMetadataForCandidate(
}
const emptyGroundingMetadata: GroundingMetadata = {
webSearchQueries: [],
groundingAttributions: [],
retrievalQueries: [],
groundingChunks: [],
groundingSupports: [],
Expand All @@ -310,12 +309,6 @@ function aggregateGroundingMetadataForCandidate(
groundingMetadataChunk.webSearchQueries
);
}
if (groundingMetadataChunk.groundingAttributions) {
groundingMetadataAggregated.groundingAttributions =
groundingMetadataAggregated.groundingAttributions!.concat(
groundingMetadataChunk.groundingAttributions
);
}
if (groundingMetadataChunk.retrievalQueries) {
groundingMetadataAggregated.retrievalQueries =
groundingMetadataAggregated.retrievalQueries!.concat(
Expand Down
84 changes: 0 additions & 84 deletions src/functions/test/test_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,18 +201,6 @@ export const STREAM_RESPONSE_CHUNKS_1: GenerateContentResponse[] = [
},
groundingMetadata: {
webSearchQueries: ['query for former chunk for first candidate'],
groundingAttributions: [
{
segment: {
endIndex: 421,
},
confidenceScore: 0.8585608,
web: {
uri: 'url for former chunk for first candidate',
title: 'title for former chunk for first candidate',
},
},
],
groundingChunks: [
{
web: {
Expand Down Expand Up @@ -273,18 +261,6 @@ export const STREAM_RESPONSE_CHUNKS_1: GenerateContentResponse[] = [
},
groundingMetadata: {
webSearchQueries: ['query for former chunk for second candidate'],
groundingAttributions: [
{
segment: {
endIndex: 421,
},
confidenceScore: 0.8585608,
web: {
uri: 'url for former chunk for second candidate',
title: 'title for former chunk for second candidate',
},
},
],
groundingChunks: [
{
web: {
Expand Down Expand Up @@ -345,18 +321,6 @@ export const STREAM_RESPONSE_CHUNKS_1: GenerateContentResponse[] = [
finishReason: 'STOP',
groundingMetadata: {
webSearchQueries: ['query for later chunk for first candidate'],
groundingAttributions: [
{
segment: {
endIndex: 421,
},
confidenceScore: 0.8585608,
web: {
uri: 'url for later chunk for first candidate',
title: 'title for later chunk for first candidate',
},
},
],
groundingChunks: [
{
web: {
Expand Down Expand Up @@ -387,18 +351,6 @@ export const STREAM_RESPONSE_CHUNKS_1: GenerateContentResponse[] = [
finishReason: 'STOP',
groundingMetadata: {
webSearchQueries: ['query for later chunk for second candidate'],
groundingAttributions: [
{
segment: {
endIndex: 421,
},
confidenceScore: 0.8585608,
web: {
uri: 'url for later chunk for second candidate',
title: 'title for later chunk for second candidate',
},
},
],
groundingChunks: [
{
web: {
Expand Down Expand Up @@ -480,24 +432,6 @@ export const AGGREGATED_RESPONSE_STREAM_RESPONSE_CHUNKS_1: GenerateContentRespon
'query for former chunk for first candidate',
'query for later chunk for first candidate',
],
groundingAttributions: [
{
segment: {endIndex: 421},
confidenceScore: 0.8585608,
web: {
uri: 'url for former chunk for first candidate',
title: 'title for former chunk for first candidate',
},
},
{
segment: {endIndex: 421},
confidenceScore: 0.8585608,
web: {
uri: 'url for later chunk for first candidate',
title: 'title for later chunk for first candidate',
},
},
],
retrievalQueries: [],
groundingChunks: [
{
Expand Down Expand Up @@ -577,24 +511,6 @@ export const AGGREGATED_RESPONSE_STREAM_RESPONSE_CHUNKS_1: GenerateContentRespon
'query for former chunk for second candidate',
'query for later chunk for second candidate',
],
groundingAttributions: [
{
segment: {endIndex: 421},
confidenceScore: 0.8585608,
web: {
uri: 'url for former chunk for second candidate',
title: 'title for former chunk for second candidate',
},
},
{
segment: {endIndex: 421},
confidenceScore: 0.8585608,
web: {
uri: 'url for later chunk for second candidate',
title: 'title for later chunk for second candidate',
},
},
],
retrievalQueries: [],
groundingChunks: [
{
Expand Down
15 changes: 2 additions & 13 deletions src/types/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,6 @@ export declare interface GroundingMetadata {
webSearchQueries?: string[];
/** Optional. Queries executed by the retrieval tools. */
retrievalQueries?: string[];
/** @deprecated
* Optional. Array of {@link GroundingAttribution}
*/
groundingAttributions?: GroundingAttribution[];
/** Optional. Google search entry for the following-up web searches. {@link SearchEntryPoint} */
searchEntryPoint?: SearchEntryPoint;
/** Optional. Array of supporting references retrieved from specified grounding source. {@link GroundingChunk}. */
Expand Down Expand Up @@ -935,15 +931,8 @@ export declare interface Retrieval {
/**
* Tool to retrieve public web data for grounding, powered by Google.
*/
export declare interface GoogleSearchRetrieval {
/**
* @deprecated groundingAttributions field in {@link GroundingMetadata} is also deprecated.
* Optional. Disable using the result from this tool in detecting grounding
* attribution. This does not affect how the result is given to the model for
* generation.
*/
disableAttribution?: boolean;
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export declare interface GoogleSearchRetrieval {}

/**
* Retrieve from Vertex AI Search datastore for grounding.
Expand Down
48 changes: 0 additions & 48 deletions system_test/end_to_end_sample_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,6 @@ describe('generateContentStream', () => {
`sys test failure on generateContentStream for grounding metadata: ${groundingMetadata}`
);
if (groundingMetadata) {
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(
`sys test failure on generateContentStream for grounding attributions: ${groundingMetadata.groundingAttributions}`
);
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(
`sys test failure on generateContentStream for web search queries: ${groundingMetadata.webSearchQueries}`
);
Expand All @@ -557,9 +554,6 @@ describe('generateContentStream', () => {
`sys test failure on generateContentStream for grounding metadata: ${groundingMetadata}`
);
if (groundingMetadata) {
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(
`sys test failure on generateContentStream for grounding attributions: ${groundingMetadata.groundingAttributions}`
);
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(
`sys test failure on generateContentStream for web search queries: ${groundingMetadata.webSearchQueries}`
);
Expand All @@ -579,9 +573,6 @@ describe('generateContentStream', () => {
`sys test failure on generateContentStream in preview for grounding metadata: ${groundingMetadata}`
);
if (groundingMetadata) {
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(
`sys test failure on generateContentStream in preview for grounding attributions: ${groundingMetadata.groundingAttributions}`
);
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(
`sys test failure on generateContentStream in preview for web search queries: ${groundingMetadata.webSearchQueries}`
);
Expand All @@ -601,9 +592,6 @@ describe('generateContentStream', () => {
`sys test failure on generateContentStream in preview for grounding metadata: ${groundingMetadata}`
);
if (groundingMetadata) {
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(
`sys test failure on generateContentStream in preview for grounding attributions: ${groundingMetadata.groundingAttributions}`
);
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(
`sys test failure on generateContentStream in preview for web search queries: ${groundingMetadata.webSearchQueries}`
);
Expand Down Expand Up @@ -681,9 +669,6 @@ describe('generateContent', () => {
`sys test failure on generateContent for grounding metadata: ${groundingMetadata}`
);
if (groundingMetadata) {
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(
`sys test failure on generateContent for grounding attributions: ${groundingMetadata.groundingAttributions}`
);
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(
`sys test failure on generateContent for web search queries: ${groundingMetadata.webSearchQueries}`
);
Expand All @@ -703,9 +688,6 @@ describe('generateContent', () => {
`sys test failure on generateContent for grounding metadata: ${groundingMetadata}`
);
if (groundingMetadata) {
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(
`sys test failure on generateContent for grounding attributions: ${groundingMetadata.groundingAttributions}`
);
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(
`sys test failure on generateContent for web search queries: ${groundingMetadata.webSearchQueries}`
);
Expand All @@ -725,9 +707,6 @@ describe('generateContent', () => {
`sys test failure on generateContent in preview for grounding metadata: ${groundingMetadata}`
);
if (groundingMetadata) {
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(
`sys test failure on generateContent in preview for grounding attributions: ${groundingMetadata.groundingAttributions}`
);
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(
`sys test failure on generateContent in preview for web search queries: ${groundingMetadata.webSearchQueries}`
);
Expand All @@ -747,9 +726,6 @@ describe('generateContent', () => {
`sys test failure on generateContent in preview for grounding metadata: ${groundingMetadata}`
);
if (groundingMetadata) {
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(
`sys test failure on generateContent in preview for grounding attributions: ${groundingMetadata.groundingAttributions}`
);
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(
`sys test failure on generateContent in preview for web search queries: ${groundingMetadata.webSearchQueries}`
);
Expand Down Expand Up @@ -918,9 +894,6 @@ describe('sendMessage', () => {
`sys test failure on sendMessage for grounding metadata: ${groundingMetadata}`
);
if (groundingMetadata) {
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(
`sys test failure on sendMessage for grounding attributions: ${groundingMetadata.groundingAttributions}`
);
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(
`sys test failure on sendMessage for web search queries: ${groundingMetadata.webSearchQueries}`
);
Expand All @@ -940,9 +913,6 @@ describe('sendMessage', () => {
`sys test failure on sendMessage for grounding metadata: ${groundingMetadata}`
);
if (groundingMetadata) {
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(
`sys test failure on sendMessage for grounding attributions: ${groundingMetadata.groundingAttributions}`
);
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(
`sys test failure on sendMessage for web search queries: ${groundingMetadata.webSearchQueries}`
);
Expand All @@ -961,9 +931,6 @@ describe('sendMessage', () => {
`sys test failure on sendMessage in preview for grounding metadata: ${groundingMetadata}`
);
if (groundingMetadata) {
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(
`sys test failure on sendMessage in preview for grounding attributions: ${groundingMetadata.groundingAttributions}`
);
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(
`sys test failure on sendMessage in preview for web search queries: ${groundingMetadata.webSearchQueries}`
);
Expand All @@ -983,9 +950,6 @@ describe('sendMessage', () => {
`sys test failure on sendMessage in preview for grounding metadata: ${groundingMetadata}`
);
if (groundingMetadata) {
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(
`sys test failure on sendMessage in preview for grounding attributions: ${groundingMetadata.groundingAttributions}`
);
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(
`sys test failure on sendMessage in preview for web search queries: ${groundingMetadata.webSearchQueries}`
);
Expand Down Expand Up @@ -1189,9 +1153,6 @@ describe('sendMessageStream', () => {
`sys test failure on groundingMetadata, ${groundingMetadata}`
);
if (groundingMetadata) {
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(
`sys test failure on groundingMetadata.groundingAttributions, ${groundingMetadata.groundingAttributions}`
);
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(
`sys test failure on groundingMetadata.webSearchQueries, ${groundingMetadata.webSearchQueries}`
);
Expand All @@ -1211,9 +1172,6 @@ describe('sendMessageStream', () => {
`sys test failure on groundingMetadata, ${groundingMetadata}`
);
if (groundingMetadata) {
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(
`sys test failure on groundingMetadata.groundingAttributions, ${groundingMetadata.groundingAttributions}`
);
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(
`sys test failure on groundingMetadata.webSearchQueries, ${groundingMetadata.webSearchQueries}`
);
Expand All @@ -1232,9 +1190,6 @@ describe('sendMessageStream', () => {
`sys test failure on groundingMetadata in preview, ${groundingMetadata}`
);
if (groundingMetadata) {
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(
`sys test failure on groundingMetadata.groundingAttributions in preview, ${groundingMetadata.groundingAttributions}`
);
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(
`sys test failure on groundingMetadata.webSearchQueries in preview, ${groundingMetadata.webSearchQueries}`
);
Expand All @@ -1254,9 +1209,6 @@ describe('sendMessageStream', () => {
`sys test failure on groundingMetadata in preview, ${groundingMetadata}`
);
if (groundingMetadata) {
expect(!!groundingMetadata.groundingAttributions).toBeTruthy(
`sys test failure on groundingMetadata.groundingAttributions in preview, ${groundingMetadata.groundingAttributions}`
);
expect(!!groundingMetadata.webSearchQueries).toBeTruthy(
`sys test failure on groundingMetadata.webSearchQueries in preview, ${groundingMetadata.webSearchQueries}`
);
Expand Down

0 comments on commit c70d9e4

Please sign in to comment.