Searches the web for your question, reads the top results, and writes a Google Doc brief citing every source it used.
Uses
Google Docs
OpenAITavily
Research a question into a sourced brief
researchQuestion to blank.Set researchQuestion to blank.maxSearchResults to 8.Set maxSearchResults to 8.maxSourcesToRead to 4.Set maxSourcesToRead to 4.charactersPerSource to 6000.Set charactersPerSource to 6000.researchQuestion. Save it as searchResponse.Search the web for researchQuestion. Save it as searchResponse.
Number of results: maxSearchResultssearchResults to searchResponse.results.Set searchResults to searchResponse.results.searchResults and save it as resultsFound.Count the items in searchResults and save it as resultsFound.resultsFound is 0If resultsFound is 0Yes
No
No steps
sourceExtracts to an empty list.Set sourceExtracts to an empty list.sourceList to an empty list.Set sourceList to an empty list.sourcesRead to 0.Set sourcesRead to 0.resultsSkipped to 0.Set resultsSkipped to 0.result in searchResults:For each result in searchResults:sourcesRead is greater than or equal to maxSourcesToReadIf sourcesRead is greater than or equal to maxSourcesToReadYes
No
No steps
pageUrl to blank.Set pageUrl to blank.pageTitle to blank.Set pageTitle to blank.resultFieldErrorIf a step below fails, save the error as resultFieldErrorTry
result.url and save it as pageUrl.Trim result.url and save it as pageUrl.result.title and save it as pageTitle.Trim result.title and save it as pageTitle.On error
A search result arrived without a link or a title. Checking what of it can still be used..Show in the output: A search result arrived without a link or a title. Checking what of it can still be used..pageUrl is empty or pageUrl doesn't contain httpIf pageUrl is empty or pageUrl doesn't contain httpYes
resultsSkipped.Add 1 to resultsSkipped.Skipping a search result with no usable web link - it is not being used as a source..Show in the output: Skipping a search result with no usable web link - it is not being used as a source..No
No steps
pageText to blank.Set pageText to blank.pageReadErrorIf a step below fails, save the error as pageReadErrorTry
pageUrl. Save it as readResponse.Read the contents of pageUrl. Save it as readResponse.readResponse.results.raw_content and save it as pageText.Trim the first item of readResponse.results.raw_content and save it as pageText.On error
pageUrl - it is not being used as a source.Show in the output: Could not read pageUrl - it is not being used as a source.pageText is emptyIf pageText is emptyYes
resultsSkipped.Add 1 to resultsSkipped.pageUrl - it is not being used as a source.Show in the output: No readable text at pageUrl - it is not being used as a source.No
No steps
pageTitle is emptyIf pageTitle is emptyYes
pageTitle to pageUrl.Change pageTitle to pageUrl.No
No steps
sourcesRead.Add 1 to sourcesRead.sourceLabel to [sourcesRead].Set sourceLabel to [sourcesRead].sourceLabel pageTitleAdd sourceLabel pageTitle
Link: pageUrl
Page text:
pageText truncated to charactersPerSource characters to the end of sourceExtracts and save it as sourceExtracts.sourceLabel pageTitle - pageUrl to the end of sourceList and save it as sourceList.Add sourceLabel pageTitle - pageUrl to the end of sourceList and save it as sourceList.sourcesRead is 0If sourcesRead is 0Yes
resultsFound search results could be read, so there is nothing to write up and no document has been created. The sources are the point here - a brief written without them would only be the model's own recollection.Stop and report a problem: None of the resultsFound search results could be read, so there is nothing to write up and no document has been created. The sources are the point here - a brief written without them would only be the model's own recollection.No
No steps
sourceExtracts with "Join sourceExtracts with
-----
and save it as sourcesText.coverageNote to Sources used: sourcesRead of the resultsFound search results found (resultsSkipped could not be read).Set coverageNote to Sources used: sourcesRead of the resultsFound search results found (resultsSkipped could not be read).promptRules to:Set promptRules to:You are writing a short research brief from a numbered set of sources that were fetched for you. Follow these rules exactly.
1. Use ONLY the source text below. Do not add anything from your own knowledge, even where you are confident it is correct.
2. End every sentence that makes a claim with the number of the source it came from, like [1], or [2][3] where several sources support it.
3. If the sources do not answer the question, say so plainly in your first sentence and then write only what they do cover. Do not fill the gap.
4. Where two sources disagree, say that they disagree and cite bo...prompt to promptRulesSet prompt to promptRules
Question:
researchQuestion
Sources:
sourcesText.prompt. Save it as modelResponse.Ask OpenAI: prompt. Save it as modelResponse.modelResponse.response_text and save it as writeUp.Trim modelResponse.response_text and save it as writeUp.writeUp is emptyIf writeUp is emptyYes
No
No steps
documentTitle to Research brief: researchQuestion truncated to 120 characters.Set documentTitle to Research brief: researchQuestion truncated to 120 characters.documentBody to QuestionSet documentBody to Question
researchQuestion
What the sources say
writeUp
Sources
sourceList joined by a new line
coverageNote.documentTitle. Save it as newDocument.Create the document documentTitle. Save it as newDocument.newDocument.document_id and save it as documentId.Trim newDocument.document_id and save it as documentId.documentId is emptyIf documentId is emptyYes
No
No steps
documentId.Add text to documentId.documentBody