Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
249 changes: 249 additions & 0 deletions llm/dashboard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 1,
"links": [],
"panels": [
{
"datasource": {
"type": "grafana-clickhouse-datasource",
"uid": "aesy917veeltsd"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"fillOpacity": 80,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineWidth": 1,
"scaleDistribution": {
"type": "linear"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 2,
"options": {
"barRadius": 0,
"barWidth": 0.97,
"fullHighlight": false,
"groupWidth": 0.7,
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"orientation": "auto",
"showValue": "always",
"stacking": "none",
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
},
"xField": "total_tokens",
"xTickLabelRotation": 0,
"xTickLabelSpacing": 0
},
"pluginVersion": "12.1.0",
"targets": [
{
"editorType": "sql",
"format": 1,
"meta": {
"builderOptions": {
"columns": [],
"database": "",
"limit": 1000,
"mode": "list",
"queryType": "table",
"table": ""
}
},
"pluginVersion": "4.10.1",
"queryType": "table",
"rawSql": "SELECT parent_run_id, total_tokens, total_cost, status\r\nFROM \"guardian\".\"langchain_metrics\"\r\nORDER BY start_time",
"refId": "A"
}
],
"title": "Token Metrics",
"type": "barchart"
},
{
"datasource": {
"type": "grafana-clickhouse-datasource",
"uid": "aesy917veeltsd"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "continuous-BlYlRd"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"fillOpacity": 80,
"gradientMode": "hue",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineWidth": 1,
"scaleDistribution": {
"type": "linear"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": 0
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 8
},
"id": 1,
"options": {
"barRadius": 0,
"barWidth": 0.97,
"colorByField": "duration",
"fullHighlight": false,
"groupWidth": 0.7,
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"orientation": "auto",
"showValue": "auto",
"stacking": "none",
"tooltip": {
"hideZeros": false,
"mode": "single",
"sort": "none"
},
"xTickLabelRotation": 0,
"xTickLabelSpacing": 0
},
"pluginVersion": "12.1.0",
"targets": [
{
"datasource": {
"type": "grafana-clickhouse-datasource",
"uid": "aesy917veeltsd"
},
"editorType": "sql",
"format": 1,
"meta": {
"builderOptions": {
"columns": [],
"database": "",
"limit": 1000,
"mode": "list",
"queryType": "table",
"table": ""
}
},
"pluginVersion": "4.10.1",
"queryType": "table",
"rawSql": "SELECT parent_run_id, duration, status, outputs\r\nFROM \"guardian\".\"langchain_metrics\"\r\nWHERE parent_run_id != 'None'\r\nORDER BY start_time ASC\r\nLIMIT 1000",
"refId": "A"
}
],
"title": "Duration Metrics",
"transparent": true,
"type": "barchart"
}
],
"preload": false,
"schemaVersion": 41,
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "2025-07-27T10:59:29.712Z",
"to": "2025-07-28T10:59:29.712Z"
},
"timepicker": {},
"timezone": "browser",
"title": "DB Metrics Visualization",
"uid": "90ced2bd-5ea8-42c5-b87b-be9e1a8cdb4c",
"version": 11
}
13 changes: 13 additions & 0 deletions llm/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: "3.8"

services:
grafana:
image: grafana/grafana-oss
container_name: grafana
ports:
- "3000:3000"
environment:
- GF_SECURITY_ALLOW_EMBEDDING=true
- GF_AUTH_ANONYMOUS_ENABLED=true
- GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer
restart: unless-stopped
17 changes: 14 additions & 3 deletions llm/langchain_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
LOADING_URL = "https://cdn.pixabay.com/animation/2025/04/08/09/08/09-08-31-655_512.gif"
DURATION_METRICS_URL = "http://localhost:3000/d-solo/90ced2bd-5ea8-42c5-b87b-be9e1a8cdb4c/db-metrics-visualization?orgId=1&from=1753395832378&to=1753417432378&timezone=browser&panelId=1&__feature.dashboardSceneSolo=true"
TOKEN_METRICS_URL = "http://localhost:3000/d-solo/90ced2bd-5ea8-42c5-b87b-be9e1a8cdb4c/db-metrics-visualization?orgId=1&from=1753645594350&to=1753667194350&timezone=browser&panelId=2&__feature.dashboardSceneSolo=true"

MOST_RECENT_RUNS_URL = "http://localhost:3000/d-solo/90ced2bd-5ea8-42c5-b87b-be9e1a8cdb4c/db-metrics-visualization?orgId=1&from=1753613969712&to=1753700369712&timezone=browser&panelId=4&__feature.dashboardSceneSolo=true"
CONTEXT_METRICS_URL = "http://localhost:3000/d-solo/90ced2bd-5ea8-42c5-b87b-be9e1a8cdb4c/db-metrics-visualization?orgId=1&from=1753645594350&to=1753667194350&timezone=browser&panelId=3&__feature.dashboardSceneSolo=true"
# Database options - customize these based on your available databases
DATABASE_OPTIONS = [
db.value[0] for db in Database
Expand Down Expand Up @@ -668,14 +669,24 @@ def log_user_interaction(interaction_type, details):


with tab4:
tab4a, tab4b = st.tabs(["Duration Metrics", "Token Metrics"])
tab4a, tab4b, tab4c, tab4d = st.tabs(["Most Recent Run", "Duration Metrics", "Token Metrics", "Context Metrics"])

with tab4a:
st.components.v1.html(
f'<iframe src="{MOST_RECENT_RUNS_URL}" width="1000" height="600" frameborder="0"></iframe>',
height=800)

with tab4b:
st.components.v1.html(
f'<iframe src="{DURATION_METRICS_URL}" width="1000" height="600" frameborder="0"></iframe>',
height=600)

with tab4b:
with tab4c:
st.components.v1.html(
f'<iframe src="{TOKEN_METRICS_URL}" width="1000" height="600" frameborder="0"></iframe>',
height=600)

with tab4d:
st.components.v1.html(
f'<iframe src="{CONTEXT_METRICS_URL}" width="1000" height="600" frameborder="0"></iframe>',
height=600)
Loading