Return a table of data with each row's values bound to the column variables in the subject argument.


PREFIX llm: <> 

General forms:

?col0 llm:askForTable ?query
(?col0 ?col1) llm:askForTable ?query
(?col0 ?col1 ?col2) llm:askForTable ?query
(?col0 ?col1 ?col2 ?col3) llm:askForTable ?query
(?col0 ?col1 ?col2 ?col3 ... ?col31) llm:askForTable ?query


PREFIX llm: <>
SELECT ?state ?capital ?pop ?area ?admitted ?governor ?celebrity {
(?state ?capital ?pop ?area ?admitted ?governor ?celebrity) llm:askForTable "Make a table of US States, their capitals, population, area, year admitted to the Union, current governor and the most famous celebrity from that state."

You can use the llm:node function to create a unique URI based on the values in the row

bind(llm:node(?state) as ?stateNote). 


Currently there is a limit of 32 columns in the subject arguments.


You need an API key to utilize this predicate. You need an OpenAI API key to utilize this predicate. See for instructions on obtaining a key (start with the Quickstart Tutorial and follow the links there to get a key). 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_openaiApiKey: <franz:sk-U01ABc2defGHIJKlmnOpQ3RstvVWxyZABcD4eFG5jiJKlmno> 

Syntax for config file:

QueryOption openaiApiKey=<franz:sk-U01ABc2defGHIJKlmnOpQ3RstvVWxyZABcD4eFG5jiJKlmno> 

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

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

API Options

The proprietary OpenAI API exposes many options and parameters for interaction with their LLM models. Currently the AllegroGraph magic predicates and functions take an opinionated approach and hide most of these options behind the scenes. Specifically, we set

API endpoint: 

Endpoint parameters:

best-of: openai-default-best-of
echo: openai-default-echo
logit-bias: openai-default-logit-bias
logprobs: openai-default-logprobs
max-tokens: openai-default-max-tokens
model: openai-default-ask-chat-model
n: openai-default-n
output-format: openai-default-output-format
presence-penalty: openai-default-presence-penalty
stop: openai-default-stop
suffix: openai-default-suffix
temperature: openai-default-temperature
timeout: openai-default-timeout
top-p: openai-default-top-p
user: openai-default-user
verbose: nil
function-call: {"name":"table"}
{"name":"table", "description": "function to return tabular data.",
{"description": "the list of table rows",
"type": "array",
"type": "array",
"items": {
"type": "string",
"description" : "the value in each column"}

Additionally we impose an API timeout of 10 seconds.

Finally, when the OpenAI API times out, returns an error, or the magic predicate implementation fails to parse the response, or any other error occurs, the magic predicate displays an informative message in Webview. Please contact AllegroGraph Support if you require different API options or customization.


The following namespace abbreviations are used:

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