Models, Retrieval, Tools, and Control Flow › Running it on a real query
Language AI HandbookAll chapters The availability query below leaves the size-matching Trail Runner Pro. The stocked fixture reports two units. The second run uses the same query, catalog, parser and generator with the inventory fixture unavailable. You can see the distinction between a matching catalog product and an observable stock count.
PythonIn [13]Expand
QUERY = "Is the Trail Runner available in size 10 under $120?"
STOCK = {("p1", "10"): 2}
available = run_assistant(QUERY, STOCK)
partial = run_assistant(QUERY, None)
for answer in (available, partial):
print(f"{answer.outcome.value}: {answer.text}")
print("Trace:", " → ".join(answer.trace))ConsoleOut [13]Expand
complete: Trail Runner Pro at $110. Size 10: p1: 2 in stock. Trace: parse → retrieve → filter → generate → validate → lookup partial: Trail Runner Pro at $110. Stock is unknown. Trace: parse → retrieve → filter → generate → validate → lookup → stock_unknown
The display text for an availability question includes a product ID next to the count. A UI may already have a name-to-ID mapping from retrieval. Here we keep the literal ID in the output so it is clear which fixture entry supplied the number. The trace on the available run has the same initial stages as the trace on the unavailable run. Its last entry differs because the unavailable run records the separate stock-unknown decision.
PythonIn [14]Expand
print("Status:", ", ".join(available.status))
print("Cited catalog rows:", available.product_ids)
print("Partial path final stage:", partial.trace[-1])ConsoleOut [14]Expand
Status: Searching the catalog, Checking stock
Cited catalog rows: ('p1',)
Partial path final stage: stock_unknown
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!