From d7f56e357981396b7be662efc1ef1dfacbe392fd Mon Sep 17 00:00:00 2001
From: Abhinav Rau
- 2. Use the "Synthetic Q&A" Tab to generate Questions and Answers from documents stored in GCS.
+ 2. Use the "Synthetic Q&A" Tab to generate Questions and Answers
OR
- If you have your own test cases then put them in a seperate sheet.
-
- 3. Reference the Questions and Answers in the "Query" and "Expected Summary" columns. And reference the expected link in the "Expected Link1" column.
-
- 4. Fill in the ID column for all rows you want the tests to run on.
+ If you have your own test cases copy into the test case table.
- 5. Fill in Config Parameters for your GCP environment in the Config Table.
- Adjust the different config parameters like "Preamble" etc.
- for your use case.
-
- 6. Click button below to run tests starting from first row.
- How to use
Note: Tests will stop when it sees an empty ID value.
@@ -103,18 +93,13 @@- 2. Fill in "FileUri" and "mimeType" columns you want questions and answers to be generated from. Valid mimeTypes for Gemini are documented here. -
-- 3. Fill in the ID column for all rows you want the tests to run on. + 2. Fill in "FileUri" column with GCS doc link. Valid file types.
- 4. Fill in Config Parameters for your GCP environment in the Config Table. - Adjust the prompt and "System Instructions", "Prompt" and "Q&A Quality Prompt" + 3. Fill in Config Parameters for your GCP environment in the Config Table. + Adjust the Prompt and Q&A Quality Prompt for your use case. -
-- 5. Click button below to generate Q&As starting from first row. +
Note: Generation will stop when it sees an empty ID value. @@ -137,18 +122,12 @@
- 2. Fill in "Text to Summarize" column with Text to summarize. + 2. Fill in "Context" column with Text to summarize.
- 3. Fill in the ID column for all rows you want the rows you want summarized. -
-- 4. Fill in Config Parameters for your GCP environment in the Config Table. - Adjust the prompt and "System Instructions", "Prompt" and "Summarization Quality Prompt" + 3. Fill in Config Parameters for your GCP environment in the Config Table. + Adjust the Prompt and Summarization Quality Prompt for your use case. -
-- 5. Click button below to generate summarizes starting from first row.
Note: Generation will stop when it sees an empty ID value. diff --git a/test/data/search/search_extractive_answer/test_vai_search_extractive_answer_request.json b/test/data/search/search_extractive_answer/test_vai_search_extractive_answer_request.json index 1db4b5f..2afebd5 100644 --- a/test/data/search/search_extractive_answer/test_vai_search_extractive_answer_request.json +++ b/test/data/search/search_extractive_answer/test_vai_search_extractive_answer_request.json @@ -13,7 +13,7 @@ "ignoreAdversarialQuery": "true", "ignoreNonSummarySeekingQuery": "true", "modelPromptSpec": { - "preamble": "" + "preamble": "You are an expert financial analyst. Only use the data returned from documents. All finance numbers must be reported in billions, millions or thousands. Be brief. Answer should be no more than 2 sentences please." }, "modelSpec": { "version": "gemini-1.0-pro-001/answer_gen/v1" diff --git a/test/test_search_runner.js b/test/test_search_runner.js index 9b70d67..57d76d5 100644 --- a/test/test_search_runner.js +++ b/test/test_search_runner.js @@ -35,7 +35,7 @@ export var testCaseRows = vertex_ai_search_testTableHeader.concat([ "link2", // Actual Link 2 "link3", // Actual Link 3 ], - [ + [ "2", // ID "What is Google's revenue for the year ending December 31, 2021", //Query "Revenue is $2.2 billion", //Expected Summary @@ -319,7 +319,7 @@ describe("When Search Run Tests is clicked ", () => { // Get the config parameters from the config table const config = await excelSearchRunner.getSearchConfig(); - const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/dataStores/${config.vertexAISearchDataStoreName}/servingConfigs/default_search:search`; + const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/engines/${config.vertexAISearchAppId}/servingConfigs/default_search:search`; // Prepare the request response mock the call to VertexAISearch const { requestJson, expectedResponse } = mockDiscoveryEngineRequestResponse( 1, @@ -338,7 +338,7 @@ describe("When Search Run Tests is clicked ", () => { const grouding_url = `https://discoveryengine.googleapis.com/v1/projects/${config.vertexAIProjectID}/locations/global/groundingConfigs/default_grounding_config:check`; // Prepare the request response mock the call to VertexAISearch - const { requestJson: grouding_requestJson, expectedResponse: grouding_expectedResponse } = + const { requestJson: grouding_requestJson, expectedResponse: grouding_expectedResponse } = mockDiscoveryEngineRequestResponse( 1, grouding_url, @@ -364,7 +364,7 @@ describe("When Search Run Tests is clicked ", () => { // check if vertex ai is called for summary match const callsToSummaryMatch = fetchMock.calls().filter((call) => call[0] === summaryMatchUrl); // Check if body is sent correctly to vertex ai search - expect(callsToSummaryMatch[0][1].body!==null).toBe(true); + expect(callsToSummaryMatch[0][1].body !== null).toBe(true); // check if vertex ai is called for check grounding match const callsToCheckGrounding = fetchMock.calls().filter((call) => call[0] === grouding_url); @@ -373,7 +373,6 @@ describe("When Search Run Tests is clicked ", () => { // Check if values get populated for each test case for (let i = 1; i < testCaseRows.length; i++) { - // Match Actual Summary const { cell: actual_summary_cell, col_index: actual_summary_col_index } = getCellAndColumnIndexByName("Actual Summary", mockTestData, i); @@ -467,7 +466,7 @@ describe("When Search Run Tests is clicked ", () => { // Get the config parameters from the config table const config = await excelSearchRunner.getSearchConfig(); - const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/dataStores/${config.vertexAISearchDataStoreName}/servingConfigs/default_search:search`; + const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/engines/${config.vertexAISearchAppId}/servingConfigs/default_search:search`; // Prepare the request response mock the call to VertexAISearch const { requestJson, expectedResponse } = mockDiscoveryEngineRequestResponse( diff --git a/test/test_vertex_ai.js b/test/test_vertex_ai.js index 0f42e82..1855980 100644 --- a/test/test_vertex_ai.js +++ b/test/test_vertex_ai.js @@ -177,7 +177,8 @@ describe("When callVertexAISearch is called", () => { const query = "What is Google's revenue for the year ending December 31, 2021"; const config = { accessToken: "YOUR_ACCESS_TOKEN", - preamble: "", + preamble: + "You are an expert financial analyst. Only use the data returned from documents. All finance numbers must be reported in billions, millions or thousands. Be brief. Answer should be no more than 2 sentences please.", extractiveContentSpec: { maxExtractiveAnswerCount: "2", maxExtractiveSegmentCount: "0", @@ -188,11 +189,11 @@ describe("When callVertexAISearch is called", () => { ignoreAdversarialQuery: true, ignoreNonSummarySeekingQuery: true, vertexAISearchProjectNumber: "YOUR_PROJECT_NUMBER", - vertexAISearchDataStoreName: "YOUR_DATASTORE_NAME", + vertexAISearchAppId: "YOUR_DATASTORE_NAME", vertexAILocation: "YOUR_LOCATION", }; - const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/dataStores/${config.vertexAISearchDataStoreName}/servingConfigs/default_search:search`; + const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/engines/${config.vertexAISearchAppId}/servingConfigs/default_search:search`; await testRequestResponse( 1, url, @@ -217,10 +218,10 @@ describe("When callVertexAISearch is called", () => { ignoreAdversarialQuery: true, ignoreNonSummarySeekingQuery: true, vertexAISearchProjectNumber: "YOUR_PROJECT_NUMBER", - vertexAISearchDataStoreName: "YOUR_DATASTORE_NAME", + vertexAISearchAppId: "YOUR_DATASTORE_NAME", vertexAILocation: "YOUR_LOCATION", }; - const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/dataStores/${config.vertexAISearchDataStoreName}/servingConfigs/default_search:search`; + const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/engines/${config.vertexAISearchAppId}/servingConfigs/default_search:search`; await testRequestResponse( 1, url, @@ -245,10 +246,10 @@ describe("When callVertexAISearch is called", () => { ignoreAdversarialQuery: true, ignoreNonSummarySeekingQuery: true, vertexAISearchProjectNumber: "YOUR_PROJECT_NUMBER", - vertexAISearchDataStoreName: "YOUR_DATASTORE_NAME", + vertexAISearchAppId: "YOUR_DATASTORE_NAME", vertexAILocation: "YOUR_LOCATION", }; - const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/dataStores/${config.vertexAISearchDataStoreName}/servingConfigs/default_search:search`; + const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/engines/${config.vertexAISearchAppId}/servingConfigs/default_search:search`; await testRequestResponse( 1, url, @@ -330,10 +331,10 @@ describe("When callVertexAISearch is called", () => { ignoreAdversarialQuery: true, ignoreNonSummarySeekingQuery: true, vertexAISearchProjectNumber: "YOUR_PROJECT_NUMBER", - vertexAISearchDataStoreName: "YOUR_DATASTORE_NAME", + vertexAISearchAppId: "YOUR_DATASTORE_NAME", vertexAILocation: "YOUR_LOCATION", }; - const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/dataStores/${config.vertexAISearchDataStoreName}/servingConfigs/default_search:search`; + const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/engines/${config.vertexAISearchAppId}/servingConfigs/default_search:search`; const { requestJson, expectedResponse } = mockDiscoveryEngineRequestResponse( 1, url, @@ -368,10 +369,10 @@ describe("When callVertexAISearch is called", () => { ignoreAdversarialQuery: true, ignoreNonSummarySeekingQuery: true, vertexAISearchProjectNumber: "YOUR_PROJECT_NUMBER", - vertexAISearchDataStoreName: "YOUR_DATASTORE_NAME", + vertexAISearchAppId: "YOUR_DATASTORE_NAME", vertexAILocation: "YOUR_LOCATION", }; - const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/dataStores/${config.vertexAISearchDataStoreName}/servingConfigs/default_search:search`; + const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/engines/${config.vertexAISearchAppId}/servingConfigs/default_search:search`; const { requestJson, expectedResponse } = mockDiscoveryEngineRequestResponse( 1, url, @@ -402,11 +403,11 @@ describe("When callVertexAISearch is called", () => { ignoreAdversarialQuery: false, ignoreNonSummarySeekingQuery: false, vertexAISearchProjectNumber: "YOUR_PROJECT_NUMBER", - vertexAISearchDataStoreName: "YOUR_DATASTORE_NAME", + vertexAISearchAppId: "YOUR_DATASTORE_NAME", vertexAILocation: "YOUR_LOCATION", }; - const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/dataStores/${config.vertexAISearchDataStoreName}/servingConfigs/default_search:search`; + const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/engines/${config.vertexAISearchAppId}/servingConfigs/default_search:search`; var response = fetchMock.postOnce(url, { throws: new Error("Mocked error"), @@ -437,10 +438,10 @@ describe("When callVertexAISearch is called", () => { ignoreAdversarialQuery: true, ignoreNonSummarySeekingQuery: true, vertexAISearchProjectNumber: "YOUR_PROJECT_NUMBER", - vertexAISearchDataStoreName: "YOUR_DATASTORE_NAME", + vertexAISearchAppId: "YOUR_DATASTORE_NAME", vertexAILocation: "YOUR_LOCATION", }; - const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/dataStores/${config.vertexAISearchDataStoreName}/servingConfigs/default_search:search`; + const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/engines/${config.vertexAISearchAppId}/servingConfigs/default_search:search`; const { requestJson, expectedResponse } = mockDiscoveryEngineRequestResponse( 1, url, @@ -472,10 +473,10 @@ describe("When callVertexAISearch is called", () => { ignoreAdversarialQuery: true, ignoreNonSummarySeekingQuery: true, vertexAISearchProjectNumber: "YOUR_PROJECT_NUMBER", - vertexAISearchDataStoreName: "YOUR_DATASTORE_NAME", + vertexAISearchAppId: "YOUR_DATASTORE_NAME", vertexAILocation: "YOUR_LOCATION", }; - const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/dataStores/${config.vertexAISearchDataStoreName}/servingConfigs/default_search:search`; + const url = `https://discoveryengine.googleapis.com/v1alpha/projects/${config.vertexAISearchProjectNumber}/locations/global/collections/default_collection/engines/${config.vertexAISearchAppId}/servingConfigs/default_search:search`; const { requestJson, expectedResponse } = mockDiscoveryEngineRequestResponse( 1, url,