From 39fff51e2720b932ff740b7683e37837ae4613bd Mon Sep 17 00:00:00 2001 From: saanaz379 <79679653+saanaz379@users.noreply.github.com> Date: Tue, 18 Jun 2024 15:25:58 -0400 Subject: [PATCH 1/6] add GET_ALTERNATIVE_QUERY function to BIDARA --- src/assistant/bidara.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/assistant/bidara.js b/src/assistant/bidara.js index a36a1f8..a083711 100644 --- a/src/assistant/bidara.js +++ b/src/assistant/bidara.js @@ -1,4 +1,4 @@ -import { PAPER_SEARCH_FUNC, TEXT_TO_IMAGE, IMAGE_TO_TEXT, GET_FILE_TYPE, GET_IMAGE_PATTERNS, PATENT_SEARCH_FUNC } from "./common" +import { PAPER_SEARCH_FUNC, TEXT_TO_IMAGE, IMAGE_TO_TEXT, GET_FILE_TYPE, GET_IMAGE_PATTERNS, PATENT_SEARCH_FUNC, GET_ALTERNATIVE_QUERY } from "./common" const PROD_NAME = "BIDARA"; const TEST_NAME = "BIDARA-TEST"; @@ -101,6 +101,7 @@ export const FUNCTIONS = [ { type: "function", function: GET_FILE_TYPE }, { type: "function", function: GET_IMAGE_PATTERNS }, { type: "function", function: PATENT_SEARCH_FUNC }, + { type: "function", function: GET_ALTERNATIVE_QUERY } ] export const HISTORY = [ From ca812c524cce77592c0e7a9dc0bc7258a11b1c35 Mon Sep 17 00:00:00 2001 From: saanaz379 <79679653+saanaz379@users.noreply.github.com> Date: Tue, 18 Jun 2024 15:27:34 -0400 Subject: [PATCH 2/6] Update bidaraFunctions.js --- src/assistant/bidaraFunctions.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/assistant/bidaraFunctions.js b/src/assistant/bidaraFunctions.js index 513948f..025683e 100644 --- a/src/assistant/bidaraFunctions.js +++ b/src/assistant/bidaraFunctions.js @@ -1,4 +1,4 @@ -import { ssSearch, genImage, imageToText, getFileType, getImagePatterns, patentSearch } from "./commonFunctions"; +import { ssSearch, genImage, imageToText, getFileType, getImagePatterns, patentSearch, nasaSearch } from "./commonFunctions"; export async function bioSsSearch(params, context) { @@ -28,7 +28,10 @@ export async function bioSsSearch(params, context) { } export async function callFunc(functionDetails, context) { let tmp = ''; - if(functionDetails.name == "get_graph_paper_relevance_search") { + if (functionDetails.name == "get_alternative_query") { + tmp = await nasaSearch(functionDetails.arguments, context); + } + else if(functionDetails.name == "get_graph_paper_relevance_search") { tmp = await bioSsSearch(functionDetails.arguments); } else if(functionDetails.name == "text_to_image") { From 05885f001ec33dbf761ced4fc4e3329058cd95ae Mon Sep 17 00:00:00 2001 From: saanaz379 <79679653+saanaz379@users.noreply.github.com> Date: Tue, 18 Jun 2024 15:28:09 -0400 Subject: [PATCH 3/6] Add function definition for GET_ALTERNATIVE_QUERY --- src/assistant/common.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/assistant/common.js b/src/assistant/common.js index b1f2963..bdb3156 100644 --- a/src/assistant/common.js +++ b/src/assistant/common.js @@ -140,3 +140,18 @@ export const PATENT_SEARCH_FUNC = { "required": ["query"], } } + +export const GET_ALTERNATIVE_QUERY = { + "name": "get_alternative_query", + "description": "Search the NASA Spinoffs database for projects similar to the user queried and how that technology was applied in different domains.", + "parameters": { + "type": "object", + "properties": { + "query": { + "type": "string", + "description": "Query containing keywords describing the project the user is currently thinking about.", + } + }, + "required": ["query"] + } +} From 2f6cf7f3dfdf362053400209b91df02038dcbf57 Mon Sep 17 00:00:00 2001 From: saanaz379 <79679653+saanaz379@users.noreply.github.com> Date: Tue, 18 Jun 2024 15:29:21 -0400 Subject: [PATCH 4/6] Add the NASA spinoffs API call in --- src/assistant/commonFunctions.js | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/assistant/commonFunctions.js b/src/assistant/commonFunctions.js index 86b1132..032c0df 100644 --- a/src/assistant/commonFunctions.js +++ b/src/assistant/commonFunctions.js @@ -268,3 +268,39 @@ async function backoffExponential(callback, maxRetries, retries, retryOffset) { function waitFor(milliseconds) { return new Promise((resolve) => setTimeout(resolve, milliseconds)); } + +// Offer this functionality as a way to expand the biomimeticist's perspective during step 1a. +// helps the biomimeticist brainstorm and see how previous NASA technologies have been applied +// outside of their intended domain and how that learning can be brought into their own project +export async function nasaSearch(params, context) { + // Retrieve the keywords for the intended project query + let searchParams = JSON.parse(params); + if ("parameters" in searchParams) { + searchParams = searchParams.parameters; + } + let keywords = JSON.stringify(searchParams.query); + if (!keywords) { + return "The query keywords passed were not found. Please try again."; + } + + // Search the techtransfer spinoff API to find similar projects that NASA has worked on + const fullUrl = `https://api.nasa.gov/techtransfer/spinoff/?${keywords}&api_key=DEMO_KEY`.replace(/['"]+/g, ''); // the url doesn't allow quotation marks around the keywords + let nasaProducts = ""; + try { + const response = await fetch(fullUrl); + const data = await response.json(); + + // Response format is: + // 1. The headline of the article about NASA's project + // 2. An abstract describing how this project deviates from the norm + // 3. The primary NASA center of the project + nasaProducts = data.results.map(product => + [product[2], + product[3], + product[9]] + ); + return `Return the following results in a modular format, including the NASA center they are in, as well as a short description of what they do: ${nasaProducts}`; + } catch (error) { + console.error(error); + } +} From b861b1b02ef6345ed5fc63bdc5f753934f43d769 Mon Sep 17 00:00:00 2001 From: saanaz379 <79679653+saanaz379@users.noreply.github.com> Date: Thu, 20 Jun 2024 14:12:23 -0400 Subject: [PATCH 5/6] Update name of nasaSearch --- src/assistant/commonFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assistant/commonFunctions.js b/src/assistant/commonFunctions.js index 032c0df..09e4aec 100644 --- a/src/assistant/commonFunctions.js +++ b/src/assistant/commonFunctions.js @@ -272,7 +272,7 @@ function waitFor(milliseconds) { // Offer this functionality as a way to expand the biomimeticist's perspective during step 1a. // helps the biomimeticist brainstorm and see how previous NASA technologies have been applied // outside of their intended domain and how that learning can be brought into their own project -export async function nasaSearch(params, context) { +export async function nasaSpinoffSearch(params, context) { // Retrieve the keywords for the intended project query let searchParams = JSON.parse(params); if ("parameters" in searchParams) { From 17d180df03edd5333bc0097185fcd6c86ded8577 Mon Sep 17 00:00:00 2001 From: saanaz379 <79679653+saanaz379@users.noreply.github.com> Date: Thu, 20 Jun 2024 15:53:20 -0400 Subject: [PATCH 6/6] Update bidaraFunctions.js --- src/assistant/bidaraFunctions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/assistant/bidaraFunctions.js b/src/assistant/bidaraFunctions.js index 025683e..f4277da 100644 --- a/src/assistant/bidaraFunctions.js +++ b/src/assistant/bidaraFunctions.js @@ -1,4 +1,4 @@ -import { ssSearch, genImage, imageToText, getFileType, getImagePatterns, patentSearch, nasaSearch } from "./commonFunctions"; +import { ssSearch, genImage, imageToText, getFileType, getImagePatterns, patentSearch, nasaSpinoffSearch } from "./commonFunctions"; export async function bioSsSearch(params, context) { @@ -29,7 +29,7 @@ export async function bioSsSearch(params, context) { export async function callFunc(functionDetails, context) { let tmp = ''; if (functionDetails.name == "get_alternative_query") { - tmp = await nasaSearch(functionDetails.arguments, context); + tmp = await nasaSpinoffSearch(functionDetails.arguments, context); } else if(functionDetails.name == "get_graph_paper_relevance_search") { tmp = await bioSsSearch(functionDetails.arguments);