Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NASA Spinoff search #151

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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
3 changes: 2 additions & 1 deletion src/assistant/bidara.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions src/assistant/bidaraFunctions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ssSearch, genImage, imageToText, getFileType, getImagePatterns, patentSearch } from "./commonFunctions";
import { ssSearch, genImage, imageToText, getFileType, getImagePatterns, patentSearch, nasaSearch } from "./commonFunctions";
saanaz379 marked this conversation as resolved.
Show resolved Hide resolved

export async function bioSsSearch(params, context) {

Expand Down Expand Up @@ -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);
saanaz379 marked this conversation as resolved.
Show resolved Hide resolved
}
else if(functionDetails.name == "get_graph_paper_relevance_search") {
tmp = await bioSsSearch(functionDetails.arguments);
}
else if(functionDetails.name == "text_to_image") {
Expand Down
15 changes: 15 additions & 0 deletions src/assistant/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,18 @@ export const PATENT_SEARCH_FUNC = {
"required": ["query"],
}
}

export const GET_ALTERNATIVE_QUERY = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why was this name chosen for this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up running into that issue where BIDARA defaulted to doing a Semantic Scholar search even when my prompt was worded to direct it towards checking the Spinoff API. With the data that Spinoff provides, I feel like it could also be really useful to help the biomimeticist think outside of the current problem confines on where to look for information.
Screenshot 2024-06-20 at 2 05 10 PM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try different variations of the function description or name to see if it can consistently call your function when given instruction similar to , "find nasa technology that ..." or "find nasa spinoffs that ...".

"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"]
}
}
36 changes: 36 additions & 0 deletions src/assistant/commonFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
saanaz379 marked this conversation as resolved.
Show resolved Hide resolved
// 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);
}
}