Example apps: the playground demos
Each guided demo in the playground is below as a small program you can run and build on: the exact examples the demo teaches, what Conceiver answers afterwards, and a complete app. Every program was run against Conceiver, and each "It prints" block is its real output. Agents can read this page as Markdown at /docs/examples.md.
Every app needs the SDK and the two environment variables from the quickstart:
export TOOLVING_API_URL=https://toolving.com
export TOOLVING_API_KEY='<your key>'
Each app creates a fresh instance, teaches it, answers the questions given on its command line (or its sample questions), then releases the instance with reap(). In your own app, keep the instance and its learning between runs: save it with instance.save() and restore it with client.create(sequence_id=...), or, with storage, load the artifact reap() stored with client.create(artifact_id=...) (see the Python SDK).
The demos teach in two ways, and the apps do the same:
- Teach:
instance.teach(question, answer)gives an example directly. - Correct: ask first with
instance.query(question), then record the right answer withinstance.resolve(prediction.prediction_id, answer). This is how an app learns from its users: it answers, someone fixes the answer, and the fix is learned.
Teach its first words
Recall exact answers. Taught bob and alice by correcting, it gives them back; a word it was never shown is UNRESOLVED.
# first_words.py
import os, sys
from toolving import ConceiverClient
with ConceiverClient(os.environ["TOOLVING_API_URL"], os.environ["TOOLVING_API_KEY"]) as client:
words = client.create()
for word in ("bob", "alice"):
p = words.query(word) # UNRESOLVED: nothing taught yet
words.resolve(p.prediction_id, word) # correct it: the answer is the word itself
for question in sys.argv[1:] or ["bob", "alice", "carol"]:
p = words.query(question)
print(question, "->", f"{p.text} ({p.confidence})" if p.status == "ANSWER" else "UNRESOLVED")
words.reap()
It prints:
bob -> bob (hypothesis)
alice -> alice (hypothesis)
carol -> UNRESOLVED
Teach an operation
Turn a command into a JSON action. After two corrected examples, a new name fills the same action.
# operation.py
import os, sys
from toolving import ConceiverClient
EXAMPLES = [
("create account bob", '{"action":"create_account","name":"bob"}'),
("create account alice", '{"action":"create_account","name":"alice"}'),
]
with ConceiverClient(os.environ["TOOLVING_API_URL"], os.environ["TOOLVING_API_KEY"]) as client:
commands = client.create()
for question, answer in EXAMPLES:
p = commands.query(question)
commands.resolve(p.prediction_id, answer)
for question in sys.argv[1:] or ["create account carol", "create account dave", "delete account carol"]:
p = commands.query(question)
if p.status == "ANSWER":
print(question, "->", p.output, f"({p.confidence})") # output is the decoded JSON
else:
print(question, "-> UNRESOLVED")
commands.reap()
It prints:
create account carol -> {'action': 'create_account', 'name': 'carol'} (confident)
create account dave -> {'action': 'create_account', 'name': 'dave'} (confident)
delete account carol -> UNRESOLVED
delete account was never taught, so there is no answer. Teach it, or send it to a person.
Build a workflow
Teach three single steps, then a request that expands into them. Each step and the whole request answer for a new name.
# workflow.py
import json, os, sys
from toolving import ConceiverClient
STEPS = ("create account", "add to team", "send welcome")
with ConceiverClient(os.environ["TOOLVING_API_URL"], os.environ["TOOLVING_API_KEY"]) as client:
flow = client.create()
for step in STEPS:
action = step.replace(" ", "_")
for name in ("bob", "alice"):
flow.teach(f"{step} {name}", json.dumps({"action": action, "name": name}, separators=(",", ":")))
for name in ("bob", "alice"):
flow.teach(f"onboard {name}", "; ".join(f"{step} {name}" for step in STEPS))
for question in sys.argv[1:] or ["onboard carol", "add to team carol"]:
p = flow.query(question)
print(question, "->", f"{p.text} ({p.confidence})" if p.status == "ANSWER" else "UNRESOLVED")
if p.status == "ANSWER" and question.startswith("onboard "):
for step in p.text.split("; "): # run each step through the same instance
s = flow.query(step)
print(" ", step, "->", s.output if s.status == "ANSWER" else "UNRESOLVED")
flow.reap()
It prints:
onboard carol -> create account carol; add to team carol; send welcome carol (confident)
create account carol -> {'action': 'create_account', 'name': 'carol'}
add to team carol -> {'action': 'add_to_team', 'name': 'carol'}
send welcome carol -> {'action': 'send_welcome', 'name': 'carol'}
add to team carol -> {"action":"add_to_team","name":"carol"} (confident)
Correct an answer
A correction moves the answer at once. Then teaching a word that tells two cases apart routes each case.
# correct.py
import os, sys
from toolving import ConceiverClient
with ConceiverClient(os.environ["TOOLVING_API_URL"], os.environ["TOOLVING_API_KEY"]) as client:
router = client.create()
p = router.query("file invoice from acme")
router.resolve(p.prediction_id, "/finance/vendors/acme")
p = router.query("file invoice from acme")
print("before the correction:", p.text, f"({p.confidence})")
router.resolve(p.prediction_id, "/legal/disputes/acme") # the right answer turned out different
p = router.query("file invoice from acme")
print("after the correction:", p.text, f"({p.confidence})")
router.teach("file disputed invoice from acme", "/legal/disputes/acme")
router.teach("file paid invoice from acme", "/finance/vendors/acme")
for question in sys.argv[1:] or ["file disputed invoice from acme", "file paid invoice from acme"]:
p = router.query(question)
print(question, "->", f"{p.text} ({p.confidence})" if p.status == "ANSWER" else "UNRESOLVED")
router.reap()
It prints:
before the correction: /finance/vendors/acme (hypothesis)
after the correction: /legal/disputes/acme (hypothesis)
file disputed invoice from acme -> /legal/disputes/acme (hypothesis)
file paid invoice from acme -> /finance/vendors/acme (hypothesis)
Workflow planner
Turn an onboarding request into a tool-call plan, a JSON list of calls. After two corrected examples it plans for a new person and team. Your app decides whether to run the plan; Conceiver only proposes it.
# workflow_planner.py
import json, os, sys
from toolving import ConceiverClient
def plan(user, team):
return [
{"args": {"team": team, "user": user}, "tool": "create_account"},
{"args": {"team": team, "user": user}, "tool": "add_to_team"},
{"args": {"user": user}, "tool": "send_welcome"},
]
def line(value):
return json.dumps(value, separators=(",", ":"), sort_keys=True) # one line, stable order
with ConceiverClient(os.environ["TOOLVING_API_URL"], os.environ["TOOLVING_API_KEY"]) as client:
planner = client.create()
for user, team in (("priya", "engineering"), ("marco", "sales")):
p = planner.query(f"onboard {user} to {team}")
planner.resolve(p.prediction_id, line(plan(user, team)))
for question in sys.argv[1:] or ["onboard leila to marketing", "please onboard leila into marketing"]:
p = planner.query(question)
if p.status == "ANSWER":
print(question, f"({p.confidence})")
for call in p.output:
print(" ", call["tool"], call["args"])
else:
print(question, "-> UNRESOLVED")
planner.reap()
It prints:
onboard leila to marketing (confident)
create_account {'team': 'marketing', 'user': 'leila'}
add_to_team {'team': 'marketing', 'user': 'leila'}
send_welcome {'user': 'leila'}
please onboard leila into marketing -> UNRESOLVED
Matching is by exact word: please and into were never taught. Normalise requests before you ask, or teach each phrasing.
Records desk
Decide where a record is filed. Two examples teach the pattern; a new category and year follow it.
# records_desk.py
import os, sys
from toolving import ConceiverClient
with ConceiverClient(os.environ["TOOLVING_API_URL"], os.environ["TOOLVING_API_KEY"]) as client:
desk = client.create()
desk.teach("file council minutes 2025", "records/council/2025")
desk.teach("file finance minutes 2026", "records/finance/2026")
for question in sys.argv[1:] or ["file parks minutes 2027", "file planning minutes 2028"]:
p = desk.query(question)
print(question, "->", f"{p.text} ({p.confidence})" if p.status == "ANSWER" else "UNRESOLVED")
desk.reap()
It prints:
file parks minutes 2027 -> records/parks/2027 (confident)
file planning minutes 2028 -> records/planning/2028 (confident)
Invoice extractor
Pull fields out of an invoice line into a JSON record. A vendor name of several words is extracted too, as a hypothesis; a different layout is UNRESOLVED.
# invoice_extractor.py
import json, os, sys
from toolving import ConceiverClient
EXAMPLES = [
("Invoice INV-2201 from Acme for 1200 due 2025-10-01",
{"amount": "1200", "due": "2025-10-01", "invoice": "INV-2201", "vendor": "Acme"}),
("Invoice INV-3001 from Northwind for 4400 due 2026-01-31",
{"amount": "4400", "due": "2026-01-31", "invoice": "INV-3001", "vendor": "Northwind"}),
]
with ConceiverClient(os.environ["TOOLVING_API_URL"], os.environ["TOOLVING_API_KEY"]) as client:
extractor = client.create()
for text, record in EXAMPLES:
extractor.teach(text, json.dumps(record, separators=(",", ":"), sort_keys=True))
for question in sys.argv[1:] or ["Invoice INV-3010 from Contoso Facilities Group for 975 due 2026-02-28",
"From Acme: invoice INV-4010, total 80, payable 2026-05-01"]:
p = extractor.query(question)
print(question, "->", f"{p.output} ({p.confidence})" if p.status == "ANSWER" else "UNRESOLVED")
extractor.reap()
It prints:
Invoice INV-3010 from Contoso Facilities Group for 975 due 2026-02-28 -> {'amount': '975', 'due': '2026-02-28', 'invoice': 'INV-3010', 'vendor': 'Contoso Facilities Group'} (hypothesis)
From Acme: invoice INV-4010, total 80, payable 2026-05-01 -> UNRESOLVED
Building on these
- Keep what it learned. These apps start empty and teach on every run. A real app teaches once and keeps the learning:
instance.save()andclient.create(sequence_id=...), or with storage the artifact fromreap()andclient.create(artifact_id=...). - Learn from your users. When a person fixes an answer, call
resolve()with the right one, as the correct-mode apps do. Confirm right answers the same way: both raise the confidence of what it got right. - Use
confidenceas your threshold. Act onconfidentorhighly confidentwhere a wrong answer is costly; have ahypothesischecked.UNRESOLVEDhas no answer: send it to a person or an LLM, then teach the answer. - Keep the rules in your app. Conceiver proposes answers; it does not authorise tool calls, move records or approve invoices. Validate decoded JSON against your schema before you use it.
The teaching guide shows how to teach each kind of task, and the Python SDK reference every call.