Use results in your app
Use Knowledge Base results in RAG, search and legal agent workflows.
Knowledge Base results are designed to be passed into product workflows as legal context. They work well in RAG systems, legal search interfaces and agent tool calls.
Legal search
For a search interface:
send the user's search text to the retrieve endpoint;
show result titles, excerpts and source URLs;
group legislation results by
work_frbr_uriwhen several portions come from the same work;let users open
portion_public_urlorpublic_urlto inspect the source.
RAG and AI answers
For a RAG workflow:
retrieve the most relevant results;
build a context block from
content.text,title,portion_titleand source URLs;ask the model to answer only from the provided context;
include citations or source links in the final answer.
Example context format:
Source: Animal By-law, 2011
URL: https://lawlibrary.org.za/akn/za-cpt/act/by-law/2011/animal/eng@2011-08-05#chp_7
Portion: Chapter 7 - Miscellaneous
Text: ...Agent tools
For a legal agent, expose retrieval as a tool with inputs such as:
query: focused legal search text;knowledge_base: the KB code to query;place: optional place filter;top_k: result count.
The agent should use the returned legal text and source URLs before drafting an answer or deciding whether it needs more information.
Improve retrieval quality
If results are too broad:
add place filters such as
frbr_place;apply
principal: trueandrepealed: falsefor legislation;reduce
top_k;rewrite the user question into more specific legal search terms.
If results are too narrow:
remove filters;
increase
top_k;query a broader Knowledge Base;
try alternative legal terms.
More examples
See the example repository for runnable integrations:
Last updated