Skip to content

Commit 9b3d2ac

Browse files
committed
feat: add charts
1 parent 35df7a4 commit 9b3d2ac

File tree

9 files changed

+753
-1
lines changed

9 files changed

+753
-1
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ __pycache__/
88

99
# Distribution / packaging
1010
.Python
11-
build/
1211
develop-eggs/
1312
dist/
1413
downloads/
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{% for file in "openedx-ai-extensions/build/assets"|walk_templates %}
2+
---
3+
{% include file %}
4+
{% endfor %}

tutor/openedx_ai_extensions/plugin.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ def _mount_plugin(mounts, path):
5454
hooks.Filters.ENV_PATCHES.add_item((os.path.basename(path), patch_file.read()))
5555

5656

57+
########################
58+
# Template rendering
59+
# Required for superset-extra-assets (datasets, charts, dashboards)
60+
########################
61+
62+
hooks.Filters.ENV_TEMPLATE_ROOTS.add_items(
63+
[
64+
str(importlib_resources.files("openedx_ai_extensions") / "templates"),
65+
]
66+
)
67+
68+
hooks.Filters.ENV_TEMPLATE_TARGETS.add_items(
69+
[
70+
("openedx-ai-extensions/build", "plugins"),
71+
],
72+
)
73+
74+
5775
########################
5876
# UI Slot configurations
5977
########################
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
_file_name: daily_token_consumption_trend.yaml
2+
slice_name: Daily Token Consumption Trend
3+
description: null
4+
certified_by: null
5+
certification_details: null
6+
viz_type: echarts_timeseries_line
7+
params:
8+
datasource: 92__table
9+
viz_type: echarts_timeseries_line
10+
slice_id: 167
11+
x_axis: emission_date
12+
time_grain_sqla: P1D
13+
x_axis_sort_asc: true
14+
x_axis_sort_series: name
15+
x_axis_sort_series_ascending: true
16+
metrics:
17+
- expressionType: SIMPLE
18+
column:
19+
advanced_data_type: null
20+
certification_details: null
21+
certified_by: null
22+
column_name: total_tokens
23+
description: Total tokens used (prompt + completion)
24+
expression: null
25+
filterable: true
26+
groupby: false
27+
id: 927
28+
is_certified: false
29+
is_dttm: false
30+
python_date_format: null
31+
type: Nullable(Int64)
32+
type_generic: 0
33+
verbose_name: Total Tokens
34+
warning_markdown: null
35+
aggregate: SUM
36+
sqlExpression: null
37+
datasourceWarning: false
38+
hasCustomLabel: true
39+
label: Total Tokens
40+
optionName: metric_qv3jyw4lu7_h9abbkf2v8u
41+
groupby:
42+
- workflow_name
43+
contributionMode: null
44+
adhoc_filters:
45+
- clause: WHERE
46+
comparator: No filter
47+
expressionType: SIMPLE
48+
operator: TEMPORAL_RANGE
49+
subject: emission_time
50+
- clause: WHERE
51+
comparator: No filter
52+
expressionType: SIMPLE
53+
operator: TEMPORAL_RANGE
54+
subject: emission_date
55+
order_desc: true
56+
row_limit: 10000
57+
truncate_metric: true
58+
show_empty_columns: true
59+
comparison_type: values
60+
annotation_layers: []
61+
forecastPeriods: 10
62+
forecastInterval: 0.8
63+
x_axis_title_margin: 15
64+
y_axis_title_margin: 15
65+
y_axis_title_position: Left
66+
sort_series_type: sum
67+
color_scheme: supersetColors
68+
seriesType: line
69+
only_total: true
70+
opacity: 0.2
71+
markerSize: 6
72+
show_legend: true
73+
legendType: scroll
74+
legendOrientation: top
75+
x_axis_time_format: smart_date
76+
rich_tooltip: true
77+
tooltipTimeFormat: smart_date
78+
y_axis_format: SMART_NUMBER
79+
truncateXAxis: true
80+
y_axis_bounds:
81+
- null
82+
- null
83+
extra_form_data: {}
84+
dashboards: []
85+
query_context: '{"datasource":{"id":92,"type":"table"},"force":false,"queries":[{"filters":[{"col":"emission_time","op":"TEMPORAL_RANGE","val":"No
86+
filter"},{"col":"emission_date","op":"TEMPORAL_RANGE","val":"No filter"}],"extras":{"time_grain_sqla":"P1D","having":"","where":""},"applied_time_extras":{},"columns":[{"timeGrain":"P1D","columnType":"BASE_AXIS","sqlExpression":"emission_date","label":"emission_date","expressionType":"SQL"},"workflow_name"],"metrics":[{"expressionType":"SIMPLE","column":{"advanced_data_type":null,"certification_details":null,"certified_by":null,"column_name":"total_tokens","description":"Total
87+
tokens used (prompt + completion)","expression":null,"filterable":true,"groupby":false,"id":927,"is_certified":false,"is_dttm":false,"python_date_format":null,"type":"Nullable(Int64)","type_generic":0,"verbose_name":"Total
88+
Tokens","warning_markdown":null},"aggregate":"SUM","sqlExpression":null,"datasourceWarning":false,"hasCustomLabel":true,"label":"Total
89+
Tokens","optionName":"metric_qv3jyw4lu7_h9abbkf2v8u"}],"orderby":[[{"expressionType":"SIMPLE","column":{"advanced_data_type":null,"certification_details":null,"certified_by":null,"column_name":"total_tokens","description":"Total
90+
tokens used (prompt + completion)","expression":null,"filterable":true,"groupby":false,"id":927,"is_certified":false,"is_dttm":false,"python_date_format":null,"type":"Nullable(Int64)","type_generic":0,"verbose_name":"Total
91+
Tokens","warning_markdown":null},"aggregate":"SUM","sqlExpression":null,"datasourceWarning":false,"hasCustomLabel":true,"label":"Total
92+
Tokens","optionName":"metric_qv3jyw4lu7_h9abbkf2v8u"},false]],"annotation_layers":[],"row_limit":10000,"series_columns":["workflow_name"],"series_limit":0,"order_desc":true,"url_params":{},"custom_params":{},"custom_form_data":{},"time_offsets":[],"post_processing":[{"operation":"pivot","options":{"index":["emission_date"],"columns":["workflow_name"],"aggregates":{"Total
93+
Tokens":{"operator":"mean"}},"drop_missing_columns":false}},{"operation":"rename","options":{"columns":{"Total
94+
Tokens":null},"level":0,"inplace":true}},{"operation":"flatten"}]}],"form_data":{"datasource":"92__table","viz_type":"echarts_timeseries_line","slice_id":167,"x_axis":"emission_date","time_grain_sqla":"P1D","x_axis_sort_asc":true,"x_axis_sort_series":"name","x_axis_sort_series_ascending":true,"metrics":[{"expressionType":"SIMPLE","column":{"advanced_data_type":null,"certification_details":null,"certified_by":null,"column_name":"total_tokens","description":"Total
95+
tokens used (prompt + completion)","expression":null,"filterable":true,"groupby":false,"id":927,"is_certified":false,"is_dttm":false,"python_date_format":null,"type":"Nullable(Int64)","type_generic":0,"verbose_name":"Total
96+
Tokens","warning_markdown":null},"aggregate":"SUM","sqlExpression":null,"datasourceWarning":false,"hasCustomLabel":true,"label":"Total
97+
Tokens","optionName":"metric_qv3jyw4lu7_h9abbkf2v8u"}],"groupby":["workflow_name"],"contributionMode":null,"adhoc_filters":[{"clause":"WHERE","comparator":"No
98+
filter","expressionType":"SIMPLE","operator":"TEMPORAL_RANGE","subject":"emission_time"},{"clause":"WHERE","comparator":"No
99+
filter","expressionType":"SIMPLE","operator":"TEMPORAL_RANGE","subject":"emission_date"}],"order_desc":true,"row_limit":10000,"truncate_metric":true,"show_empty_columns":true,"comparison_type":"values","annotation_layers":[],"forecastPeriods":10,"forecastInterval":0.8,"x_axis_title_margin":15,"y_axis_title_margin":15,"y_axis_title_position":"Left","sort_series_type":"sum","color_scheme":"supersetColors","seriesType":"line","only_total":true,"opacity":0.2,"markerSize":6,"show_legend":true,"legendType":"scroll","legendOrientation":"top","x_axis_time_format":"smart_date","rich_tooltip":true,"tooltipTimeFormat":"smart_date","y_axis_format":"SMART_NUMBER","truncateXAxis":true,"y_axis_bounds":[null,null],"extra_form_data":{},"dashboards":[],"force":false,"result_format":"json","result_type":"full"},"result_format":"json","result_type":"full"}'
100+
cache_timeout: null
101+
uuid: b13ccb0b-c3fe-4d04-9970-ee2c8c97ae3f
102+
version: 1.0.0
103+
dataset_uuid: a7c3e8f1-5b2d-4e9a-8f1c-3d7e5a9b2c4f
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
_file_name: event_count_by_verb.yaml
2+
uuid: 6c7d8e9f-0a1b-2c3d-4e5f-6a7b8c9d0e1f
3+
dataset_uuid: a7c3e8f1-5b2d-4e9a-8f1c-3d7e5a9b2c4f
4+
slice_name: Event Count by Verb
5+
description: null
6+
certified_by: null
7+
certification_details: null
8+
viz_type: pie
9+
params:
10+
datasource: 92__table
11+
viz_type: pie
12+
slice_id: 168
13+
groupby:
14+
- verb
15+
metric:
16+
expressionType: SIMPLE
17+
column:
18+
advanced_data_type: null
19+
certification_details: null
20+
certified_by: null
21+
column_name: event_id
22+
description: Unique identifier for each xAPI event
23+
expression: null
24+
filterable: true
25+
groupby: false
26+
id: 915
27+
is_certified: false
28+
is_dttm: false
29+
python_date_format: null
30+
type: UUID
31+
type_generic: 1
32+
verbose_name: Event ID
33+
warning_markdown: null
34+
aggregate: COUNT
35+
sqlExpression: null
36+
datasourceWarning: false
37+
hasCustomLabel: true
38+
label: Event Count
39+
optionName: metric_7421u8cab16_2gaahp2wrv4
40+
adhoc_filters:
41+
- clause: WHERE
42+
comparator: No filter
43+
expressionType: SIMPLE
44+
operator: TEMPORAL_RANGE
45+
subject: emission_time
46+
row_limit: 100
47+
sort_by_metric: true
48+
color_scheme: supersetColors
49+
show_labels_threshold: 5
50+
show_legend: true
51+
legendType: scroll
52+
legendOrientation: top
53+
label_type: key
54+
number_format: SMART_NUMBER
55+
date_format: smart_date
56+
show_labels: true
57+
labels_outside: true
58+
outerRadius: 70
59+
innerRadius: 30
60+
extra_form_data: {}
61+
dashboards: []
62+
query_context: null
63+
cache_timeout: null
64+
version: 1.0.0
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
_file_name: event_count_by_workflow.yaml
2+
uuid: 5b6c7d8e-9f0a-1b2c-3d4e-5f6a7b8c9d0e
3+
dataset_uuid: a7c3e8f1-5b2d-4e9a-8f1c-3d7e5a9b2c4f
4+
slice_name: Event Count by Workflow
5+
description: null
6+
certified_by: null
7+
certification_details: null
8+
viz_type: echarts_timeseries_bar
9+
params:
10+
datasource: 92__table
11+
viz_type: echarts_timeseries_bar
12+
slice_id: 169
13+
x_axis: workflow_name
14+
xAxisForceCategorical: true
15+
x_axis_sort: workflow_name
16+
x_axis_sort_asc: true
17+
x_axis_sort_series: name
18+
x_axis_sort_series_ascending: true
19+
metrics:
20+
- expressionType: SIMPLE
21+
column:
22+
advanced_data_type: null
23+
certification_details: null
24+
certified_by: null
25+
column_name: event_id
26+
description: Unique identifier for each xAPI event
27+
expression: null
28+
filterable: true
29+
groupby: false
30+
id: 915
31+
is_certified: false
32+
is_dttm: false
33+
python_date_format: null
34+
type: UUID
35+
type_generic: 1
36+
verbose_name: Event ID
37+
warning_markdown: null
38+
aggregate: COUNT
39+
sqlExpression: null
40+
datasourceWarning: false
41+
hasCustomLabel: true
42+
label: Event Count
43+
optionName: metric_13jy73i6akk_0hsv50zelfn
44+
groupby: []
45+
adhoc_filters:
46+
- clause: WHERE
47+
comparator: No filter
48+
expressionType: SIMPLE
49+
operator: TEMPORAL_RANGE
50+
subject: emission_time
51+
order_desc: true
52+
row_limit: 10000
53+
truncate_metric: true
54+
show_empty_columns: true
55+
comparison_type: values
56+
annotation_layers: []
57+
forecastPeriods: 10
58+
forecastInterval: 0.8
59+
orientation: vertical
60+
x_axis_title_margin: 15
61+
y_axis_title_margin: 15
62+
y_axis_title_position: Left
63+
sort_series_type: sum
64+
color_scheme: supersetColors
65+
only_total: true
66+
show_legend: true
67+
legendType: scroll
68+
legendOrientation: top
69+
x_axis_time_format: smart_date
70+
y_axis_format: SMART_NUMBER
71+
truncateXAxis: true
72+
y_axis_bounds:
73+
- null
74+
- null
75+
rich_tooltip: true
76+
tooltipTimeFormat: smart_date
77+
extra_form_data: {}
78+
dashboards: []
79+
query_context: null
80+
cache_timeout: null
81+
version: 1.0.0
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
_file_name: total_tokens_by_course.yaml
2+
uuid: 3f2e2d1c-4b5a-6e7f-8a9b-0c1d2e3f4a5b
3+
dataset_uuid: a7c3e8f1-5b2d-4e9a-8f1c-3d7e5a9b2c4f
4+
slice_name: Total Tokens By Course
5+
description: null
6+
certified_by: null
7+
certification_details: null
8+
viz_type: echarts_timeseries_bar
9+
params:
10+
datasource: 92__table
11+
viz_type: echarts_timeseries_bar
12+
slice_id: 170
13+
x_axis: course_key
14+
xAxisForceCategorical: true
15+
x_axis_sort: course_key
16+
x_axis_sort_asc: true
17+
x_axis_sort_series: name
18+
x_axis_sort_series_ascending: true
19+
metrics:
20+
- expressionType: SIMPLE
21+
column:
22+
advanced_data_type: null
23+
certification_details: null
24+
certified_by: null
25+
column_name: total_tokens
26+
description: Total tokens used (prompt + completion)
27+
expression: null
28+
filterable: true
29+
groupby: false
30+
id: 927
31+
is_certified: false
32+
is_dttm: false
33+
python_date_format: null
34+
type: Nullable(Int64)
35+
type_generic: 0
36+
verbose_name: Total Tokens
37+
warning_markdown: null
38+
aggregate: SUM
39+
sqlExpression: null
40+
datasourceWarning: false
41+
hasCustomLabel: true
42+
label: Total Tokens
43+
optionName: metric_gzreklovcg_eh7or6gyrcp
44+
groupby: []
45+
adhoc_filters:
46+
- clause: WHERE
47+
comparator: No filter
48+
expressionType: SIMPLE
49+
operator: TEMPORAL_RANGE
50+
subject: emission_time
51+
order_desc: true
52+
row_limit: 10000
53+
truncate_metric: true
54+
show_empty_columns: true
55+
comparison_type: values
56+
annotation_layers: []
57+
forecastPeriods: 10
58+
forecastInterval: 0.8
59+
orientation: vertical
60+
x_axis_title_margin: 15
61+
y_axis_title_margin: 15
62+
y_axis_title_position: Left
63+
sort_series_type: sum
64+
color_scheme: supersetColors
65+
only_total: true
66+
show_legend: true
67+
legendType: scroll
68+
legendOrientation: top
69+
x_axis_time_format: smart_date
70+
y_axis_format: SMART_NUMBER
71+
truncateXAxis: true
72+
y_axis_bounds:
73+
- null
74+
- null
75+
rich_tooltip: true
76+
tooltipTimeFormat: smart_date
77+
extra_form_data: {}
78+
dashboards: []
79+
query_context: null
80+
cache_timeout: null
81+
version: 1.0.0

0 commit comments

Comments
 (0)