To learn more about different context types, check out our dedicated context section.
- Adding queries.
- Adding semantic models.
Adding queries as context
The cleanest way to add queries as context is to create a dedicated directory for your queries, then use a wild-card (*.sql) to slurp them all up into a
context object, as follows:
system_instructions using Jinja, as follows:
Adding semantic models as context
Sometimes you don’t need a full set of queries, but simply some snippets of SQL that represent metric calculations, dimension calculations, etc. — something minimal to bridge business logic to query logic. In these situations, building a semantic model is a good choice. Each semantic model has three required fields:measures, dimensions, and entities.
measures are special, in that they require a sql field to run. The other
objects only require a name field, though a few other fields (of note:
sample (an array of sample data), description (a plaintext description of
the column), synonyms (an array of synonyms for the column)). We suggest
using the column name as name.
A sample semantic model is shown below: