http://franz.com/ns/allegrograph/8.0.0/llm/askSerp

API Key

You need an SERP API key to utilize this predicate. Your API key should be here: SERP API key. See llm.html for additional information.

There are three ways to configure your API key, as a query option prefix or in a couple of places in the Allegrograph configuration. (The keys in the examples are not valid.)

As a query option prefix, write:

PREFIX franzOption_serpApiKey: <franz:ac34ac1234567894b15627d34b5859c76d17038d791c26e38f161e7938f167e9> 

Syntax for config file:

QueryOption serpApiKey=<franz:ac34ac1234567894b15627d34b5859c76d17038d791c26e38f161e7938f167e9> 

In the file data/settings/default-query-options:

(("franzOption_serpApiKey" "<franz:ac34ac1234567894b15627d34b5859c76d17038d791c26e38f161e7938f167e9>")) 

Description

Return Google search results using the serpapi.com search engine retrieval API.

Namespace:

PREFIX llm: <http://franz.com/ns/allegrograph/8.0.0/llm/> 

General forms:

?response llm:askSerp ?query  
(?response ?citation) llm:askSerp ?query  
(?response ?citation ?path) llm:askSerp ?query  
?response llm:askSerp (?query ?topN)  
(?response ?citation) llm:askSerp (?query ?topN)  
(?response ?citation ?path) llm:askSerp (?query ?topN)  
?response llm:askSerp (?query ?topN ?pathRegex)  
(?response ?citation) llm:askSerp (?query ?topN ?pathRegex)  
(?response ?citation ?path) llm:askSerp (?query ?topN ?pathRegex) 

Example:

PREFIX llm: <http://franz.com/ns/allegrograph/8.0.0/llm/>  
PREFIX franzOption_serpApiKey: <franz:ac34ac1234567894b15627d34b5859c76d17038d791c26e38f161e7938f167e9>  
SELECT * {  
# Try:  
# Who is the US President?  
# How many liters in a US gallon?  
# Who won the Super Bowl in 2023?  
# How much is the most expensive car in the world?  
(?weather ?citation ?path) llm:askSerp ("What is the weather in London, UK today?")  
}  

LLM Example:

PREFIX llm: <http://franz.com/ns/allegrograph/8.0.0/llm/>  
PREFIX franzOption_openaiApiKey: <franz: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>  
PREFIX franzOption_serpApiKey: <franz:ac34ac1234567894b15627d34b5859c76d17038d791c26e38f161e7938f167e9>  
SELECT   (llm:response(concat("Predict tomorrow's top headline based on today's headlines: ", GROUP_CONCAT(?news; separator="; "))) as ?prediction) {  
    ?news llm:askSerp ("Top news headlines" 10 "top_stories")  
}  

The optional input variables are:

The optional output variables are:

The implementation of llm:askSerp takes an opinionated approach to deciding which JSON pathways to ignore, which to include and the relative importance of each. Please contact AllegroGraph Support ([email protected]) if you require different API options or customization.

Notes

The following namespace abbreviations are used:

The SPARQL magic properties reference has additional information on using AllegroGraph magic properties and functions.