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.

As a query option prefix, write:

PREFIX franzOption_serpApiKey: <franz:ac34ac5984ac0094b15627d34b5859c76d17038d791c26e38f161e7938f167e9> 

Syntax for config file:

QueryOption serpApiKey=<franz:ac34ac5984ac0094b15627d34b5859c76d17038d791c26e38f161e7938f167e9> 

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

(("franzOption_serpApiKey" "<franz:sk-U01ABc2defGHIJKlmnOpQ3RstvVWxyZABcD4eFG5jiJKlmno>")) 

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:ac34ac5984ac0094b15627d34b5859c76d17038d791c26e38f161e7938f167e9>
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:cb61b7cb2077c507583ab621e57d3d6b04361b7638c76b7959408e17038e161c>
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 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.