Files
metabase/resources/metabot/prompts/llm_shape.selmer

363 lines
14 KiB
Plaintext

{% if is_measure %}
<measure measure_id="{{measure_id}}" name="{{measure_name}}" display_name="{{measure_display_name}}"{% if measure_database_name %} database_name="{{measure_database_name}}"{% endif %}{% if measure_base_table_fqn %} base_table_fully_qualified_name="{{measure_base_table_fqn}}"{% endif %}{% if measure_portable_entity_id %} portable_entity_id="{{measure_portable_entity_id}}"{% endif %}>{% if measure_description %}
{{measure_description}}{% endif %}{% if measure_definition %}
<definition>
{{measure_definition|safe}}
</definition>{% endif %}
</measure>
{% endif %}
{% if is_segment %}
<segment id="{{segment_id}}" name="{{segment_name}}" display_name="{{segment_display_name}}"{% if segment_database_name %} database_name="{{segment_database_name}}"{% endif %}{% if segment_base_table_fqn %} base_table_fully_qualified_name="{{segment_base_table_fqn}}"{% endif %}{% if segment_portable_entity_id %} portable_entity_id="{{segment_portable_entity_id}}"{% endif %}>{% if segment_description %}
{{segment_description}}{% endif %}{% if segment_definition %}
<definition>
{{segment_definition|safe}}
</definition>{% endif %}
</segment>
{% endif %}
{% if is_field %}
<field id="{{field_id}}" name="{{field_name|safe}}" display_name="{{field_display_name}}" type="{{field_base_type}}" database_type="{{field_database_type}}"{% if field_fk_target_fqn %} fk_target_fully_qualified_name="{{field_fk_target_fqn}}"{% endif %}>{% if field_description %}
## Description
{{field_description}}{% endif %}</field>
{% endif %}
{% if is_collection %}
<collection name="{{collection_name}}"{% if collection_authority_level %} authority_level="{{collection_authority_level}}"{% endif %}>{% if collection_description %}
<description>{{collection_description}}</description>{% endif %}</collection>
{% endif %}
{% if is_related_table %}
<related-table{% if related_table_id %} id="{{related_table_id}}"{% endif %} name="{{related_table_name}}"{% if related_table_related_by %} related_by="{{related_table_related_by}}"{% endif %}{% if related_table_database_name %} database_name="{{related_table_database_name}}"{% endif %} fully_qualified_name="{{related_table_fqn}}">{% if related_table_fields_xml %}
{{related_table_fields_xml|safe}}{% endif %}</related-table>
{% endif %}
{% if is_metric %}
<metric id="{{metric_id}}", name="{{metric_name}}" is_verified="{{metric_verified}}"{% if metric_database_name %} database_name="{{metric_database_name}}"{% endif %}{% if metric_base_table_fqn %} base_table_fully_qualified_name="{{metric_base_table_fqn}}"{% endif %}{% if metric_portable_entity_id %} portable_entity_id="{{metric_portable_entity_id}}"{% endif %}>
{% if metric_collection_xml %}
The metric is stored in the following collection:
{{metric_collection_xml|safe}}
{% endif %}
{% if metric_default_time_dimension %}
Default Time Dimension Field: {{metric_default_time_dimension}}
{% endif %}
### Metric Description
{{metric_description}}
{% if metric_dimensions_table %}
### Dimensions
The following dimensions can be used for filter- or group-by operations:
{{metric_dimensions_table|safe}}
Before using any field in comparisons, filters, or conditions, you should check their metadata and sample values first, using the uri `metabase://metric/{{metric_id}}/dimensions/{field_id}`.
This will help avoid errors due to unexpected data types or formats.
{% endif %}
</metric>
{% endif %}
{% if is_table %}
<table id="{{table_id}}", name="{{table_name}}" database_id="{{table_database_id}}"{% if table_database_name %} database_name="{{table_database_name}}"{% endif %} database_engine="{{table_database_engine}}" fully_qualified_name="{{table_fqn}}">
### Description
{{table_description}}
{% if table_fields_xml %}
### Fields
The following fields are available in this table.
{{table_fields_xml|safe}}
{% endif %}
{% if table_related_tables_xml %}
### Related Tables
Foreign key fields from related tables. Usage patterns:
- Can be used directly in notebook queries (non-sql) as if they were part of the table.
- For SQL queries: Use "fieldname" with explicit JOINs
{{table_related_tables_xml|safe}}
{% endif %}
{% if table_measures_xml %}
### Measures (Pre-defined Aggregation Formulas)
The following pre-defined MEASURES (NOT metrics!) are available for this table.
These are aggregation formulas defined on this table. Use them instead of creating custom aggregations when available.
{{table_measures_xml|safe}}
{% endif %}
{% if table_segments_xml %}
### Segments (Pre-defined Filter Conditions)
The following pre-defined SEGMENTS are available for this table.
These are business-defined filter conditions. Use them instead of creating custom filters when available.
{{table_segments_xml|safe}}
{% endif %}
Before using any field in comparisons, filters, or conditions, you should check their metadata and sample values first, using the uri `metabase://table/{{table_id}}/fields/{field_id}`.
This will help avoid errors due to unexpected data types or formats.
</table>
{% endif %}
{% if is_model %}
<metabase-model id="{{model_id}}" name="{{model_name}}" is_verified="{{model_verified}}" database_id="{{model_database_id}}"{% if model_database_name %} database_name="{{model_database_name}}"{% endif %} database_engine="{{model_database_engine}}" fully_qualified_name="{{model_fqn}}"{% if model_portable_entity_id %} portable_entity_id="{{model_portable_entity_id}}"{% endif %}>
### Description
{{model_description}}
{% if model_query_json %}
### Saved query
The model's saved query, in the same canonical portable representations JSON format the
`construct_notebook_query` tool consumes:
<query>
{{model_query_json|safe}}
</query>
{% endif %}
{% if model_fields_xml %}
### Fields
The following fields are available in this model.
{{model_fields_xml|safe}}
{% endif %}
{% if model_related_tables_xml %}
### Related Tables
Foreign key fields from related tables. Usage patterns:
- Can be used directly in notebook queries (non-sql) as if they were part of the model.
- For SQL queries: Use "fieldname" with explicit JOINs
{{model_related_tables_xml|safe}}
{% endif %}
{% if model_measures_xml %}
### Measures (Pre-defined Aggregation Formulas)
The following pre-defined MEASURES (NOT metrics!) are available for this model.
These are aggregation formulas defined on this model. Use them instead of creating custom aggregations when available.
{{model_measures_xml|safe}}
{% endif %}
{% if model_segments_xml %}
### Segments (Pre-defined Filter Conditions)
The following pre-defined SEGMENTS are available for this model.
These are business-defined filter conditions. Use them instead of creating custom filters when available.
{{model_segments_xml|safe}}
{% endif %}
Before using any field in comparisons, filters, or conditions, you should check their metadata and sample values first, using the uri `metabase://model/{{model_id}}/fields/{field_id}`.
This will help avoid errors due to unexpected data types or formats.
</model>
{% endif %}
{% if is_query_results %}
<query_results>
{% if result_columns_table %}
### Result Columns
{{result_columns_table|safe}}
{% endif %}
{% if result_rows_table %}
### Result Rows
{{result_rows_table|safe}}
{% endif %}
</query_results>
{% endif %}
{% if is_query %}
<query type="{{query_type}}" id="{{query_id}}" database_id="{{query_database_id}}">
{% if query_content %}
{{query_content|safe}}
{% endif %}
{% if query_results_xml %}
{{query_results_xml|safe}}
{% endif %}
</query>
{% endif %}
{% if is_visualization %}
<chart id="{{visualization_chart_id}}">
The chart is powered by the following queries:
{% if visualization_queries_xml %}
{{visualization_queries_xml|safe}}
{% endif %}
{% if visualization_settings_text %}
<visualization>{{visualization_settings_text}}</visualization>{% endif %}
</chart>
{% endif %}
{% if is_chart %}
<chart id="{{chart_id}}" type="{{chart_type}}" query-id="{{chart_query_id}}">
Chart link: metabase://chart/{{chart_id}}
</chart>
{% endif %}
{% if is_question %}
<metabase_question id="{{question_id}}" is_verified="{{question_verified}}"{% if question_display_type %} display_type="{{question_display_type}}"{% endif %}{% if question_portable_entity_id %} portable_entity_id="{{question_portable_entity_id}}"{% endif %}>
<name>{{question_name}}</name>
{% if question_description %}
<description>{{question_description}}</description>
{% endif %}
{% if question_collection_xml %}
The question is stored in the following collection:
{{question_collection_xml|safe}}
{% endif %}
{% if question_query_json %}
The question's saved query, in the same canonical portable representations JSON format the
`construct_notebook_query` tool consumes:
<query>
{{question_query_json|safe}}
</query>
{% endif %}
{% if question_visualization_xml %}
The question is visualized as follows:
{{question_visualization_xml|safe}}
{% endif %}
</metabase_question>
{% endif %}
{% if is_text_card %}
<text_card id="{{text_card_id}}" order="{{text_card_order}}" width="{{text_card_width}}" height="{{text_card_height}}">
{{text_card_text}}
</text_card>
{% endif %}
{% if is_viz_card %}
<viz_card id="{{viz_card_id}}" order="{{viz_card_order}}" width="{{viz_card_width}}" height="{{viz_card_height}}">
{% if viz_card_title %}
<title>{{viz_card_title}}</title>
{% endif %}
{% if viz_card_description %}
<description>{{viz_card_description}}</description>
{% endif %}
{% if viz_card_chart_xml %}
{{viz_card_chart_xml|safe}}{% endif %}
</viz_card>
{% endif %}
{% if is_dashboard %}
<dashboard id="{{dashboard_id}}" is_verified="{{dashboard_verified}}">
<name>{{dashboard_name}}</name>
{% if dashboard_description %}
<description>{{dashboard_description}}</description>
{% endif %}
{% if dashboard_collection_xml %}
The dashboard is stored in the following collection:
{{dashboard_collection_xml|safe}}
{% endif %}
{% if dashboard_tabs_xml %}
{{dashboard_tabs_xml|safe}}{% endif %}
</dashboard>
{% endif %}
{% if is_database_schema %}
<database_schema name='{{database_schema_name}}'>{{database_schema_description}}</database_schema>
{% endif %}
{% if is_database %}
<database id="{{database_id}}" name="{{database_name}}">
{% if database_description %}
<description>{{database_description}}</description>
{% endif %}
{% if database_schemas_xml %}
<schemas>
{{database_schemas_xml|safe}}</schemas>
{% endif %}
</database>
{% endif %}
{% if is_user %}
<user>
### User Info
- Name: {{user_name}}
- User ID: {{user_id}}
- Email: {{user_email}}
{% if user_glossary_rows %}
### Glossary Terms
The user's company has the following glossary terms defined in Metabase. Use these to understand specific terminology
or jargon that may be relevant to the user's questions.
| term | definition |
|---|---|
{{user_glossary_rows|safe}}
{% endif %}
</user>
{% endif %}
{% if is_search_result %}
<{{search_tag_name}} id="{{search_id}}" name="{{search_name}}"{% if search_has_curated %} is_curated="{{search_curated}}"{% endif %}{% if search_has_verified %} is_verified="{{search_verified}}"{% endif %}{% if search_has_official %} is_official="{{search_official}}"{% endif %}{% if search_data_layer %} data_layer="{{search_data_layer}}"{% endif %}{% if search_data_authority %} data_authority="{{search_data_authority}}"{% endif %}{% if search_database_id %} database_id="{{search_database_id}}"{% endif %}{% if search_database_name %} database_name="{{search_database_name}}"{% endif %}{% if search_database_engine %} database_engine="{{search_database_engine}}"{% endif %}{% if search_fqn %} fully_qualified_name="{{search_fqn}}"{% endif %}{% if search_base_table_fqn %} base_table_fully_qualified_name="{{search_base_table_fqn}}"{% endif %}{% if search_portable_entity_id %} portable_entity_id="{{search_portable_entity_id}}"{% endif %}>
{% if search_description %}
{{search_description}}
{% endif %}
{% if search_collection_name %}
Collection: {{search_collection_name}}
{% endif %}
</{{search_tag_name}}>
{% endif %}
{% if is_search_results %}
Here are the search results:
<search-results>
{{search_results_xml|safe}}
</search-results>
{% endif %}
{% if is_field_values_metadata %}
{% if sample_values_table %}
**Sample Values (for understanding format pattern)**
The following sample values show the data format in this field. The actual dataset may contain
other values following the same pattern:
{{sample_values_table|safe}}
{% else %}
**Sample Values**
This field hasn't been sampled yet. Continue without samples.
{% endif %}
{% if stats_table %}
**Field Statistics (SAMPLE-BASED)**
The following statistics are based on a df.sample(n) of the data.
They provide a rough idea of the data characteristics but may not reflect the complete dataset:
{{stats_table|safe}}
{% endif %}
{% endif %}
{% if is_field_metadata %}
{% if field_metadata_value_xml %}
<field-metadata field_id="{{field_metadata_field_id}}">
{% if field_metadata_source %} Source table: {{field_metadata_source}}
{% endif %}{% if field_metadata_reference %} Reference (copy into a field clause): {{field_metadata_reference|safe}}
{% endif %} {{field_metadata_value_xml|safe}}
</field-metadata>
{% else %}
No metadata available to display. This doesn't mean the column is empty or cannot be queried - there may be various reasons why values aren't shown here.
{% endif %}
{% endif %}
{% if is_transform %}
<transform id="{{transform_id}}" name="{{transform_name}}">
{% if transform_description %}
<description>{{transform_description}}</description>
{% endif %}
{% if transform_source_type %}
<source type="{{transform_source_type}}">
{% if transform_source_database %}
<database>{{transform_source_database}}</database>
{% endif %}
{% if transform_source_query %}
<query>{{transform_source_query|safe}}</query>
{% endif %}
</source>
{% endif %}
{% if transform_target %}
<target>{{transform_target|safe}}</target>
{% endif %}
</transform>
{% endif %}
{% if is_get_metadata_result %}
{% if metadata_has_any %}
{% if metadata_metrics_xml %}{{metadata_metrics_xml|safe}}{% endif %}{% if metadata_tables_xml %}{{metadata_tables_xml|safe}}{% endif %}{% if metadata_models_xml %}{{metadata_models_xml|safe}}{% endif %}{% if metadata_errors %}
<errors>
The following errors were encountered while fetching metadata:
{{metadata_errors|safe}}
</errors>{% endif %}
{% else %}
{% if metadata_errors %}
No metadata was returned for the requested tables, models, or metrics.
<errors>
The following errors were encountered while fetching metadata:
{{metadata_errors|safe}}
</errors>
{% else %}
No metadata was returned for the requested tables, models, or metrics.
{% endif %}
{% endif %}
{% endif %}