Quick start
Three calls cover most of what you'll do: encode, decode, and build a prompt.
Encode and decode
Pass any JSON-compatible value. You get JDogo text back, and decoding it returns exactly the same value.
import jdogo
users = [
{"id": 1001, "name": "Ada Lovelace", "role": "admin", "active": True},
{"id": 1002, "name": "Grace Hopper", "role": "editor", "active": True},
{"id": 1003, "name": "Alan Turing", "role": "viewer", "active": False},
{"id": 1004, "name": "Katherine Johnson", "role": "editor", "active": True},
]
text = jdogo.dumps(users)
print(text)
assert jdogo.loads(text) == usersimport { stringify, parse } from "jdogo";
const users = [
{ id: 1001, name: "Ada Lovelace", role: "admin", active: true },
{ id: 1002, name: "Grace Hopper", role: "editor", active: true },
{ id: 1003, name: "Alan Turing", role: "viewer", active: false },
{ id: 1004, name: "Katherine Johnson", role: "editor", active: true },
];
const text = stringify(users);
console.log(text);
const back = parse(text); // deep-equal to usersimport com.jdogo.core.doc.DocCodec;
import java.util.List;
record User(int id, String name, String role, boolean active) {}
var users = List.of(
new User(1001, "Ada Lovelace", "admin", true),
new User(1002, "Grace Hopper", "editor", true),
new User(1003, "Alan Turing", "viewer", false),
new User(1004, "Katherine Johnson", "editor", true));
String text = DocCodec.encode(users);
Object back = DocCodec.decode(text); // List of Maps, same keys and valuesOutput:
@id+,name,role,active 1001,Ada Lovelace,admin,true 1,Grace Hopper,editor,true 1,Alan Turing,viewer,false 1,Katherine Johnson,editor,true
id+ stores each id as the step from the row above. The format guide covers every symbol.
Send it to a model
The prompt builder writes the instruction, the data and the question in the layout that tested best across models. It keeps full key names and quoted values so the model can match your question to the data.
prompt = jdogo.format_query_prompt("Which users are editors?", users)
reply = call_your_model(prompt)import { formatQueryPrompt } from "jdogo";
const prompt = formatQueryPrompt("Which users are editors?", users);import com.jdogo.ai.JDogoAI;
String prompt = JDogoAI.formatQueryPrompt("Which users are editors?", users);Get exact numbers with ask()
For counts, totals and averages, let the model write a query instead of reading rows. You pass a function that calls your model; JDogo does the rest.
from jdogo import ask
result = ask("How many active admins are there?", users, llm=call_your_model)
print(result.answer, result.route, result.expression)
# 1 compute count where role = "admin" and active = trueimport { ask } from "jdogo";
const r = await ask("How many active admins are there?", users, callYourModel);
console.log(r.answer, r.route, r.expression);JDogoAI.AskResult r = JDogoAI.ask("How many active admins are there?", users, prompt -> callYourModel(prompt));Read AI prompts and ask() for routing, fallbacks and what the model may write.