Search and Fetch
Suppose we want to plan a weekend trip using a GenAIScript that will help us plan by using web search to learn about things to do and the expected weather.
-
Use the
> GenAIScript: Create new script...
command in the command palette to create a new script. -
Start the script by defining the model and title:
-
Use the
webSearch
function to search for information about the destination. If you don’t have one, then you can search for the web pages manually and use the URLs directly in the call to thefetchText
function. -
webSearch
returns a list of URLs. UsefetchText
to fetch the contents of the 1st URL. -
fetchText
returns a lot of formatting HTML tags, etc. UserunPrompt
to call the LLM to clean out the tags and just keep the text. -
Repeat to get the latest weather info about your destination.
-
Replace the text
"TELL THE LLM WHAT TO DO..."
with what kind of vacation you want to plan. -
Press the “Run” button on the upper right corner of the editor to run the script. (You can run this script in this way because it takes no other input in
env.files
)) -
The output will be displayed in a new document tab.
Here’s an example of the output you might get:
Here’s the complete GenAIScript: