@memberjunction/ng-dashboards 5.21.0 → 5.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -0
- package/dist/AI/components/agents/agent-configuration.component.d.ts.map +1 -1
- package/dist/AI/components/agents/agent-configuration.component.js +364 -362
- package/dist/AI/components/agents/agent-configuration.component.js.map +1 -1
- package/dist/AI/components/agents/agent-editor.component.js +2 -2
- package/dist/AI/components/autotagging/autotagging-pipeline-resource.component.d.ts +313 -0
- package/dist/AI/components/autotagging/autotagging-pipeline-resource.component.d.ts.map +1 -0
- package/dist/AI/components/autotagging/autotagging-pipeline-resource.component.js +2792 -0
- package/dist/AI/components/autotagging/autotagging-pipeline-resource.component.js.map +1 -0
- package/dist/AI/components/duplicates/duplicate-detection-resource.component.d.ts +382 -0
- package/dist/AI/components/duplicates/duplicate-detection-resource.component.d.ts.map +1 -0
- package/dist/AI/components/duplicates/duplicate-detection-resource.component.js +2683 -0
- package/dist/AI/components/duplicates/duplicate-detection-resource.component.js.map +1 -0
- package/dist/AI/components/execution-monitoring.component.d.ts.map +1 -1
- package/dist/AI/components/execution-monitoring.component.js +191 -197
- package/dist/AI/components/execution-monitoring.component.js.map +1 -1
- package/dist/AI/components/models/model-management.component.js +9 -8
- package/dist/AI/components/models/model-management.component.js.map +1 -1
- package/dist/AI/components/prompts/prompt-management.component.js +305 -299
- package/dist/AI/components/prompts/prompt-management.component.js.map +1 -1
- package/dist/AI/components/system/system-configuration.component.js +319 -313
- package/dist/AI/components/system/system-configuration.component.js.map +1 -1
- package/dist/AI/components/vectors/vector-management-resource.component.d.ts +240 -0
- package/dist/AI/components/vectors/vector-management-resource.component.d.ts.map +1 -0
- package/dist/AI/components/vectors/vector-management-resource.component.js +1767 -0
- package/dist/AI/components/vectors/vector-management-resource.component.js.map +1 -0
- package/dist/AI/index.d.ts +3 -0
- package/dist/AI/index.d.ts.map +1 -1
- package/dist/AI/index.js +6 -0
- package/dist/AI/index.js.map +1 -1
- package/dist/AI/services/ai-instrumentation.service.d.ts +50 -7
- package/dist/AI/services/ai-instrumentation.service.d.ts.map +1 -1
- package/dist/AI/services/ai-instrumentation.service.js +161 -193
- package/dist/AI/services/ai-instrumentation.service.js.map +1 -1
- package/dist/APIKeys/api-applications-panel.component.js +10 -12
- package/dist/APIKeys/api-applications-panel.component.js.map +1 -1
- package/dist/APIKeys/api-key-create-dialog.component.js +13 -19
- package/dist/APIKeys/api-key-create-dialog.component.js.map +1 -1
- package/dist/APIKeys/api-key-edit-panel.component.js +12 -14
- package/dist/APIKeys/api-key-edit-panel.component.js.map +1 -1
- package/dist/APIKeys/api-scopes-panel.component.js +61 -68
- package/dist/APIKeys/api-scopes-panel.component.js.map +1 -1
- package/dist/APIKeys/api-usage-panel.component.js +10 -11
- package/dist/APIKeys/api-usage-panel.component.js.map +1 -1
- package/dist/Actions/components/actions-list-view.component.js +82 -96
- package/dist/Actions/components/actions-list-view.component.js.map +1 -1
- package/dist/Actions/components/actions-overview.component.js +130 -134
- package/dist/Actions/components/actions-overview.component.js.map +1 -1
- package/dist/Actions/components/categories-list-view.component.d.ts.map +1 -1
- package/dist/Actions/components/categories-list-view.component.js +40 -46
- package/dist/Actions/components/categories-list-view.component.js.map +1 -1
- package/dist/Actions/components/code-management.component.js +2 -2
- package/dist/Actions/components/code-management.component.js.map +1 -1
- package/dist/Actions/components/entity-integration.component.js +2 -2
- package/dist/Actions/components/entity-integration.component.js.map +1 -1
- package/dist/Actions/components/execution-monitoring.component.js +127 -132
- package/dist/Actions/components/execution-monitoring.component.js.map +1 -1
- package/dist/Actions/components/executions-list-view.component.js +2 -2
- package/dist/Actions/components/executions-list-view.component.js.map +1 -1
- package/dist/Actions/components/explorer/action-card.component.js +11 -17
- package/dist/Actions/components/explorer/action-card.component.js.map +1 -1
- package/dist/Actions/components/explorer/action-explorer.component.js +5 -11
- package/dist/Actions/components/explorer/action-explorer.component.js.map +1 -1
- package/dist/Actions/components/explorer/action-list-item.component.js +8 -10
- package/dist/Actions/components/explorer/action-list-item.component.js.map +1 -1
- package/dist/Actions/components/explorer/action-toolbar.component.js +112 -133
- package/dist/Actions/components/explorer/action-toolbar.component.js.map +1 -1
- package/dist/Actions/components/explorer/action-tree-panel.component.js +63 -83
- package/dist/Actions/components/explorer/action-tree-panel.component.js.map +1 -1
- package/dist/Actions/components/explorer/new-action-panel.component.js +17 -21
- package/dist/Actions/components/explorer/new-action-panel.component.js.map +1 -1
- package/dist/Actions/components/explorer/new-category-panel.component.js +17 -21
- package/dist/Actions/components/explorer/new-category-panel.component.js.map +1 -1
- package/dist/Actions/components/scheduled-actions.component.js +2 -2
- package/dist/Actions/components/scheduled-actions.component.js.map +1 -1
- package/dist/Actions/components/security-permissions.component.js +2 -2
- package/dist/Actions/components/security-permissions.component.js.map +1 -1
- package/dist/ComponentStudio/component-studio-dashboard.component.d.ts +13 -5
- package/dist/ComponentStudio/component-studio-dashboard.component.d.ts.map +1 -1
- package/dist/ComponentStudio/component-studio-dashboard.component.js +168 -145
- package/dist/ComponentStudio/component-studio-dashboard.component.js.map +1 -1
- package/dist/ComponentStudio/components/artifact-load-dialog.component.d.ts +4 -5
- package/dist/ComponentStudio/components/artifact-load-dialog.component.d.ts.map +1 -1
- package/dist/ComponentStudio/components/artifact-load-dialog.component.js +197 -200
- package/dist/ComponentStudio/components/artifact-load-dialog.component.js.map +1 -1
- package/dist/ComponentStudio/components/artifact-selection-dialog.component.d.ts +5 -7
- package/dist/ComponentStudio/components/artifact-selection-dialog.component.d.ts.map +1 -1
- package/dist/ComponentStudio/components/artifact-selection-dialog.component.js +142 -148
- package/dist/ComponentStudio/components/artifact-selection-dialog.component.js.map +1 -1
- package/dist/ComponentStudio/components/browser/component-browser.component.js +153 -166
- package/dist/ComponentStudio/components/browser/component-browser.component.js.map +1 -1
- package/dist/ComponentStudio/components/editors/code-editor-panel.component.js +15 -20
- package/dist/ComponentStudio/components/editors/code-editor-panel.component.js.map +1 -1
- package/dist/ComponentStudio/components/editors/data-requirements-editor.component.js +16 -21
- package/dist/ComponentStudio/components/editors/data-requirements-editor.component.js.map +1 -1
- package/dist/ComponentStudio/components/editors/requirements-editor.component.js +18 -23
- package/dist/ComponentStudio/components/editors/requirements-editor.component.js.map +1 -1
- package/dist/ComponentStudio/components/editors/spec-editor.component.js +25 -30
- package/dist/ComponentStudio/components/editors/spec-editor.component.js.map +1 -1
- package/dist/ComponentStudio/components/new-component-dialog/new-component-dialog.component.js +10 -11
- package/dist/ComponentStudio/components/new-component-dialog/new-component-dialog.component.js.map +1 -1
- package/dist/ComponentStudio/components/save-version-dialog/save-version-dialog.component.d.ts.map +1 -1
- package/dist/ComponentStudio/components/save-version-dialog/save-version-dialog.component.js +24 -35
- package/dist/ComponentStudio/components/save-version-dialog/save-version-dialog.component.js.map +1 -1
- package/dist/ComponentStudio/components/text-import-dialog.component.js +15 -17
- package/dist/ComponentStudio/components/text-import-dialog.component.js.map +1 -1
- package/dist/Credentials/components/credentials-categories-resource.component.js +7 -6
- package/dist/Credentials/components/credentials-categories-resource.component.js.map +1 -1
- package/dist/Credentials/components/credentials-list-resource.component.js +6 -5
- package/dist/Credentials/components/credentials-list-resource.component.js.map +1 -1
- package/dist/Credentials/components/credentials-types-resource.component.js +7 -6
- package/dist/Credentials/components/credentials-types-resource.component.js.map +1 -1
- package/dist/DashboardBrowser/dashboard-browser-resource.component.d.ts +11 -0
- package/dist/DashboardBrowser/dashboard-browser-resource.component.d.ts.map +1 -1
- package/dist/DashboardBrowser/dashboard-browser-resource.component.js +57 -0
- package/dist/DashboardBrowser/dashboard-browser-resource.component.js.map +1 -1
- package/dist/DashboardBrowser/dashboard-share-dialog.component.js +9 -9
- package/dist/DashboardBrowser/dashboard-share-dialog.component.js.map +1 -1
- package/dist/DataExplorer/components/navigation-panel/navigation-panel.component.d.ts +1 -1
- package/dist/DataExplorer/data-explorer-dashboard.component.d.ts +10 -2
- package/dist/DataExplorer/data-explorer-dashboard.component.d.ts.map +1 -1
- package/dist/DataExplorer/data-explorer-dashboard.component.js +35 -11
- package/dist/DataExplorer/data-explorer-dashboard.component.js.map +1 -1
- package/dist/DataExplorer/data-explorer-resource.component.d.ts +1 -0
- package/dist/DataExplorer/data-explorer-resource.component.d.ts.map +1 -1
- package/dist/DataExplorer/data-explorer-resource.component.js +8 -4
- package/dist/DataExplorer/data-explorer-resource.component.js.map +1 -1
- package/dist/Home/home-dashboard.component.d.ts +181 -1
- package/dist/Home/home-dashboard.component.d.ts.map +1 -1
- package/dist/Home/home-dashboard.component.js +1704 -182
- package/dist/Home/home-dashboard.component.js.map +1 -1
- package/dist/Integration/components/connections/connections.component.js +4 -4
- package/dist/Integration/components/connections/connections.component.js.map +1 -1
- package/dist/Integration/components/mapping-workspace/mapping-workspace.component.js +246 -259
- package/dist/Integration/components/mapping-workspace/mapping-workspace.component.js.map +1 -1
- package/dist/Integration/components/widgets/integration-card.component.js +7 -9
- package/dist/Integration/components/widgets/integration-card.component.js.map +1 -1
- package/dist/Integration/integration.module.d.ts +6 -10
- package/dist/Integration/integration.module.d.ts.map +1 -1
- package/dist/Integration/integration.module.js +12 -20
- package/dist/Integration/integration.module.js.map +1 -1
- package/dist/KnowledgeHub/components/clusters/cluster-visualization-resource.component.d.ts +106 -0
- package/dist/KnowledgeHub/components/clusters/cluster-visualization-resource.component.d.ts.map +1 -0
- package/dist/KnowledgeHub/components/clusters/cluster-visualization-resource.component.js +607 -0
- package/dist/KnowledgeHub/components/clusters/cluster-visualization-resource.component.js.map +1 -0
- package/dist/KnowledgeHub/components/config/knowledge-config-resource.component.d.ts +126 -0
- package/dist/KnowledgeHub/components/config/knowledge-config-resource.component.d.ts.map +1 -0
- package/dist/KnowledgeHub/components/config/knowledge-config-resource.component.js +1086 -0
- package/dist/KnowledgeHub/components/config/knowledge-config-resource.component.js.map +1 -0
- package/dist/KnowledgeHub/components/results-detail/search-result-detail.component.d.ts +56 -0
- package/dist/KnowledgeHub/components/results-detail/search-result-detail.component.d.ts.map +1 -0
- package/dist/KnowledgeHub/components/results-detail/search-result-detail.component.js +291 -0
- package/dist/KnowledgeHub/components/results-detail/search-result-detail.component.js.map +1 -0
- package/dist/KnowledgeHub/components/search/knowledge-search-resource.component.d.ts +85 -0
- package/dist/KnowledgeHub/components/search/knowledge-search-resource.component.d.ts.map +1 -0
- package/dist/KnowledgeHub/components/search/knowledge-search-resource.component.js +461 -0
- package/dist/KnowledgeHub/components/search/knowledge-search-resource.component.js.map +1 -0
- package/dist/KnowledgeHub/index.d.ts +5 -0
- package/dist/KnowledgeHub/index.d.ts.map +1 -0
- package/dist/KnowledgeHub/index.js +6 -0
- package/dist/KnowledgeHub/index.js.map +1 -0
- package/dist/Lists/components/lists-browse-resource.component.d.ts.map +1 -1
- package/dist/Lists/components/lists-browse-resource.component.js +9 -7
- package/dist/Lists/components/lists-browse-resource.component.js.map +1 -1
- package/dist/Lists/components/lists-my-lists-resource.component.js +5 -4
- package/dist/Lists/components/lists-my-lists-resource.component.js.map +1 -1
- package/dist/Lists/components/lists-operations-resource.component.js +10 -9
- package/dist/Lists/components/lists-operations-resource.component.js.map +1 -1
- package/dist/MCP/components/mcp-connection-dialog.component.js +141 -132
- package/dist/MCP/components/mcp-connection-dialog.component.js.map +1 -1
- package/dist/MCP/components/mcp-log-detail-panel.component.js +4 -4
- package/dist/MCP/components/mcp-log-detail-panel.component.js.map +1 -1
- package/dist/MCP/components/mcp-server-dialog.component.js +141 -128
- package/dist/MCP/components/mcp-server-dialog.component.js.map +1 -1
- package/dist/MCP/components/mcp-test-tool-dialog.component.js +210 -218
- package/dist/MCP/components/mcp-test-tool-dialog.component.js.map +1 -1
- package/dist/MCP/mcp-dashboard.component.js +2 -2
- package/dist/MCP/mcp-dashboard.component.js.map +1 -1
- package/dist/MCP/mcp.module.d.ts +6 -9
- package/dist/MCP/mcp.module.d.ts.map +1 -1
- package/dist/MCP/mcp.module.js +20 -22
- package/dist/MCP/mcp.module.js.map +1 -1
- package/dist/QueryBrowser/query-browser-resource.component.d.ts.map +1 -1
- package/dist/QueryBrowser/query-browser-resource.component.js +5 -1
- package/dist/QueryBrowser/query-browser-resource.component.js.map +1 -1
- package/dist/Scheduling/components/scheduling-activity.component.js +5 -4
- package/dist/Scheduling/components/scheduling-activity.component.js.map +1 -1
- package/dist/Scheduling/components/scheduling-jobs.component.js +6 -5
- package/dist/Scheduling/components/scheduling-jobs.component.js.map +1 -1
- package/dist/Scheduling/components/scheduling-overview.component.js +93 -92
- package/dist/Scheduling/components/scheduling-overview.component.js.map +1 -1
- package/dist/SystemDiagnostics/system-diagnostics.component.d.ts.map +1 -1
- package/dist/SystemDiagnostics/system-diagnostics.component.js +1 -0
- package/dist/SystemDiagnostics/system-diagnostics.component.js.map +1 -1
- package/dist/Testing/components/testing-dashboard-tab-resource.component.d.ts +7 -1
- package/dist/Testing/components/testing-dashboard-tab-resource.component.d.ts.map +1 -1
- package/dist/Testing/components/testing-dashboard-tab-resource.component.js +63 -8
- package/dist/Testing/components/testing-dashboard-tab-resource.component.js.map +1 -1
- package/dist/Testing/components/testing-dashboard-tab.component.d.ts +9 -1
- package/dist/Testing/components/testing-dashboard-tab.component.d.ts.map +1 -1
- package/dist/Testing/components/testing-dashboard-tab.component.js +109 -62
- package/dist/Testing/components/testing-dashboard-tab.component.js.map +1 -1
- package/dist/Testing/components/testing-explorer.component.d.ts +2 -1
- package/dist/Testing/components/testing-explorer.component.d.ts.map +1 -1
- package/dist/Testing/components/testing-explorer.component.js +241 -200
- package/dist/Testing/components/testing-explorer.component.js.map +1 -1
- package/dist/Testing/components/testing-runs-resource.component.d.ts +7 -1
- package/dist/Testing/components/testing-runs-resource.component.d.ts.map +1 -1
- package/dist/Testing/components/testing-runs-resource.component.js +63 -8
- package/dist/Testing/components/testing-runs-resource.component.js.map +1 -1
- package/dist/Testing/components/testing-runs.component.d.ts.map +1 -1
- package/dist/Testing/components/testing-runs.component.js +7 -5
- package/dist/Testing/components/testing-runs.component.js.map +1 -1
- package/dist/Testing/testing-dashboard.component.d.ts +9 -1
- package/dist/Testing/testing-dashboard.component.d.ts.map +1 -1
- package/dist/Testing/testing-dashboard.component.js +122 -54
- package/dist/Testing/testing-dashboard.component.js.map +1 -1
- package/dist/actions-dashboards.module.d.ts +8 -13
- package/dist/actions-dashboards.module.d.ts.map +1 -1
- package/dist/actions-dashboards.module.js +6 -27
- package/dist/actions-dashboards.module.js.map +1 -1
- package/dist/ai-dashboards.module.d.ts +14 -11
- package/dist/ai-dashboards.module.d.ts.map +1 -1
- package/dist/ai-dashboards.module.js +58 -44
- package/dist/ai-dashboards.module.js.map +1 -1
- package/dist/communication-dashboards.module.d.ts +4 -8
- package/dist/communication-dashboards.module.d.ts.map +1 -1
- package/dist/communication-dashboards.module.js +0 -19
- package/dist/communication-dashboards.module.js.map +1 -1
- package/dist/component-studio-dashboards.module.d.ts +7 -11
- package/dist/component-studio-dashboards.module.d.ts.map +1 -1
- package/dist/component-studio-dashboards.module.js +22 -34
- package/dist/component-studio-dashboards.module.js.map +1 -1
- package/dist/core-dashboards.module.d.ts +13 -18
- package/dist/core-dashboards.module.d.ts.map +1 -1
- package/dist/core-dashboards.module.js +18 -31
- package/dist/core-dashboards.module.js.map +1 -1
- package/dist/credentials-dashboards.module.d.ts +5 -8
- package/dist/credentials-dashboards.module.d.ts.map +1 -1
- package/dist/credentials-dashboards.module.js +3 -19
- package/dist/credentials-dashboards.module.js.map +1 -1
- package/dist/data-explorer-dashboards.module.d.ts +7 -13
- package/dist/data-explorer-dashboards.module.d.ts.map +1 -1
- package/dist/data-explorer-dashboards.module.js +0 -27
- package/dist/data-explorer-dashboards.module.js.map +1 -1
- package/dist/lists-dashboards.module.d.ts +5 -8
- package/dist/lists-dashboards.module.d.ts.map +1 -1
- package/dist/lists-dashboards.module.js +3 -19
- package/dist/lists-dashboards.module.js.map +1 -1
- package/dist/public-api.d.ts +5 -1
- package/dist/public-api.d.ts.map +1 -1
- package/dist/public-api.js +6 -1
- package/dist/public-api.js.map +1 -1
- package/dist/scheduling-dashboards.module.d.ts +6 -10
- package/dist/scheduling-dashboards.module.d.ts.map +1 -1
- package/dist/scheduling-dashboards.module.js +3 -23
- package/dist/scheduling-dashboards.module.js.map +1 -1
- package/dist/testing-dashboards.module.d.ts +7 -12
- package/dist/testing-dashboards.module.d.ts.map +1 -1
- package/dist/testing-dashboards.module.js +4 -27
- package/dist/testing-dashboards.module.js.map +1 -1
- package/package.json +47 -53
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import { Injectable } from '@angular/core';
|
|
2
2
|
import { BehaviorSubject, from, combineLatest } from 'rxjs';
|
|
3
|
-
import { switchMap, shareReplay, tap } from 'rxjs/operators';
|
|
4
|
-
import { RunView
|
|
3
|
+
import { switchMap, shareReplay, tap, map } from 'rxjs/operators';
|
|
4
|
+
import { RunView } from '@memberjunction/core';
|
|
5
5
|
import * as i0 from "@angular/core";
|
|
6
|
+
/** Fields to request for prompt runs — only what the dashboard needs for aggregation */
|
|
7
|
+
const PROMPT_RUN_FIELDS = [
|
|
8
|
+
'ID', 'RunAt', 'CompletedAt', 'Success', 'Cost', 'TokensUsed',
|
|
9
|
+
'TokensPrompt', 'TokensCompletion', 'ExecutionTimeMS',
|
|
10
|
+
'ModelID', 'Model', 'AgentID', 'Agent', 'Prompt', 'ErrorMessage'
|
|
11
|
+
];
|
|
12
|
+
/** Fields to request for agent runs — only what the dashboard needs for aggregation */
|
|
13
|
+
const AGENT_RUN_FIELDS = [
|
|
14
|
+
'ID', 'StartedAt', 'CompletedAt', 'Status', 'Success',
|
|
15
|
+
'TotalCost', 'TotalTokensUsed', 'AgentID', 'Agent', 'ErrorMessage'
|
|
16
|
+
];
|
|
6
17
|
export class AIInstrumentationService {
|
|
7
18
|
_dateRange$ = new BehaviorSubject({
|
|
8
19
|
start: new Date(Date.now() - 24 * 60 * 60 * 1000), // Last 24 hours
|
|
@@ -10,57 +21,77 @@ export class AIInstrumentationService {
|
|
|
10
21
|
});
|
|
11
22
|
_refreshTrigger$ = new BehaviorSubject(0);
|
|
12
23
|
_isLoading$ = new BehaviorSubject(false);
|
|
13
|
-
metadata = new Metadata();
|
|
14
24
|
// Expose loading state as observable
|
|
15
25
|
isLoading$ = this._isLoading$.asObservable();
|
|
16
26
|
constructor() { }
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}, 100);
|
|
28
|
-
}
|
|
27
|
+
/**
|
|
28
|
+
* Single data load: fetches prompt runs and agent runs ONCE per refresh/date-range change.
|
|
29
|
+
* All downstream streams derive from this shared dataset.
|
|
30
|
+
*/
|
|
31
|
+
rawData$ = combineLatest([this._refreshTrigger$, this._dateRange$]).pipe(tap(() => this._isLoading$.next(true)), switchMap(() => from(this.loadAllData())), tap(() => this._isLoading$.next(false)), shareReplay(1));
|
|
32
|
+
// Derived streams — pure in-memory transforms, no extra DB queries
|
|
33
|
+
kpis$ = this.rawData$.pipe(map(data => this.computeKPIs(data.promptRuns, data.agentRuns)), shareReplay(1));
|
|
34
|
+
trends$ = this.rawData$.pipe(map(data => this.computeTrends(data.promptRuns, data.agentRuns)), shareReplay(1));
|
|
35
|
+
liveExecutions$ = this.rawData$.pipe(map(data => this.computeLiveExecutions(data.livePromptRuns, data.liveAgentRuns)), shareReplay(1));
|
|
36
|
+
chartData$ = combineLatest([this.rawData$, this.trends$]).pipe(map(([data, executionTrends]) => this.computeChartData(data.promptRuns, executionTrends)), shareReplay(1));
|
|
29
37
|
setDateRange(start, end) {
|
|
30
38
|
this._dateRange$.next({ start, end });
|
|
31
|
-
// No need to manually refresh - streams now react to date range changes
|
|
32
39
|
}
|
|
33
40
|
refresh() {
|
|
34
41
|
this._refreshTrigger$.next(this._refreshTrigger$.value + 1);
|
|
35
42
|
}
|
|
36
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Single batch query that loads all data needed by every dashboard widget.
|
|
45
|
+
* Uses ResultType: 'simple' with explicit Fields to minimize payload size.
|
|
46
|
+
*/
|
|
47
|
+
async loadAllData() {
|
|
37
48
|
const { start, end } = this._dateRange$.value;
|
|
49
|
+
const now = new Date();
|
|
50
|
+
const recentTime = new Date(now.getTime() - 5 * 60 * 1000);
|
|
38
51
|
const rv = new RunView();
|
|
39
|
-
|
|
40
|
-
|
|
52
|
+
const [promptResults, agentResults, livePromptResults, liveAgentResults] = await rv.RunViews([
|
|
53
|
+
{
|
|
54
|
+
EntityName: 'MJ: AI Prompt Runs',
|
|
55
|
+
ExtraFilter: `RunAt >= '${start.toISOString()}' AND RunAt <= '${end.toISOString()}'`,
|
|
56
|
+
Fields: PROMPT_RUN_FIELDS,
|
|
57
|
+
ResultType: 'simple'
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
EntityName: 'MJ: AI Agent Runs',
|
|
61
|
+
ExtraFilter: `StartedAt >= '${start.toISOString()}' AND StartedAt <= '${end.toISOString()}'`,
|
|
62
|
+
Fields: AGENT_RUN_FIELDS,
|
|
63
|
+
ResultType: 'simple'
|
|
64
|
+
},
|
|
41
65
|
{
|
|
42
66
|
EntityName: 'MJ: AI Prompt Runs',
|
|
43
|
-
ExtraFilter: `RunAt >= '${
|
|
67
|
+
ExtraFilter: `RunAt >= '${recentTime.toISOString()}'`,
|
|
68
|
+
OrderBy: 'RunAt DESC',
|
|
69
|
+
Fields: PROMPT_RUN_FIELDS,
|
|
70
|
+
ResultType: 'simple'
|
|
44
71
|
},
|
|
45
72
|
{
|
|
46
73
|
EntityName: 'MJ: AI Agent Runs',
|
|
47
|
-
ExtraFilter: `StartedAt >= '${
|
|
74
|
+
ExtraFilter: `StartedAt >= '${recentTime.toISOString()}'`,
|
|
75
|
+
OrderBy: 'StartedAt DESC',
|
|
76
|
+
Fields: AGENT_RUN_FIELDS,
|
|
77
|
+
ResultType: 'simple'
|
|
48
78
|
}
|
|
49
79
|
]);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
80
|
+
return {
|
|
81
|
+
promptRuns: promptResults.Results,
|
|
82
|
+
agentRuns: agentResults.Results,
|
|
83
|
+
livePromptRuns: livePromptResults.Results,
|
|
84
|
+
liveAgentRuns: liveAgentResults.Results
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
// ─── KPI Computation ─────────────────────────────────────────────
|
|
88
|
+
computeKPIs(promptRuns, agentRuns) {
|
|
53
89
|
const totalExecutions = promptRuns.length + agentRuns.length;
|
|
54
90
|
const activeExecutions = this.countActiveExecutions(promptRuns, agentRuns);
|
|
55
91
|
const totalCost = this.sumCosts(promptRuns, agentRuns);
|
|
56
92
|
const totalTokens = this.sumTokens(promptRuns, agentRuns);
|
|
57
93
|
const avgExecutionTime = this.calculateAverageExecutionTime(promptRuns, agentRuns);
|
|
58
94
|
const successRate = this.calculateSuccessRate(promptRuns, agentRuns);
|
|
59
|
-
const errorRate = 1 - successRate;
|
|
60
|
-
const costPerToken = totalTokens > 0 ? totalCost / totalTokens : 0;
|
|
61
|
-
const dailyCostBurn = this.calculateDailyCostBurn(promptRuns, agentRuns);
|
|
62
|
-
const topModel = await this.getTopModel(promptRuns);
|
|
63
|
-
const topAgent = await this.getTopAgent(agentRuns);
|
|
64
95
|
return {
|
|
65
96
|
totalExecutions,
|
|
66
97
|
activeExecutions,
|
|
@@ -69,118 +100,71 @@ export class AIInstrumentationService {
|
|
|
69
100
|
avgExecutionTime,
|
|
70
101
|
successRate,
|
|
71
102
|
totalTokens,
|
|
72
|
-
costPerToken,
|
|
73
|
-
topModel,
|
|
74
|
-
topAgent,
|
|
75
|
-
errorRate,
|
|
76
|
-
dailyCostBurn
|
|
103
|
+
costPerToken: totalTokens > 0 ? totalCost / totalTokens : 0,
|
|
104
|
+
topModel: this.getTopModel(promptRuns),
|
|
105
|
+
topAgent: this.getTopAgent(agentRuns),
|
|
106
|
+
errorRate: 1 - successRate,
|
|
107
|
+
dailyCostBurn: this.calculateDailyCostBurn(promptRuns, agentRuns)
|
|
77
108
|
};
|
|
78
109
|
}
|
|
79
|
-
|
|
110
|
+
// ─── Trend Computation ────────────────────────────────────────────
|
|
111
|
+
computeTrends(promptRuns, agentRuns) {
|
|
80
112
|
const { start, end } = this._dateRange$.value;
|
|
113
|
+
const bucketSizeMs = this.getBucketSizeMs(start, end);
|
|
81
114
|
const hourlyBuckets = this.createHourlyBuckets(start, end);
|
|
82
|
-
|
|
83
|
-
const duration = end.getTime() - start.getTime();
|
|
84
|
-
const hours = duration / (1000 * 60 * 60);
|
|
85
|
-
let bucketSizeMs;
|
|
86
|
-
if (hours <= 24) {
|
|
87
|
-
bucketSizeMs = 60 * 60 * 1000; // 1 hour
|
|
88
|
-
}
|
|
89
|
-
else if (hours <= 24 * 7) {
|
|
90
|
-
bucketSizeMs = 4 * 60 * 60 * 1000; // 4 hours
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
bucketSizeMs = 24 * 60 * 60 * 1000; // 24 hours
|
|
94
|
-
}
|
|
95
|
-
// Load all data in a single query instead of per-bucket
|
|
96
|
-
const rv = new RunView();
|
|
97
|
-
const [promptResults, agentResults] = await rv.RunViews([
|
|
98
|
-
{
|
|
99
|
-
EntityName: 'MJ: AI Prompt Runs',
|
|
100
|
-
ExtraFilter: `RunAt >= '${start.toISOString()}' AND RunAt <= '${end.toISOString()}'`
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
EntityName: 'MJ: AI Agent Runs',
|
|
104
|
-
ExtraFilter: `StartedAt >= '${start.toISOString()}' AND StartedAt <= '${end.toISOString()}'`
|
|
105
|
-
}
|
|
106
|
-
]);
|
|
107
|
-
const allPromptRuns = promptResults.Results;
|
|
108
|
-
const allAgentRuns = agentResults.Results;
|
|
109
|
-
// Now aggregate data into buckets on the client side
|
|
110
|
-
const trends = [];
|
|
111
|
-
for (const bucket of hourlyBuckets) {
|
|
112
|
-
const bucketStart = bucket;
|
|
115
|
+
return hourlyBuckets.map(bucket => {
|
|
113
116
|
const bucketEnd = new Date(bucket.getTime() + bucketSizeMs);
|
|
114
|
-
|
|
115
|
-
const promptRuns = allPromptRuns.filter(r => {
|
|
117
|
+
const bucketPrompts = promptRuns.filter(r => {
|
|
116
118
|
const runAt = new Date(r.RunAt);
|
|
117
|
-
return runAt >=
|
|
119
|
+
return runAt >= bucket && runAt < bucketEnd;
|
|
118
120
|
});
|
|
119
|
-
const
|
|
121
|
+
const bucketAgents = agentRuns.filter(r => {
|
|
120
122
|
const startedAt = new Date(r.StartedAt);
|
|
121
|
-
return startedAt >=
|
|
123
|
+
return startedAt >= bucket && startedAt < bucketEnd;
|
|
122
124
|
});
|
|
123
|
-
|
|
125
|
+
return {
|
|
124
126
|
timestamp: bucket,
|
|
125
|
-
executions:
|
|
126
|
-
cost: this.sumCosts(
|
|
127
|
-
tokens: this.sumTokens(
|
|
128
|
-
avgTime: this.calculateAverageExecutionTime(
|
|
129
|
-
errors: this.countErrors(
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return trends;
|
|
127
|
+
executions: bucketPrompts.length + bucketAgents.length,
|
|
128
|
+
cost: this.sumCosts(bucketPrompts, bucketAgents),
|
|
129
|
+
tokens: this.sumTokens(bucketPrompts, bucketAgents),
|
|
130
|
+
avgTime: this.calculateAverageExecutionTime(bucketPrompts, bucketAgents),
|
|
131
|
+
errors: this.countErrors(bucketPrompts, bucketAgents)
|
|
132
|
+
};
|
|
133
|
+
});
|
|
133
134
|
}
|
|
134
|
-
|
|
135
|
+
// ─── Live Executions Computation ──────────────────────────────────
|
|
136
|
+
computeLiveExecutions(promptRuns, agentRuns) {
|
|
135
137
|
const now = new Date();
|
|
136
|
-
const recentTime = new Date(now.getTime() - 5 * 60 * 1000);
|
|
137
|
-
const rv = new RunView();
|
|
138
|
-
const [promptResults, agentResults] = await rv.RunViews([
|
|
139
|
-
{
|
|
140
|
-
EntityName: 'MJ: AI Prompt Runs',
|
|
141
|
-
ExtraFilter: `RunAt >= '${recentTime.toISOString()}'`,
|
|
142
|
-
OrderBy: 'RunAt DESC'
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
EntityName: 'MJ: AI Agent Runs',
|
|
146
|
-
ExtraFilter: `StartedAt >= '${recentTime.toISOString()}'`,
|
|
147
|
-
OrderBy: 'StartedAt DESC'
|
|
148
|
-
}
|
|
149
|
-
]);
|
|
150
|
-
const promptRuns = promptResults.Results;
|
|
151
|
-
const agentRuns = agentResults.Results;
|
|
152
138
|
const liveExecutions = [];
|
|
153
|
-
// Process prompt runs - they already have the prompt name in the Prompt field
|
|
154
139
|
for (const run of promptRuns) {
|
|
155
140
|
const isRunning = !run.CompletedAt && run.Success !== false;
|
|
156
|
-
const duration = run.CompletedAt
|
|
157
|
-
new Date(run.CompletedAt).getTime() - new Date(run.RunAt).getTime()
|
|
158
|
-
now.getTime() - new Date(run.RunAt).getTime();
|
|
141
|
+
const duration = run.CompletedAt
|
|
142
|
+
? new Date(run.CompletedAt).getTime() - new Date(run.RunAt).getTime()
|
|
143
|
+
: now.getTime() - new Date(run.RunAt).getTime();
|
|
159
144
|
liveExecutions.push({
|
|
160
145
|
id: run.ID,
|
|
161
146
|
type: 'prompt',
|
|
162
|
-
name: run.Prompt || 'Unnamed Prompt',
|
|
147
|
+
name: run.Prompt || 'Unnamed Prompt',
|
|
163
148
|
status: isRunning ? 'running' : (run.Success ? 'completed' : 'failed'),
|
|
164
149
|
startTime: new Date(run.RunAt),
|
|
165
|
-
duration
|
|
150
|
+
duration,
|
|
166
151
|
cost: run.Cost || 0,
|
|
167
152
|
tokens: run.TokensUsed || 0,
|
|
168
153
|
progress: isRunning ? Math.min(90, (duration / 30000) * 100) : 100
|
|
169
154
|
});
|
|
170
155
|
}
|
|
171
|
-
// Process agent runs - they already have the agent name in the Agent field
|
|
172
156
|
for (const run of agentRuns) {
|
|
173
157
|
const isRunning = run.Status === 'Running';
|
|
174
|
-
const duration = run.CompletedAt
|
|
175
|
-
new Date(run.CompletedAt).getTime() - new Date(run.StartedAt).getTime()
|
|
176
|
-
now.getTime() - new Date(run.StartedAt).getTime();
|
|
158
|
+
const duration = run.CompletedAt
|
|
159
|
+
? new Date(run.CompletedAt).getTime() - new Date(run.StartedAt).getTime()
|
|
160
|
+
: now.getTime() - new Date(run.StartedAt).getTime();
|
|
177
161
|
liveExecutions.push({
|
|
178
162
|
id: run.ID,
|
|
179
163
|
type: 'agent',
|
|
180
|
-
name: run.Agent || 'Unnamed Agent',
|
|
164
|
+
name: run.Agent || 'Unnamed Agent',
|
|
181
165
|
status: run.Status.toLowerCase(),
|
|
182
166
|
startTime: new Date(run.StartedAt),
|
|
183
|
-
duration
|
|
167
|
+
duration,
|
|
184
168
|
cost: run.TotalCost || 0,
|
|
185
169
|
tokens: run.TotalTokensUsed || 0,
|
|
186
170
|
progress: isRunning ? Math.min(90, (duration / 60000) * 100) : 100
|
|
@@ -188,27 +172,16 @@ export class AIInstrumentationService {
|
|
|
188
172
|
}
|
|
189
173
|
return liveExecutions.sort((a, b) => b.startTime.getTime() - a.startTime.getTime());
|
|
190
174
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const dateFilter = `RunAt >= '${start.toISOString()}' AND RunAt <= '${end.toISOString()}'`;
|
|
194
|
-
const promptRv = new RunView();
|
|
195
|
-
const promptResults = await promptRv.RunView({
|
|
196
|
-
EntityName: 'MJ: AI Prompt Runs',
|
|
197
|
-
ExtraFilter: dateFilter
|
|
198
|
-
});
|
|
199
|
-
const promptRuns = promptResults.Results;
|
|
200
|
-
const executionTrends = await this.loadTrends();
|
|
201
|
-
const costByModel = await this.analyzeCostByModel(promptRuns);
|
|
202
|
-
const performanceMatrix = await this.analyzePerformanceMatrix(promptRuns);
|
|
203
|
-
const tokenEfficiency = await this.analyzeTokenEfficiency(promptRuns);
|
|
175
|
+
// ─── Chart Data Computation ───────────────────────────────────────
|
|
176
|
+
computeChartData(promptRuns, executionTrends) {
|
|
204
177
|
return {
|
|
205
178
|
executionTrends,
|
|
206
|
-
costByModel,
|
|
207
|
-
performanceMatrix,
|
|
208
|
-
tokenEfficiency
|
|
179
|
+
costByModel: this.analyzeCostByModel(promptRuns),
|
|
180
|
+
performanceMatrix: this.analyzePerformanceMatrix(promptRuns),
|
|
181
|
+
tokenEfficiency: this.analyzeTokenEfficiency(promptRuns)
|
|
209
182
|
};
|
|
210
183
|
}
|
|
211
|
-
// Helper
|
|
184
|
+
// ─── Helper Methods ───────────────────────────────────────────────
|
|
212
185
|
countActiveExecutions(promptRuns, agentRuns) {
|
|
213
186
|
const activePrompts = promptRuns.filter(r => !r.CompletedAt && r.Success !== false).length;
|
|
214
187
|
const activeAgents = agentRuns.filter(r => r.Status === 'Running').length;
|
|
@@ -254,25 +227,28 @@ export class AIInstrumentationService {
|
|
|
254
227
|
const todayAgents = agentRuns.filter(r => new Date(r.StartedAt) >= dayStart);
|
|
255
228
|
return this.sumCosts(todayPrompts, todayAgents);
|
|
256
229
|
}
|
|
230
|
+
getBucketSizeMs(start, end) {
|
|
231
|
+
const hours = (end.getTime() - start.getTime()) / (1000 * 60 * 60);
|
|
232
|
+
if (hours <= 24)
|
|
233
|
+
return 60 * 60 * 1000; // 1 hour
|
|
234
|
+
if (hours <= 24 * 7)
|
|
235
|
+
return 4 * 60 * 60 * 1000; // 4 hours
|
|
236
|
+
return 24 * 60 * 60 * 1000; // 24 hours
|
|
237
|
+
}
|
|
257
238
|
createHourlyBuckets(start, end) {
|
|
258
239
|
const buckets = [];
|
|
259
240
|
const current = new Date(start);
|
|
260
|
-
const
|
|
261
|
-
const hours = duration / (1000 * 60 * 60);
|
|
262
|
-
// Determine bucket size based on duration
|
|
241
|
+
const hours = (end.getTime() - start.getTime()) / (1000 * 60 * 60);
|
|
263
242
|
let bucketSize;
|
|
264
243
|
if (hours <= 24) {
|
|
265
|
-
// For up to 24 hours, use hourly buckets
|
|
266
244
|
bucketSize = 1;
|
|
267
245
|
current.setMinutes(0, 0, 0);
|
|
268
246
|
}
|
|
269
247
|
else if (hours <= 24 * 7) {
|
|
270
|
-
// For up to 7 days, use 4-hour buckets
|
|
271
248
|
bucketSize = 4;
|
|
272
249
|
current.setHours(Math.floor(current.getHours() / 4) * 4, 0, 0, 0);
|
|
273
250
|
}
|
|
274
251
|
else {
|
|
275
|
-
// For more than 7 days, use daily buckets
|
|
276
252
|
bucketSize = 24;
|
|
277
253
|
current.setHours(0, 0, 0, 0);
|
|
278
254
|
}
|
|
@@ -282,14 +258,12 @@ export class AIInstrumentationService {
|
|
|
282
258
|
}
|
|
283
259
|
return buckets;
|
|
284
260
|
}
|
|
285
|
-
|
|
261
|
+
getTopModel(promptRuns) {
|
|
286
262
|
const modelCounts = new Map();
|
|
287
263
|
const modelNames = new Map();
|
|
288
|
-
// Count models and track their names from the Model field
|
|
289
264
|
for (const run of promptRuns) {
|
|
290
265
|
if (run.ModelID && run.Model) {
|
|
291
|
-
|
|
292
|
-
modelCounts.set(run.ModelID, count + 1);
|
|
266
|
+
modelCounts.set(run.ModelID, (modelCounts.get(run.ModelID) || 0) + 1);
|
|
293
267
|
modelNames.set(run.ModelID, run.Model);
|
|
294
268
|
}
|
|
295
269
|
}
|
|
@@ -299,14 +273,12 @@ export class AIInstrumentationService {
|
|
|
299
273
|
.sort(([, a], [, b]) => b - a)[0][0];
|
|
300
274
|
return modelNames.get(topModelId) || 'Unknown Model';
|
|
301
275
|
}
|
|
302
|
-
|
|
276
|
+
getTopAgent(agentRuns) {
|
|
303
277
|
const agentCounts = new Map();
|
|
304
278
|
const agentNames = new Map();
|
|
305
|
-
// Count agents and track their names from the Agent field
|
|
306
279
|
for (const run of agentRuns) {
|
|
307
280
|
if (run.AgentID && run.Agent) {
|
|
308
|
-
|
|
309
|
-
agentCounts.set(run.AgentID, count + 1);
|
|
281
|
+
agentCounts.set(run.AgentID, (agentCounts.get(run.AgentID) || 0) + 1);
|
|
310
282
|
agentNames.set(run.AgentID, run.Agent);
|
|
311
283
|
}
|
|
312
284
|
}
|
|
@@ -316,7 +288,7 @@ export class AIInstrumentationService {
|
|
|
316
288
|
.sort(([, a], [, b]) => b - a)[0][0];
|
|
317
289
|
return agentNames.get(topAgentId) || 'Unknown Agent';
|
|
318
290
|
}
|
|
319
|
-
|
|
291
|
+
analyzeCostByModel(promptRuns) {
|
|
320
292
|
const modelStats = new Map();
|
|
321
293
|
for (const run of promptRuns) {
|
|
322
294
|
if (run.ModelID && run.Model) {
|
|
@@ -326,25 +298,17 @@ export class AIInstrumentationService {
|
|
|
326
298
|
modelStats.set(run.ModelID, existing);
|
|
327
299
|
}
|
|
328
300
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
model: stats.name,
|
|
333
|
-
cost: stats.cost,
|
|
334
|
-
tokens: stats.tokens
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
return results.sort((a, b) => b.cost - a.cost);
|
|
301
|
+
return Array.from(modelStats.values())
|
|
302
|
+
.map(stats => ({ model: stats.name, cost: stats.cost, tokens: stats.tokens }))
|
|
303
|
+
.sort((a, b) => b.cost - a.cost);
|
|
338
304
|
}
|
|
339
|
-
|
|
305
|
+
analyzePerformanceMatrix(promptRuns) {
|
|
340
306
|
const combinations = new Map();
|
|
341
307
|
for (const run of promptRuns) {
|
|
342
308
|
if (run.AgentID && run.ModelID && run.ExecutionTimeMS) {
|
|
343
309
|
const key = `${run.AgentID}:${run.ModelID}`;
|
|
344
310
|
const existing = combinations.get(key) || {
|
|
345
|
-
times: [],
|
|
346
|
-
successes: 0,
|
|
347
|
-
total: 0,
|
|
311
|
+
times: [], successes: 0, total: 0,
|
|
348
312
|
agentName: run.Agent || 'Unknown Agent',
|
|
349
313
|
modelName: run.Model || 'Unknown Model'
|
|
350
314
|
};
|
|
@@ -355,18 +319,14 @@ export class AIInstrumentationService {
|
|
|
355
319
|
combinations.set(key, existing);
|
|
356
320
|
}
|
|
357
321
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
successRate: data.successes / data.total
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
return results;
|
|
322
|
+
return Array.from(combinations.values()).map(data => ({
|
|
323
|
+
agent: data.agentName,
|
|
324
|
+
model: data.modelName,
|
|
325
|
+
avgTime: data.times.reduce((sum, time) => sum + time, 0) / data.times.length,
|
|
326
|
+
successRate: data.successes / data.total
|
|
327
|
+
}));
|
|
368
328
|
}
|
|
369
|
-
|
|
329
|
+
analyzeTokenEfficiency(promptRuns) {
|
|
370
330
|
const modelEfficiency = new Map();
|
|
371
331
|
for (const run of promptRuns) {
|
|
372
332
|
if (run.ModelID && run.Model && run.TokensPrompt && run.TokensCompletion) {
|
|
@@ -377,17 +337,14 @@ export class AIInstrumentationService {
|
|
|
377
337
|
modelEfficiency.set(run.ModelID, existing);
|
|
378
338
|
}
|
|
379
339
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
model: data.name
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
return results;
|
|
340
|
+
return Array.from(modelEfficiency.values()).map(data => ({
|
|
341
|
+
inputTokens: data.input,
|
|
342
|
+
outputTokens: data.output,
|
|
343
|
+
cost: data.cost,
|
|
344
|
+
model: data.name
|
|
345
|
+
}));
|
|
390
346
|
}
|
|
347
|
+
// ─── Execution Details (on-demand, not part of initial load) ──────
|
|
391
348
|
async getExecutionDetails(executionId, type) {
|
|
392
349
|
try {
|
|
393
350
|
if (type === 'prompt') {
|
|
@@ -404,17 +361,23 @@ export class AIInstrumentationService {
|
|
|
404
361
|
}
|
|
405
362
|
async getPromptExecutionDetails(promptRunId) {
|
|
406
363
|
const rv = new RunView();
|
|
407
|
-
const result = await rv.
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
364
|
+
const [result, childrenResult] = await rv.RunViews([
|
|
365
|
+
{
|
|
366
|
+
EntityName: 'MJ: AI Prompt Runs',
|
|
367
|
+
ExtraFilter: `ID = '${promptRunId}'`,
|
|
368
|
+
Fields: PROMPT_RUN_FIELDS,
|
|
369
|
+
ResultType: 'simple'
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
EntityName: 'MJ: AI Prompt Runs',
|
|
373
|
+
ExtraFilter: `ParentID = '${promptRunId}'`,
|
|
374
|
+
Fields: PROMPT_RUN_FIELDS,
|
|
375
|
+
ResultType: 'simple'
|
|
376
|
+
}
|
|
377
|
+
]);
|
|
411
378
|
const run = result.Results[0];
|
|
412
379
|
if (!run)
|
|
413
380
|
throw new Error('Prompt run not found');
|
|
414
|
-
const childrenResult = await rv.RunView({
|
|
415
|
-
EntityName: 'MJ: AI Prompt Runs',
|
|
416
|
-
ExtraFilter: `ParentID = '${promptRunId}'`
|
|
417
|
-
});
|
|
418
381
|
const children = await Promise.all(childrenResult.Results.map(child => this.getPromptExecutionDetails(child.ID)));
|
|
419
382
|
return {
|
|
420
383
|
id: run.ID,
|
|
@@ -427,24 +390,29 @@ export class AIInstrumentationService {
|
|
|
427
390
|
tokens: run.TokensUsed || 0,
|
|
428
391
|
success: run.Success || false,
|
|
429
392
|
errorMessage: run.ErrorMessage || undefined,
|
|
430
|
-
parentId: run.ParentID || undefined,
|
|
431
393
|
children,
|
|
432
394
|
model: run.Model || undefined
|
|
433
395
|
};
|
|
434
396
|
}
|
|
435
397
|
async getAgentExecutionDetails(agentRunId) {
|
|
436
398
|
const rv = new RunView();
|
|
437
|
-
const result = await rv.
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
399
|
+
const [result, childrenResult] = await rv.RunViews([
|
|
400
|
+
{
|
|
401
|
+
EntityName: 'MJ: AI Agent Runs',
|
|
402
|
+
ExtraFilter: `ID = '${agentRunId}'`,
|
|
403
|
+
Fields: AGENT_RUN_FIELDS,
|
|
404
|
+
ResultType: 'simple'
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
EntityName: 'MJ: AI Agent Runs',
|
|
408
|
+
ExtraFilter: `ParentRunID = '${agentRunId}'`,
|
|
409
|
+
Fields: AGENT_RUN_FIELDS,
|
|
410
|
+
ResultType: 'simple'
|
|
411
|
+
}
|
|
412
|
+
]);
|
|
441
413
|
const run = result.Results[0];
|
|
442
414
|
if (!run)
|
|
443
415
|
throw new Error('Agent run not found');
|
|
444
|
-
const childrenResult = await rv.RunView({
|
|
445
|
-
EntityName: 'MJ: AI Agent Runs',
|
|
446
|
-
ExtraFilter: `ParentRunID = '${agentRunId}'`
|
|
447
|
-
});
|
|
448
416
|
const children = await Promise.all(childrenResult.Results.map(child => this.getAgentExecutionDetails(child.ID)));
|
|
449
417
|
return {
|
|
450
418
|
id: run.ID,
|
|
@@ -457,7 +425,7 @@ export class AIInstrumentationService {
|
|
|
457
425
|
tokens: run.TotalTokensUsed || 0,
|
|
458
426
|
success: run.Success || false,
|
|
459
427
|
errorMessage: run.ErrorMessage || undefined,
|
|
460
|
-
parentId:
|
|
428
|
+
parentId: undefined,
|
|
461
429
|
children
|
|
462
430
|
};
|
|
463
431
|
}
|