@proofhound/web-ui 0.1.6
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/LICENSE +190 -0
- package/dist/components/annotations/annotation-claim-dialog.d.ts +13 -0
- package/dist/components/annotations/annotation-claim-dialog.d.ts.map +1 -0
- package/dist/components/annotations/annotation-claim-dialog.js +60 -0
- package/dist/components/annotations/annotation-claim-dialog.js.map +1 -0
- package/dist/components/charts/source-legend.d.ts +10 -0
- package/dist/components/charts/source-legend.d.ts.map +1 -0
- package/dist/components/charts/source-legend.js +15 -0
- package/dist/components/charts/source-legend.js.map +1 -0
- package/dist/components/charts/source-stacked-bar.d.ts +22 -0
- package/dist/components/charts/source-stacked-bar.d.ts.map +1 -0
- package/dist/components/charts/source-stacked-bar.js +43 -0
- package/dist/components/charts/source-stacked-bar.js.map +1 -0
- package/dist/components/index.d.ts +15 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +17 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/json-object-textarea.d.ts +11 -0
- package/dist/components/json-object-textarea.d.ts.map +1 -0
- package/dist/components/json-object-textarea.js +82 -0
- package/dist/components/json-object-textarea.js.map +1 -0
- package/dist/components/model-context-window-input.d.ts +15 -0
- package/dist/components/model-context-window-input.d.ts.map +1 -0
- package/dist/components/model-context-window-input.js +57 -0
- package/dist/components/model-context-window-input.js.map +1 -0
- package/dist/components/model-probe-status.d.ts +11 -0
- package/dist/components/model-probe-status.d.ts.map +1 -0
- package/dist/components/model-probe-status.js +34 -0
- package/dist/components/model-probe-status.js.map +1 -0
- package/dist/components/prompt-diff/prompt-diff-split-view.d.ts +28 -0
- package/dist/components/prompt-diff/prompt-diff-split-view.d.ts.map +1 -0
- package/dist/components/prompt-diff/prompt-diff-split-view.js +101 -0
- package/dist/components/prompt-diff/prompt-diff-split-view.js.map +1 -0
- package/dist/components/prompt-language-select.d.ts +13 -0
- package/dist/components/prompt-language-select.d.ts.map +1 -0
- package/dist/components/prompt-language-select.js +14 -0
- package/dist/components/prompt-language-select.js.map +1 -0
- package/dist/components/prompt-version-picker-row.d.ts +27 -0
- package/dist/components/prompt-version-picker-row.d.ts.map +1 -0
- package/dist/components/prompt-version-picker-row.js +50 -0
- package/dist/components/prompt-version-picker-row.js.map +1 -0
- package/dist/components/prompt-version-status-badge.d.ts +8 -0
- package/dist/components/prompt-version-status-badge.d.ts.map +1 -0
- package/dist/components/prompt-version-status-badge.js +31 -0
- package/dist/components/prompt-version-status-badge.js.map +1 -0
- package/dist/components/quick-fill/quick-fill-picker.d.ts +42 -0
- package/dist/components/quick-fill/quick-fill-picker.d.ts.map +1 -0
- package/dist/components/quick-fill/quick-fill-picker.js +46 -0
- package/dist/components/quick-fill/quick-fill-picker.js.map +1 -0
- package/dist/components/time-zone-preference-menu.d.ts +10 -0
- package/dist/components/time-zone-preference-menu.d.ts.map +1 -0
- package/dist/components/time-zone-preference-menu.js +33 -0
- package/dist/components/time-zone-preference-menu.js.map +1 -0
- package/dist/contracts/index.d.ts +13 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +7 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/features/index.d.ts +3 -0
- package/dist/features/index.d.ts.map +1 -0
- package/dist/features/index.js +4 -0
- package/dist/features/index.js.map +1 -0
- package/dist/features/model-quick-fill/model-preset-draft.d.ts +19 -0
- package/dist/features/model-quick-fill/model-preset-draft.d.ts.map +1 -0
- package/dist/features/model-quick-fill/model-preset-draft.js +22 -0
- package/dist/features/model-quick-fill/model-preset-draft.js.map +1 -0
- package/dist/features/model-quick-fill/model-preset-quick-fill.d.ts +7 -0
- package/dist/features/model-quick-fill/model-preset-quick-fill.d.ts.map +1 -0
- package/dist/features/model-quick-fill/model-preset-quick-fill.js +73 -0
- package/dist/features/model-quick-fill/model-preset-quick-fill.js.map +1 -0
- package/dist/hooks/annotation.d.ts +253 -0
- package/dist/hooks/annotation.d.ts.map +1 -0
- package/dist/hooks/annotation.js +79 -0
- package/dist/hooks/annotation.js.map +1 -0
- package/dist/hooks/canary-release.d.ts +674 -0
- package/dist/hooks/canary-release.d.ts.map +1 -0
- package/dist/hooks/canary-release.js +142 -0
- package/dist/hooks/canary-release.js.map +1 -0
- package/dist/hooks/connector.d.ts +585 -0
- package/dist/hooks/connector.d.ts.map +1 -0
- package/dist/hooks/connector.js +157 -0
- package/dist/hooks/connector.js.map +1 -0
- package/dist/hooks/dataset.d.ts +138 -0
- package/dist/hooks/dataset.d.ts.map +1 -0
- package/dist/hooks/dataset.js +84 -0
- package/dist/hooks/dataset.js.map +1 -0
- package/dist/hooks/experiment.d.ts +376 -0
- package/dist/hooks/experiment.d.ts.map +1 -0
- package/dist/hooks/experiment.js +58 -0
- package/dist/hooks/experiment.js.map +1 -0
- package/dist/hooks/index.d.ts +18 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +18 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/model.d.ts +327 -0
- package/dist/hooks/model.d.ts.map +1 -0
- package/dist/hooks/model.js +103 -0
- package/dist/hooks/model.js.map +1 -0
- package/dist/hooks/optimization.d.ts +557 -0
- package/dist/hooks/optimization.d.ts.map +1 -0
- package/dist/hooks/optimization.js +94 -0
- package/dist/hooks/optimization.js.map +1 -0
- package/dist/hooks/production-release.d.ts +141 -0
- package/dist/hooks/production-release.d.ts.map +1 -0
- package/dist/hooks/production-release.js +51 -0
- package/dist/hooks/production-release.js.map +1 -0
- package/dist/hooks/project-monitoring.d.ts +199 -0
- package/dist/hooks/project-monitoring.d.ts.map +1 -0
- package/dist/hooks/project-monitoring.js +55 -0
- package/dist/hooks/project-monitoring.js.map +1 -0
- package/dist/hooks/prompt.d.ts +509 -0
- package/dist/hooks/prompt.d.ts.map +1 -0
- package/dist/hooks/prompt.js +127 -0
- package/dist/hooks/prompt.js.map +1 -0
- package/dist/hooks/quick-start.d.ts +219 -0
- package/dist/hooks/quick-start.d.ts.map +1 -0
- package/dist/hooks/quick-start.js +35 -0
- package/dist/hooks/quick-start.js.map +1 -0
- package/dist/hooks/release-line.d.ts +819 -0
- package/dist/hooks/release-line.d.ts.map +1 -0
- package/dist/hooks/release-line.js +52 -0
- package/dist/hooks/release-line.js.map +1 -0
- package/dist/hooks/run-result.d.ts +118 -0
- package/dist/hooks/run-result.d.ts.map +1 -0
- package/dist/hooks/run-result.js +56 -0
- package/dist/hooks/run-result.js.map +1 -0
- package/dist/hooks/token.d.ts +58 -0
- package/dist/hooks/token.d.ts.map +1 -0
- package/dist/hooks/token.js +39 -0
- package/dist/hooks/token.js.map +1 -0
- package/dist/hooks/use-auto-refresh.d.ts +30 -0
- package/dist/hooks/use-auto-refresh.d.ts.map +1 -0
- package/dist/hooks/use-auto-refresh.js +175 -0
- package/dist/hooks/use-auto-refresh.js.map +1 -0
- package/dist/hooks/use-date-time-formatter.d.ts +11 -0
- package/dist/hooks/use-date-time-formatter.d.ts.map +1 -0
- package/dist/hooks/use-date-time-formatter.js +24 -0
- package/dist/hooks/use-date-time-formatter.js.map +1 -0
- package/dist/hooks/use-delayed-loading.d.ts +25 -0
- package/dist/hooks/use-delayed-loading.d.ts.map +1 -0
- package/dist/hooks/use-delayed-loading.js +95 -0
- package/dist/hooks/use-delayed-loading.js.map +1 -0
- package/dist/i18n/index.d.ts +5678 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +5712 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/i18n/language.d.ts +17 -0
- package/dist/i18n/language.d.ts.map +1 -0
- package/dist/i18n/language.js +43 -0
- package/dist/i18n/language.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api-error.d.ts +2 -0
- package/dist/lib/api-error.d.ts.map +1 -0
- package/dist/lib/api-error.js +38 -0
- package/dist/lib/api-error.js.map +1 -0
- package/dist/lib/format.d.ts +30 -0
- package/dist/lib/format.d.ts.map +1 -0
- package/dist/lib/format.js +157 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/index.d.ts +8 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +8 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/model-number.d.ts +2 -0
- package/dist/lib/model-number.d.ts.map +1 -0
- package/dist/lib/model-number.js +18 -0
- package/dist/lib/model-number.js.map +1 -0
- package/dist/lib/model-provider-type.d.ts +7 -0
- package/dist/lib/model-provider-type.d.ts.map +1 -0
- package/dist/lib/model-provider-type.js +28 -0
- package/dist/lib/model-provider-type.js.map +1 -0
- package/dist/lib/project-name.d.ts +7 -0
- package/dist/lib/project-name.d.ts.map +1 -0
- package/dist/lib/project-name.js +14 -0
- package/dist/lib/project-name.js.map +1 -0
- package/dist/lib/releases/release-line-model.d.ts +55 -0
- package/dist/lib/releases/release-line-model.d.ts.map +1 -0
- package/dist/lib/releases/release-line-model.js +476 -0
- package/dist/lib/releases/release-line-model.js.map +1 -0
- package/dist/lib/time-zone.d.ts +14 -0
- package/dist/lib/time-zone.d.ts.map +1 -0
- package/dist/lib/time-zone.js +118 -0
- package/dist/lib/time-zone.js.map +1 -0
- package/dist/lib/uuid.d.ts +2 -0
- package/dist/lib/uuid.d.ts.map +1 -0
- package/dist/lib/uuid.js +5 -0
- package/dist/lib/uuid.js.map +1 -0
- package/dist/providers/display-preferences-provider.d.ts +18 -0
- package/dist/providers/display-preferences-provider.d.ts.map +1 -0
- package/dist/providers/display-preferences-provider.js +46 -0
- package/dist/providers/display-preferences-provider.js.map +1 -0
- package/dist/providers/index.d.ts +5 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +5 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/project-context-provider.d.ts +8 -0
- package/dist/providers/project-context-provider.d.ts.map +1 -0
- package/dist/providers/project-context-provider.js +15 -0
- package/dist/providers/project-context-provider.js.map +1 -0
- package/dist/providers/proofhound-web-provider.d.ts +9 -0
- package/dist/providers/proofhound-web-provider.d.ts.map +1 -0
- package/dist/providers/proofhound-web-provider.js +44 -0
- package/dist/providers/proofhound-web-provider.js.map +1 -0
- package/dist/providers/refine-provider.d.ts +5 -0
- package/dist/providers/refine-provider.d.ts.map +1 -0
- package/dist/providers/refine-provider.js +23 -0
- package/dist/providers/refine-provider.js.map +1 -0
- package/dist/screens/annotations/annotation-detail-page.d.ts +5 -0
- package/dist/screens/annotations/annotation-detail-page.d.ts.map +1 -0
- package/dist/screens/annotations/annotation-detail-page.js +379 -0
- package/dist/screens/annotations/annotation-detail-page.js.map +1 -0
- package/dist/screens/annotations/annotation-new-page.d.ts +4 -0
- package/dist/screens/annotations/annotation-new-page.d.ts.map +1 -0
- package/dist/screens/annotations/annotation-new-page.js +125 -0
- package/dist/screens/annotations/annotation-new-page.js.map +1 -0
- package/dist/screens/annotations/annotation-task-model.d.ts +39 -0
- package/dist/screens/annotations/annotation-task-model.d.ts.map +1 -0
- package/dist/screens/annotations/annotation-task-model.js +88 -0
- package/dist/screens/annotations/annotation-task-model.js.map +1 -0
- package/dist/screens/annotations/annotation-ui.d.ts +33 -0
- package/dist/screens/annotations/annotation-ui.d.ts.map +1 -0
- package/dist/screens/annotations/annotation-ui.js +92 -0
- package/dist/screens/annotations/annotation-ui.js.map +1 -0
- package/dist/screens/annotations/annotations-list-page.d.ts +4 -0
- package/dist/screens/annotations/annotations-list-page.d.ts.map +1 -0
- package/dist/screens/annotations/annotations-list-page.js +82 -0
- package/dist/screens/annotations/annotations-list-page.js.map +1 -0
- package/dist/screens/connectors/connector-detail-page.d.ts +5 -0
- package/dist/screens/connectors/connector-detail-page.d.ts.map +1 -0
- package/dist/screens/connectors/connector-detail-page.js +838 -0
- package/dist/screens/connectors/connector-detail-page.js.map +1 -0
- package/dist/screens/connectors/connector-form-page.d.ts +8 -0
- package/dist/screens/connectors/connector-form-page.d.ts.map +1 -0
- package/dist/screens/connectors/connector-form-page.js +328 -0
- package/dist/screens/connectors/connector-form-page.js.map +1 -0
- package/dist/screens/connectors/connector-peek-dialog.d.ts +8 -0
- package/dist/screens/connectors/connector-peek-dialog.d.ts.map +1 -0
- package/dist/screens/connectors/connector-peek-dialog.js +24 -0
- package/dist/screens/connectors/connector-peek-dialog.js.map +1 -0
- package/dist/screens/connectors/connector-types.d.ts +36 -0
- package/dist/screens/connectors/connector-types.d.ts.map +1 -0
- package/dist/screens/connectors/connector-types.js +48 -0
- package/dist/screens/connectors/connector-types.js.map +1 -0
- package/dist/screens/connectors/connector-ui.d.ts +14 -0
- package/dist/screens/connectors/connector-ui.d.ts.map +1 -0
- package/dist/screens/connectors/connector-ui.js +40 -0
- package/dist/screens/connectors/connector-ui.js.map +1 -0
- package/dist/screens/connectors/connectors-list-page.d.ts +4 -0
- package/dist/screens/connectors/connectors-list-page.d.ts.map +1 -0
- package/dist/screens/connectors/connectors-list-page.js +220 -0
- package/dist/screens/connectors/connectors-list-page.js.map +1 -0
- package/dist/screens/dashboard/dashboard-screen.d.ts +5 -0
- package/dist/screens/dashboard/dashboard-screen.d.ts.map +1 -0
- package/dist/screens/dashboard/dashboard-screen.js +524 -0
- package/dist/screens/dashboard/dashboard-screen.js.map +1 -0
- package/dist/screens/datasets/dataset-detail-helpers.d.ts +10 -0
- package/dist/screens/datasets/dataset-detail-helpers.d.ts.map +1 -0
- package/dist/screens/datasets/dataset-detail-helpers.js +84 -0
- package/dist/screens/datasets/dataset-detail-helpers.js.map +1 -0
- package/dist/screens/datasets/dataset-detail-page.d.ts +6 -0
- package/dist/screens/datasets/dataset-detail-page.d.ts.map +1 -0
- package/dist/screens/datasets/dataset-detail-page.js +379 -0
- package/dist/screens/datasets/dataset-detail-page.js.map +1 -0
- package/dist/screens/datasets/dataset-import-runner.d.ts +17 -0
- package/dist/screens/datasets/dataset-import-runner.d.ts.map +1 -0
- package/dist/screens/datasets/dataset-import-runner.js +33 -0
- package/dist/screens/datasets/dataset-import-runner.js.map +1 -0
- package/dist/screens/datasets/dataset-mappers.d.ts +5 -0
- package/dist/screens/datasets/dataset-mappers.d.ts.map +1 -0
- package/dist/screens/datasets/dataset-mappers.js +79 -0
- package/dist/screens/datasets/dataset-mappers.js.map +1 -0
- package/dist/screens/datasets/dataset-samples-table.d.ts +21 -0
- package/dist/screens/datasets/dataset-samples-table.d.ts.map +1 -0
- package/dist/screens/datasets/dataset-samples-table.js +59 -0
- package/dist/screens/datasets/dataset-samples-table.js.map +1 -0
- package/dist/screens/datasets/dataset-transfer-progress.d.ts +30 -0
- package/dist/screens/datasets/dataset-transfer-progress.d.ts.map +1 -0
- package/dist/screens/datasets/dataset-transfer-progress.js +157 -0
- package/dist/screens/datasets/dataset-transfer-progress.js.map +1 -0
- package/dist/screens/datasets/dataset-types.d.ts +59 -0
- package/dist/screens/datasets/dataset-types.d.ts.map +1 -0
- package/dist/screens/datasets/dataset-types.js +15 -0
- package/dist/screens/datasets/dataset-types.js.map +1 -0
- package/dist/screens/datasets/dataset-ui.d.ts +49 -0
- package/dist/screens/datasets/dataset-ui.d.ts.map +1 -0
- package/dist/screens/datasets/dataset-ui.js +163 -0
- package/dist/screens/datasets/dataset-ui.js.map +1 -0
- package/dist/screens/datasets/dataset-upload-page.d.ts +4 -0
- package/dist/screens/datasets/dataset-upload-page.d.ts.map +1 -0
- package/dist/screens/datasets/dataset-upload-page.js +425 -0
- package/dist/screens/datasets/dataset-upload-page.js.map +1 -0
- package/dist/screens/datasets/dataset-upload-parser.d.ts +21 -0
- package/dist/screens/datasets/dataset-upload-parser.d.ts.map +1 -0
- package/dist/screens/datasets/dataset-upload-parser.js +536 -0
- package/dist/screens/datasets/dataset-upload-parser.js.map +1 -0
- package/dist/screens/datasets/datasets-list-page.d.ts +4 -0
- package/dist/screens/datasets/datasets-list-page.d.ts.map +1 -0
- package/dist/screens/datasets/datasets-list-page.js +249 -0
- package/dist/screens/datasets/datasets-list-page.js.map +1 -0
- package/dist/screens/experiments/experiment-detail-page.d.ts +5 -0
- package/dist/screens/experiments/experiment-detail-page.d.ts.map +1 -0
- package/dist/screens/experiments/experiment-detail-page.js +460 -0
- package/dist/screens/experiments/experiment-detail-page.js.map +1 -0
- package/dist/screens/experiments/experiment-new-page.d.ts +21 -0
- package/dist/screens/experiments/experiment-new-page.d.ts.map +1 -0
- package/dist/screens/experiments/experiment-new-page.js +427 -0
- package/dist/screens/experiments/experiment-new-page.js.map +1 -0
- package/dist/screens/experiments/experiment-option-adapter.d.ts +68 -0
- package/dist/screens/experiments/experiment-option-adapter.d.ts.map +1 -0
- package/dist/screens/experiments/experiment-option-adapter.js +225 -0
- package/dist/screens/experiments/experiment-option-adapter.js.map +1 -0
- package/dist/screens/experiments/experiment-progress.d.ts +5 -0
- package/dist/screens/experiments/experiment-progress.d.ts.map +1 -0
- package/dist/screens/experiments/experiment-progress.js +15 -0
- package/dist/screens/experiments/experiment-progress.js.map +1 -0
- package/dist/screens/experiments/experiment-repeat-href.d.ts +17 -0
- package/dist/screens/experiments/experiment-repeat-href.d.ts.map +1 -0
- package/dist/screens/experiments/experiment-repeat-href.js +32 -0
- package/dist/screens/experiments/experiment-repeat-href.js.map +1 -0
- package/dist/screens/experiments/experiment-theme.d.ts +43 -0
- package/dist/screens/experiments/experiment-theme.d.ts.map +1 -0
- package/dist/screens/experiments/experiment-theme.js +43 -0
- package/dist/screens/experiments/experiment-theme.js.map +1 -0
- package/dist/screens/experiments/experiment-ui.d.ts +36 -0
- package/dist/screens/experiments/experiment-ui.d.ts.map +1 -0
- package/dist/screens/experiments/experiment-ui.js +46 -0
- package/dist/screens/experiments/experiment-ui.js.map +1 -0
- package/dist/screens/experiments/experiment-view-model.d.ts +118 -0
- package/dist/screens/experiments/experiment-view-model.d.ts.map +1 -0
- package/dist/screens/experiments/experiment-view-model.js +114 -0
- package/dist/screens/experiments/experiment-view-model.js.map +1 -0
- package/dist/screens/experiments/experiments-comparison-view.d.ts +10 -0
- package/dist/screens/experiments/experiments-comparison-view.d.ts.map +1 -0
- package/dist/screens/experiments/experiments-comparison-view.js +215 -0
- package/dist/screens/experiments/experiments-comparison-view.js.map +1 -0
- package/dist/screens/experiments/experiments-list-page.d.ts +4 -0
- package/dist/screens/experiments/experiments-list-page.d.ts.map +1 -0
- package/dist/screens/experiments/experiments-list-page.js +364 -0
- package/dist/screens/experiments/experiments-list-page.js.map +1 -0
- package/dist/screens/experiments/experiments-table.d.ts +18 -0
- package/dist/screens/experiments/experiments-table.d.ts.map +1 -0
- package/dist/screens/experiments/experiments-table.js +97 -0
- package/dist/screens/experiments/experiments-table.js.map +1 -0
- package/dist/screens/experiments/run-result-detail-sheet.d.ts +9 -0
- package/dist/screens/experiments/run-result-detail-sheet.d.ts.map +1 -0
- package/dist/screens/experiments/run-result-detail-sheet.js +89 -0
- package/dist/screens/experiments/run-result-detail-sheet.js.map +1 -0
- package/dist/screens/experiments/run-result-display.d.ts +28 -0
- package/dist/screens/experiments/run-result-display.d.ts.map +1 -0
- package/dist/screens/experiments/run-result-display.js +124 -0
- package/dist/screens/experiments/run-result-display.js.map +1 -0
- package/dist/screens/experiments/run-result-labels.d.ts +16 -0
- package/dist/screens/experiments/run-result-labels.d.ts.map +1 -0
- package/dist/screens/experiments/run-result-labels.js +52 -0
- package/dist/screens/experiments/run-result-labels.js.map +1 -0
- package/dist/screens/index.d.ts +29 -0
- package/dist/screens/index.d.ts.map +1 -0
- package/dist/screens/index.js +43 -0
- package/dist/screens/index.js.map +1 -0
- package/dist/screens/models/model-form-page.d.ts +9 -0
- package/dist/screens/models/model-form-page.d.ts.map +1 -0
- package/dist/screens/models/model-form-page.js +876 -0
- package/dist/screens/models/model-form-page.js.map +1 -0
- package/dist/screens/models/model-view-model.d.ts +66 -0
- package/dist/screens/models/model-view-model.d.ts.map +1 -0
- package/dist/screens/models/model-view-model.js +36 -0
- package/dist/screens/models/model-view-model.js.map +1 -0
- package/dist/screens/models/models-list-page.d.ts +4 -0
- package/dist/screens/models/models-list-page.d.ts.map +1 -0
- package/dist/screens/models/models-list-page.js +352 -0
- package/dist/screens/models/models-list-page.js.map +1 -0
- package/dist/screens/models/project-model-adapter.d.ts +5 -0
- package/dist/screens/models/project-model-adapter.d.ts.map +1 -0
- package/dist/screens/models/project-model-adapter.js +63 -0
- package/dist/screens/models/project-model-adapter.js.map +1 -0
- package/dist/screens/monitoring/big-chart-card.d.ts +36 -0
- package/dist/screens/monitoring/big-chart-card.d.ts.map +1 -0
- package/dist/screens/monitoring/big-chart-card.js +32 -0
- package/dist/screens/monitoring/big-chart-card.js.map +1 -0
- package/dist/screens/monitoring/monitoring-filter-strip.d.ts +14 -0
- package/dist/screens/monitoring/monitoring-filter-strip.d.ts.map +1 -0
- package/dist/screens/monitoring/monitoring-filter-strip.js +36 -0
- package/dist/screens/monitoring/monitoring-filter-strip.js.map +1 -0
- package/dist/screens/monitoring/project-monitoring-page.d.ts +9 -0
- package/dist/screens/monitoring/project-monitoring-page.d.ts.map +1 -0
- package/dist/screens/monitoring/project-monitoring-page.js +240 -0
- package/dist/screens/monitoring/project-monitoring-page.js.map +1 -0
- package/dist/screens/monitoring/ranking-cards.d.ts +23 -0
- package/dist/screens/monitoring/ranking-cards.d.ts.map +1 -0
- package/dist/screens/monitoring/ranking-cards.js +78 -0
- package/dist/screens/monitoring/ranking-cards.js.map +1 -0
- package/dist/screens/optimizations/optimization-detail-page.d.ts +5 -0
- package/dist/screens/optimizations/optimization-detail-page.d.ts.map +1 -0
- package/dist/screens/optimizations/optimization-detail-page.js +934 -0
- package/dist/screens/optimizations/optimization-detail-page.js.map +1 -0
- package/dist/screens/optimizations/optimization-mappers.d.ts +56 -0
- package/dist/screens/optimizations/optimization-mappers.d.ts.map +1 -0
- package/dist/screens/optimizations/optimization-mappers.js +142 -0
- package/dist/screens/optimizations/optimization-mappers.js.map +1 -0
- package/dist/screens/optimizations/optimization-new-page.d.ts +8 -0
- package/dist/screens/optimizations/optimization-new-page.d.ts.map +1 -0
- package/dist/screens/optimizations/optimization-new-page.js +732 -0
- package/dist/screens/optimizations/optimization-new-page.js.map +1 -0
- package/dist/screens/optimizations/optimization-theme.d.ts +43 -0
- package/dist/screens/optimizations/optimization-theme.d.ts.map +1 -0
- package/dist/screens/optimizations/optimization-theme.js +46 -0
- package/dist/screens/optimizations/optimization-theme.js.map +1 -0
- package/dist/screens/optimizations/optimization-ui.d.ts +60 -0
- package/dist/screens/optimizations/optimization-ui.d.ts.map +1 -0
- package/dist/screens/optimizations/optimization-ui.js +164 -0
- package/dist/screens/optimizations/optimization-ui.js.map +1 -0
- package/dist/screens/optimizations/optimizations-list-page.d.ts +4 -0
- package/dist/screens/optimizations/optimizations-list-page.d.ts.map +1 -0
- package/dist/screens/optimizations/optimizations-list-page.js +358 -0
- package/dist/screens/optimizations/optimizations-list-page.js.map +1 -0
- package/dist/screens/prompts/prompt-body-editor.d.ts +15 -0
- package/dist/screens/prompts/prompt-body-editor.d.ts.map +1 -0
- package/dist/screens/prompts/prompt-body-editor.js +165 -0
- package/dist/screens/prompts/prompt-body-editor.js.map +1 -0
- package/dist/screens/prompts/prompt-dataset-variables.d.ts +4 -0
- package/dist/screens/prompts/prompt-dataset-variables.d.ts.map +1 -0
- package/dist/screens/prompts/prompt-dataset-variables.js +27 -0
- package/dist/screens/prompts/prompt-dataset-variables.js.map +1 -0
- package/dist/screens/prompts/prompt-detail-page.d.ts +5 -0
- package/dist/screens/prompts/prompt-detail-page.d.ts.map +1 -0
- package/dist/screens/prompts/prompt-detail-page.js +1013 -0
- package/dist/screens/prompts/prompt-detail-page.js.map +1 -0
- package/dist/screens/prompts/prompt-model.d.ts +77 -0
- package/dist/screens/prompts/prompt-model.d.ts.map +1 -0
- package/dist/screens/prompts/prompt-model.js +152 -0
- package/dist/screens/prompts/prompt-model.js.map +1 -0
- package/dist/screens/prompts/prompt-preview-parts.d.ts +12 -0
- package/dist/screens/prompts/prompt-preview-parts.d.ts.map +1 -0
- package/dist/screens/prompts/prompt-preview-parts.js +32 -0
- package/dist/screens/prompts/prompt-preview-parts.js.map +1 -0
- package/dist/screens/prompts/prompt-preview.d.ts +10 -0
- package/dist/screens/prompts/prompt-preview.d.ts.map +1 -0
- package/dist/screens/prompts/prompt-preview.js +16 -0
- package/dist/screens/prompts/prompt-preview.js.map +1 -0
- package/dist/screens/prompts/prompt-ui.d.ts +30 -0
- package/dist/screens/prompts/prompt-ui.d.ts.map +1 -0
- package/dist/screens/prompts/prompt-ui.js +51 -0
- package/dist/screens/prompts/prompt-ui.js.map +1 -0
- package/dist/screens/prompts/prompts-list-page.d.ts +5 -0
- package/dist/screens/prompts/prompts-list-page.d.ts.map +1 -0
- package/dist/screens/prompts/prompts-list-page.js +208 -0
- package/dist/screens/prompts/prompts-list-page.js.map +1 -0
- package/dist/screens/quick-start/quick-start-screen.d.ts +2 -0
- package/dist/screens/quick-start/quick-start-screen.d.ts.map +1 -0
- package/dist/screens/quick-start/quick-start-screen.js +486 -0
- package/dist/screens/quick-start/quick-start-screen.js.map +1 -0
- package/dist/screens/releases/release-line-detail-page.d.ts +5 -0
- package/dist/screens/releases/release-line-detail-page.d.ts.map +1 -0
- package/dist/screens/releases/release-line-detail-page.js +973 -0
- package/dist/screens/releases/release-line-detail-page.js.map +1 -0
- package/dist/screens/releases/release-line-ui.d.ts +30 -0
- package/dist/screens/releases/release-line-ui.d.ts.map +1 -0
- package/dist/screens/releases/release-line-ui.js +197 -0
- package/dist/screens/releases/release-line-ui.js.map +1 -0
- package/dist/screens/releases/release-new-model.d.ts +5 -0
- package/dist/screens/releases/release-new-model.d.ts.map +1 -0
- package/dist/screens/releases/release-new-model.js +18 -0
- package/dist/screens/releases/release-new-model.js.map +1 -0
- package/dist/screens/releases/release-new-page.d.ts +6 -0
- package/dist/screens/releases/release-new-page.d.ts.map +1 -0
- package/dist/screens/releases/release-new-page.js +816 -0
- package/dist/screens/releases/release-new-page.js.map +1 -0
- package/dist/screens/releases/release-topology-canvas.d.ts +13 -0
- package/dist/screens/releases/release-topology-canvas.d.ts.map +1 -0
- package/dist/screens/releases/release-topology-canvas.js +856 -0
- package/dist/screens/releases/release-topology-canvas.js.map +1 -0
- package/dist/screens/releases/releases-list-page.d.ts +4 -0
- package/dist/screens/releases/releases-list-page.d.ts.map +1 -0
- package/dist/screens/releases/releases-list-page.js +86 -0
- package/dist/screens/releases/releases-list-page.js.map +1 -0
- package/dist/screens/settings/settings-page.d.ts +2 -0
- package/dist/screens/settings/settings-page.d.ts.map +1 -0
- package/dist/screens/settings/settings-page.js +250 -0
- package/dist/screens/settings/settings-page.js.map +1 -0
- package/dist/styles/globals.css +961 -0
- package/package.json +84 -0
|
@@ -0,0 +1,876 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import Link from 'next/link';
|
|
4
|
+
import { useRouter } from 'next/navigation';
|
|
5
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
6
|
+
import { MODEL_DEFAULT_CONCURRENCY_LIMIT, MODEL_MAX_CONCURRENCY_LIMIT, MODEL_UNLIMITED_RATE_LIMIT, } from '@proofhound/shared';
|
|
7
|
+
import { AlertTriangle, Cable, Check, Copy, CopyPlus, DollarSign, Eye, EyeOff, Gauge, KeyRound, Link2, Loader2, Lock, Save, Trash2, X, } from 'lucide-react';
|
|
8
|
+
import { Button, Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, DetailPageSkeleton, Progress, formatProgressLabel, cn, } from '@proofhound/ui';
|
|
9
|
+
import { JsonObjectTextarea, ModelContextWindowInput, ModelProbeStatus, ModelPresetQuickFill } from '../../components';
|
|
10
|
+
import { Main } from '@proofhound/ui/layout';
|
|
11
|
+
import { useI18n } from '../../i18n';
|
|
12
|
+
import { getApiErrorMessage, toIntegerInputValue, buildProviderTypeOptions, isProjectNameTaken } from '../../lib';
|
|
13
|
+
import { useCreateProjectModel, useDateTimeFormatter, useDelayedLoading, useProbeProjectModel, useProbeDraftProjectModel, useDeleteProjectModel, useProjectModels, useProjectModel, useProjectModelReferences, useRevealProjectModelApiKey, useUpdateProjectModel, } from '../../hooks';
|
|
14
|
+
import { dtoToProjectModel } from './project-model-adapter';
|
|
15
|
+
import { getProjectModelSource, isProjectModelEditable, } from './model-view-model';
|
|
16
|
+
import { MODEL_SOURCE_LABEL_KEYS, MODEL_STATUS_CLASSES, MODEL_STATUS_LABEL_KEYS } from './model-view-model';
|
|
17
|
+
const EMPTY_MODEL_REFERENCES = {
|
|
18
|
+
experiments: 0,
|
|
19
|
+
canaryReleases: 0,
|
|
20
|
+
optimizations: 0,
|
|
21
|
+
productionReleases: 0,
|
|
22
|
+
total: 0,
|
|
23
|
+
};
|
|
24
|
+
const MODEL_REFERENCE_LABEL_KEYS = {
|
|
25
|
+
experiments: 'models.activeUsage.experiments',
|
|
26
|
+
canaryReleases: 'models.activeUsage.canaryReleases',
|
|
27
|
+
optimizations: 'models.activeUsage.optimizations',
|
|
28
|
+
productionReleases: 'models.activeUsage.productionReleases',
|
|
29
|
+
};
|
|
30
|
+
const PROJECT_MODEL_FALLBACK = {
|
|
31
|
+
id: '',
|
|
32
|
+
name: '',
|
|
33
|
+
provider: '',
|
|
34
|
+
providerModelId: '',
|
|
35
|
+
endpoint: '',
|
|
36
|
+
source: 'local',
|
|
37
|
+
status: 'enabled',
|
|
38
|
+
apiKey: '',
|
|
39
|
+
credentialTail: '',
|
|
40
|
+
contextWindow: '',
|
|
41
|
+
contextWindowInput: '',
|
|
42
|
+
extraBodyInput: '',
|
|
43
|
+
rpm: { limit: '', limitInput: '', usage: 0, current: '' },
|
|
44
|
+
tpm: { limit: '', limitInput: '', usage: 0, current: '' },
|
|
45
|
+
concurrency: { limit: '', limitInput: '', usage: 0, current: '' },
|
|
46
|
+
autoConcurrency: true,
|
|
47
|
+
pricing: { inputPerMillion: '', outputPerMillion: '' },
|
|
48
|
+
imageCapability: 'none',
|
|
49
|
+
references: 0,
|
|
50
|
+
readonly: false,
|
|
51
|
+
lastUpdated: '',
|
|
52
|
+
};
|
|
53
|
+
function projectModelForCopy(source, nameSuffix) {
|
|
54
|
+
return {
|
|
55
|
+
...PROJECT_MODEL_FALLBACK,
|
|
56
|
+
name: `${source.name}${nameSuffix}`,
|
|
57
|
+
provider: source.provider,
|
|
58
|
+
providerModelId: source.providerModelId,
|
|
59
|
+
endpoint: source.endpoint,
|
|
60
|
+
contextWindow: source.contextWindow,
|
|
61
|
+
contextWindowInput: source.contextWindowInput,
|
|
62
|
+
extraBodyInput: source.extraBodyInput,
|
|
63
|
+
rpm: { ...PROJECT_MODEL_FALLBACK.rpm, limit: source.rpm.limit, limitInput: source.rpm.limitInput },
|
|
64
|
+
tpm: { ...PROJECT_MODEL_FALLBACK.tpm, limit: source.tpm.limit, limitInput: source.tpm.limitInput },
|
|
65
|
+
concurrency: {
|
|
66
|
+
...PROJECT_MODEL_FALLBACK.concurrency,
|
|
67
|
+
limit: source.concurrency.limit,
|
|
68
|
+
limitInput: source.concurrency.limitInput,
|
|
69
|
+
},
|
|
70
|
+
pricing: source.pricing,
|
|
71
|
+
imageCapability: source.imageCapability,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function projectModelFromQuickFillDraft(draft) {
|
|
75
|
+
return {
|
|
76
|
+
...PROJECT_MODEL_FALLBACK,
|
|
77
|
+
name: draft.name,
|
|
78
|
+
provider: draft.providerType,
|
|
79
|
+
providerModelId: draft.providerModelId,
|
|
80
|
+
endpoint: draft.endpoint,
|
|
81
|
+
contextWindow: String(draft.contextWindowTokens),
|
|
82
|
+
contextWindowInput: String(draft.contextWindowTokens),
|
|
83
|
+
extraBodyInput: draft.extraBodyInput,
|
|
84
|
+
rpm: {
|
|
85
|
+
...PROJECT_MODEL_FALLBACK.rpm,
|
|
86
|
+
limit: String(draft.rpmLimit),
|
|
87
|
+
limitInput: String(draft.rpmLimit),
|
|
88
|
+
},
|
|
89
|
+
tpm: {
|
|
90
|
+
...PROJECT_MODEL_FALLBACK.tpm,
|
|
91
|
+
limit: String(draft.tpmLimit),
|
|
92
|
+
limitInput: String(draft.tpmLimit),
|
|
93
|
+
},
|
|
94
|
+
concurrency: {
|
|
95
|
+
...PROJECT_MODEL_FALLBACK.concurrency,
|
|
96
|
+
limit: String(draft.concurrencyLimit),
|
|
97
|
+
limitInput: String(draft.concurrencyLimit),
|
|
98
|
+
},
|
|
99
|
+
pricing: {
|
|
100
|
+
inputPerMillion: String(draft.inputTokenPricePerMillion),
|
|
101
|
+
outputPerMillion: String(draft.outputTokenPricePerMillion),
|
|
102
|
+
},
|
|
103
|
+
imageCapability: draft.imageCapability,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
const SOURCE_CLASS_NAMES = {
|
|
107
|
+
local: 'status-running',
|
|
108
|
+
};
|
|
109
|
+
function FieldInput({ name, defaultValue, suffix, placeholder, disabled = false, readOnly = false, type = 'text', onChange, testId, }) {
|
|
110
|
+
return (_jsxs("div", { className: "relative", children: [_jsx(Input, { name: name, type: type, defaultValue: defaultValue, placeholder: placeholder, disabled: disabled, readOnly: readOnly, onChange: onChange ? (event) => onChange(event.target.value) : undefined, "data-testid": testId, className: cn('h-9 text-sm', suffix && 'pr-20', readOnly && 'bg-muted/50 text-muted-foreground') }), suffix && (_jsx("span", { className: "pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-[11px] text-muted-foreground", children: suffix }))] }));
|
|
111
|
+
}
|
|
112
|
+
function Field({ label, required, help, error, children, }) {
|
|
113
|
+
return (_jsxs("div", { children: [_jsxs(Label, { className: "mb-1.5 block text-xs font-medium", children: [label, required && _jsx("span", { className: "text-destructive", children: "*" })] }), children, error ? (_jsx("div", { className: "mt-1.5 text-[11.5px] leading-relaxed text-destructive", children: error })) : (help && _jsx("div", { className: "mt-1.5 text-[11.5px] leading-relaxed text-muted-foreground", children: help }))] }));
|
|
114
|
+
}
|
|
115
|
+
function Section({ number, title, right, children, complete = false, }) {
|
|
116
|
+
return (_jsxs("section", { className: "rounded-lg border bg-card", children: [_jsxs("div", { className: "flex items-center gap-2 border-b px-4 py-3", children: [_jsx("span", { className: cn('inline-flex size-6 shrink-0 items-center justify-center rounded-full bg-muted font-mono text-xs font-semibold text-muted-foreground', complete && 'bg-[var(--status-running-dot)] text-white'), children: number }), _jsx("h2", { className: "text-sm font-semibold", children: title }), right && _jsx("div", { className: "ml-auto", children: right })] }), _jsx("div", { className: "space-y-4 p-4", children: children })] }));
|
|
117
|
+
}
|
|
118
|
+
function SwitchLike({ on }) {
|
|
119
|
+
return (_jsx("span", { className: cn('relative inline-flex h-5 w-9 rounded-full border transition-colors', on ? 'border-primary bg-primary' : 'border-border bg-muted'), "aria-hidden": "true", children: _jsx("span", { className: cn('absolute top-0.5 size-4 rounded-full bg-card shadow transition-transform', on ? 'translate-x-[17px]' : 'translate-x-0.5') }) }));
|
|
120
|
+
}
|
|
121
|
+
function SourceAndStatus({ model }) {
|
|
122
|
+
const { t } = useI18n();
|
|
123
|
+
const status = MODEL_STATUS_CLASSES[model.status];
|
|
124
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { className: cn('inline-flex rounded-full border px-2 py-0.5 text-[11px] font-medium', SOURCE_CLASS_NAMES[getProjectModelSource(model)]), children: t(MODEL_SOURCE_LABEL_KEYS[getProjectModelSource(model)]) }), _jsxs("span", { className: cn('inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[11px] font-medium', status.pill), children: [_jsx("span", { className: cn('size-1.5 rounded-full', status.dot) }), t(MODEL_STATUS_LABEL_KEYS[model.status])] })] }));
|
|
125
|
+
}
|
|
126
|
+
function BasicSection({ mode, useDefaults, model, readOnly, nameError, onNameChange, onDraftChange, }) {
|
|
127
|
+
const { t } = useI18n();
|
|
128
|
+
const isNew = mode === 'new';
|
|
129
|
+
return (_jsxs(Section, { number: "1", title: t('models.form.basicInfo'), complete: isNew, right: !isNew && (_jsx("span", { className: "rounded bg-muted px-2 py-0.5 font-mono text-[11px] text-muted-foreground", children: t('models.form.unchanged') })), children: [_jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [_jsx(Field, { label: t('models.form.name'), required: true, error: nameError, children: _jsx(FieldInput, { name: "name", defaultValue: useDefaults ? model.name : undefined, placeholder: "openai-prod", readOnly: readOnly, onChange: onNameChange, testId: isNew ? 'model-new-name' : undefined }) }), _jsx(Field, { label: t('models.form.provider'), required: true, help: !isNew ? t('models.form.providerLockedHelp') : undefined, children: _jsxs(Select, { name: "providerType", defaultValue: useDefaults ? model.provider || undefined : undefined, disabled: !isNew, onValueChange: onDraftChange, children: [_jsx(SelectTrigger, { className: "h-9", "aria-label": t('models.form.provider'), "data-testid": isNew ? 'model-new-provider-type' : undefined, children: _jsx(SelectValue, { placeholder: t('models.form.providerPlaceholder') }) }), _jsx(SelectContent, { children: buildProviderTypeOptions(useDefaults ? model.provider : undefined).map((option) => (_jsx(SelectItem, { value: option.value, "data-testid": isNew ? `model-new-provider-option-${option.value}` : undefined, children: option.label }, option.value))) })] }) })] }), _jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [_jsx(Field, { label: t('models.form.modelId'), required: true, help: isNew ? t('models.form.modelIdHelp') : undefined, children: _jsx(FieldInput, { name: "providerModelId", defaultValue: useDefaults ? model.providerModelId : undefined, placeholder: "gpt-4o-2024-08-06", readOnly: readOnly, testId: isNew ? 'model-new-provider-model-id' : undefined }) }), _jsx(Field, { label: t('models.form.endpoint'), required: isNew, children: _jsx(FieldInput, { name: "endpoint", defaultValue: useDefaults ? model.endpoint : undefined, placeholder: "https://api.openai.com/v1", readOnly: readOnly, testId: isNew ? 'model-new-endpoint' : undefined }) })] }), _jsx("div", { className: "grid gap-4 md:grid-cols-2", children: _jsx(Field, { label: t('models.form.contextWindow'), required: true, children: _jsx(ModelContextWindowInput, { defaultValue: useDefaults ? (model.contextWindowInput ?? toIntegerInputValue(model.contextWindow)) : undefined, readOnly: readOnly, inputClassName: "h-9 text-sm", buttonClassName: "h-9", onValueChange: onDraftChange, testId: isNew ? 'model-new-context-window' : undefined }) }) })] }));
|
|
130
|
+
}
|
|
131
|
+
function CredentialSection({ mode, useDefaults, model, readOnly, projectId, initialApiKey, onApiKeyEdited, onDraftChange, }) {
|
|
132
|
+
const { t } = useI18n();
|
|
133
|
+
const isNew = mode === 'new';
|
|
134
|
+
const revealMutation = useRevealProjectModelApiKey(projectId);
|
|
135
|
+
const [apiKeyVisible, setApiKeyVisible] = useState(isNew);
|
|
136
|
+
const [apiKeyCopied, setApiKeyCopied] = useState(false);
|
|
137
|
+
const [apiKeyValue, setApiKeyValue] = useState(() => initialApiKey ?? (isNew ? '' : model.apiKey));
|
|
138
|
+
const copyApiKey = async () => {
|
|
139
|
+
if (!apiKeyVisible || !apiKeyValue)
|
|
140
|
+
return;
|
|
141
|
+
await navigator.clipboard?.writeText(apiKeyValue);
|
|
142
|
+
setApiKeyCopied(true);
|
|
143
|
+
window.setTimeout(() => setApiKeyCopied(false), 1800);
|
|
144
|
+
};
|
|
145
|
+
const toggleReveal = () => {
|
|
146
|
+
if (isNew) {
|
|
147
|
+
setApiKeyVisible((visible) => !visible);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (apiKeyVisible) {
|
|
151
|
+
setApiKeyVisible(false);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (apiKeyValue) {
|
|
155
|
+
setApiKeyVisible(true);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (!model.id)
|
|
159
|
+
return;
|
|
160
|
+
revealMutation.mutate(model.id, {
|
|
161
|
+
onSuccess: (result) => {
|
|
162
|
+
setApiKeyValue(result.apiKey);
|
|
163
|
+
setApiKeyVisible(true);
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
return (_jsxs(Section, { number: "2", title: t('models.form.credential'), complete: isNew, right: _jsxs("span", { className: "inline-flex items-center gap-1 rounded border border-amber-200 bg-amber-50 px-2 py-0.5 font-mono text-[11px] text-amber-800 dark:border-amber-900/60 dark:bg-amber-950/30 dark:text-amber-200", children: [_jsx(Lock, { className: "size-3" }), apiKeyVisible
|
|
168
|
+
? t('models.form.plaintextVisible')
|
|
169
|
+
: isNew
|
|
170
|
+
? t('models.form.encryptedStorage')
|
|
171
|
+
: t('models.form.masked')] }), children: [_jsx(Field, { label: "API Key", required: isNew, help: t('models.form.apiKeyHelp'), children: _jsxs("div", { className: "flex h-9 items-center gap-2 rounded-md border border-input bg-background px-3 text-sm", children: [_jsx("input", { name: "apiKey", type: apiKeyVisible ? 'text' : 'password', value: apiKeyValue, onChange: (event) => {
|
|
172
|
+
setApiKeyValue(event.target.value);
|
|
173
|
+
if (!isNew)
|
|
174
|
+
onApiKeyEdited?.();
|
|
175
|
+
}, readOnly: readOnly, placeholder: "sk-...", "data-testid": isNew ? 'model-new-api-key' : undefined, className: cn('min-w-0 flex-1 bg-transparent font-mono outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed', readOnly && 'text-muted-foreground') }), apiKeyVisible && (_jsxs(Button, { type: "button", variant: "ghost", size: "sm", className: "ml-auto h-7 px-2 text-xs", "aria-label": t('models.form.copyKey'), disabled: !apiKeyValue, onClick: () => {
|
|
176
|
+
void copyApiKey();
|
|
177
|
+
}, children: [_jsx(Copy, { className: "size-3.5" }), apiKeyCopied ? t('models.form.keyCopied') : t('models.form.copyKey')] })), _jsx(Button, { type: "button", variant: "ghost", size: "icon", className: cn('size-7', !apiKeyVisible && 'ml-auto'), "aria-label": t('models.form.revealKey'), onClick: toggleReveal, disabled: revealMutation.isPending, children: apiKeyVisible ? _jsx(EyeOff, { className: "size-3.5" }) : _jsx(Eye, { className: "size-3.5" }) })] }) }), _jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [_jsx(Field, { label: t('models.form.extraHeaders'), help: t('models.form.extraHeadersHelp'), children: _jsx(FieldInput, { placeholder: '{ "X-Region": "cn-east" }', readOnly: readOnly }) }), _jsx(Field, { label: t('models.form.extraBody'), help: t('models.form.extraBodyHelp'), children: _jsx(JsonObjectTextarea, { name: "extraBody", defaultValue: useDefaults ? model.extraBodyInput : undefined, placeholder: '{ "top_k": 40, "repetition_penalty": 1.05 }', readOnly: readOnly, onAutoFormat: onDraftChange }) })] })] }));
|
|
178
|
+
}
|
|
179
|
+
function capabilityToDraft(model, useDefaults) {
|
|
180
|
+
if (!useDefaults) {
|
|
181
|
+
return { supportsImages: true, imageUrl: true, imageBase64: true };
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
supportsImages: model.imageCapability !== 'none',
|
|
185
|
+
imageUrl: model.imageCapability === 'url' || model.imageCapability === 'both',
|
|
186
|
+
imageBase64: model.imageCapability === 'base64' || model.imageCapability === 'both',
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function imageCapabilityFromDraft(supportsImages, imageUrl, imageBase64) {
|
|
190
|
+
if (!supportsImages)
|
|
191
|
+
return 'none';
|
|
192
|
+
if (imageUrl && imageBase64)
|
|
193
|
+
return 'both';
|
|
194
|
+
if (imageUrl)
|
|
195
|
+
return 'url';
|
|
196
|
+
if (imageBase64)
|
|
197
|
+
return 'base64';
|
|
198
|
+
return 'none';
|
|
199
|
+
}
|
|
200
|
+
function CapabilitiesSection({ mode, useDefaults, model, readOnly, onDraftChange, }) {
|
|
201
|
+
const { t } = useI18n();
|
|
202
|
+
const isNew = mode === 'new';
|
|
203
|
+
const initialDraft = useMemo(() => capabilityToDraft(model, useDefaults), [useDefaults, model]);
|
|
204
|
+
const [supportsImages, setSupportsImages] = useState(initialDraft.supportsImages);
|
|
205
|
+
const [imageUrl, setImageUrl] = useState(initialDraft.imageUrl);
|
|
206
|
+
const [imageBase64, setImageBase64] = useState(initialDraft.imageBase64);
|
|
207
|
+
const imageCapability = imageCapabilityFromDraft(supportsImages, imageUrl, imageBase64);
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect -- async model detail seeds the controlled capability draft
|
|
210
|
+
setSupportsImages(initialDraft.supportsImages);
|
|
211
|
+
setImageUrl(initialDraft.imageUrl);
|
|
212
|
+
setImageBase64(initialDraft.imageBase64);
|
|
213
|
+
}, [initialDraft]);
|
|
214
|
+
const scheduleDraftChange = () => {
|
|
215
|
+
window.requestAnimationFrame(() => onDraftChange?.());
|
|
216
|
+
};
|
|
217
|
+
const toggleSupportsImages = () => {
|
|
218
|
+
if (readOnly)
|
|
219
|
+
return;
|
|
220
|
+
setSupportsImages((current) => {
|
|
221
|
+
const next = !current;
|
|
222
|
+
if (next && !imageUrl && !imageBase64) {
|
|
223
|
+
setImageUrl(true);
|
|
224
|
+
setImageBase64(true);
|
|
225
|
+
}
|
|
226
|
+
return next;
|
|
227
|
+
});
|
|
228
|
+
scheduleDraftChange();
|
|
229
|
+
};
|
|
230
|
+
return (_jsxs(Section, { number: "3", title: t('models.form.capabilities'), right: !isNew && (_jsxs("span", { className: "inline-flex items-center gap-1.5 rounded border px-2 py-0.5 text-[11px] font-medium status-pending", children: [_jsx(AlertTriangle, { className: "size-3" }), t('models.form.affectsPrompts')] })), children: [_jsx("input", { type: "hidden", name: "imageCapability", value: imageCapability }), _jsxs("div", { className: "flex items-start justify-between gap-4 py-1", children: [_jsxs("div", { children: [_jsx("div", { className: "text-sm font-medium", children: t('models.form.supportsImages') }), !isNew && (_jsx("div", { className: "mt-0.5 text-[11.5px] text-muted-foreground", children: t('models.form.supportsImagesHelp') }))] }), _jsx("button", { type: "button", "aria-label": t('models.form.supportsImages'), disabled: readOnly, onClick: toggleSupportsImages, children: _jsx(SwitchLike, { on: supportsImages }) })] }), supportsImages && (_jsxs("div", { className: "grid gap-3 border-t pt-4 md:grid-cols-2", children: [_jsxs("label", { className: "flex cursor-pointer items-start gap-2.5 rounded-md border p-3 hover:bg-accent", children: [_jsx("input", { name: "imageUrl", type: "checkbox", checked: imageUrl, disabled: readOnly, onChange: (event) => {
|
|
231
|
+
setImageUrl(event.target.checked);
|
|
232
|
+
scheduleDraftChange();
|
|
233
|
+
}, className: "mt-0.5 size-4 accent-primary" }), _jsxs("span", { children: [_jsx("span", { className: "block text-xs font-medium", children: t('models.form.imageUrl') }), _jsx("span", { className: "mt-0.5 block text-[11.5px] text-muted-foreground", children: t('models.form.imageUrlHelp') })] })] }), _jsxs("label", { className: "flex cursor-pointer items-start gap-2.5 rounded-md border p-3 hover:bg-accent", children: [_jsx("input", { name: "imageBase64", type: "checkbox", checked: imageBase64, disabled: readOnly, onChange: (event) => {
|
|
234
|
+
setImageBase64(event.target.checked);
|
|
235
|
+
scheduleDraftChange();
|
|
236
|
+
}, className: "mt-0.5 size-4 accent-primary" }), _jsxs("span", { children: [_jsx("span", { className: "block text-xs font-medium", children: t('models.form.imageBase64') }), _jsx("span", { className: "mt-0.5 block text-[11.5px] text-muted-foreground", children: t('models.form.imageBase64Help') })] })] })] }))] }));
|
|
237
|
+
}
|
|
238
|
+
function QuotaSection({ mode, useDefaults, model, readOnly, }) {
|
|
239
|
+
const { t } = useI18n();
|
|
240
|
+
const isEdit = mode === 'edit';
|
|
241
|
+
const isNew = mode === 'new';
|
|
242
|
+
const [autoConcurrency, setAutoConcurrency] = useState(useDefaults ? model.autoConcurrency : true);
|
|
243
|
+
const usageSummary = `${t('models.form.realtimeUsage')}: ${model.rpm.usage}% / ${model.tpm.usage}% / ${model.concurrency.usage}%`;
|
|
244
|
+
return (_jsx(Section, { number: "4", title: t('models.form.quotas'), right: isEdit && (_jsxs("span", { className: "inline-flex items-center gap-1.5 rounded border px-2 py-0.5 text-[11px] font-medium status-canary", children: [_jsx("span", { className: "size-1.5 rounded-full dot-canary" }), usageSummary] })), children: _jsxs("div", { className: "grid gap-4 md:grid-cols-3", children: [_jsxs(Field, { label: t('models.form.rpmLimit'), required: true, help: t('models.form.rpmTpmLimitHelp'), children: [_jsx(FieldInput, { name: "rpmLimit", defaultValue: useDefaults ? (model.rpm.limitInput ?? toIntegerInputValue(model.rpm.limit)) : undefined, placeholder: "2000", suffix: "req/min", readOnly: readOnly, testId: isNew ? 'model-new-rpm-limit' : undefined }), isEdit && _jsx(QuotaLine, { usage: model.rpm.usage, current: model.rpm.current, limit: model.rpm.limit })] }), _jsxs(Field, { label: t('models.form.tpmLimit'), required: true, help: t('models.form.rpmTpmLimitHelp'), children: [_jsx(FieldInput, { name: "tpmLimit", defaultValue: useDefaults ? (model.tpm.limitInput ?? toIntegerInputValue(model.tpm.limit)) : undefined, placeholder: "800000", suffix: "tok/min", readOnly: readOnly, testId: isNew ? 'model-new-tpm-limit' : undefined }), isEdit && _jsx(QuotaLine, { usage: model.tpm.usage, current: model.tpm.current, limit: model.tpm.limit })] }), _jsxs(Field, { label: autoConcurrency ? t('models.form.concurrencyCeiling') : t('models.form.concurrencyLimit'), help: autoConcurrency ? t('models.form.autoConcurrencyHelp') : t('models.form.concurrencyLimitHelp'), children: [_jsx(FieldInput, { name: "concurrencyLimit", defaultValue: useDefaults ? (model.concurrency.limitInput ?? toIntegerInputValue(model.concurrency.limit)) : undefined, placeholder: String(MODEL_DEFAULT_CONCURRENCY_LIMIT), suffix: "in-flight", readOnly: readOnly }), _jsxs("label", { className: "mt-2 flex cursor-pointer items-center gap-2 text-[11.5px] text-muted-foreground", children: [_jsx("input", { name: "autoConcurrency", type: "checkbox", checked: autoConcurrency, disabled: readOnly, onChange: (event) => setAutoConcurrency(event.target.checked), className: "size-3.5 accent-primary" }), _jsx("span", { children: t('models.form.autoConcurrency') })] }), isEdit && (_jsx(QuotaLine, { usage: model.concurrency.usage, current: model.concurrency.current, limit: autoConcurrency && model.concurrency.effective
|
|
245
|
+
? `${model.concurrency.effective} / ${model.concurrency.limit}`
|
|
246
|
+
: model.concurrency.limit }))] })] }) }));
|
|
247
|
+
}
|
|
248
|
+
function QuotaLine({ usage, current, limit }) {
|
|
249
|
+
const meterLabel = formatProgressLabel({
|
|
250
|
+
value: usage,
|
|
251
|
+
max: 100,
|
|
252
|
+
percent: usage,
|
|
253
|
+
valueLabel: current,
|
|
254
|
+
maxLabel: limit,
|
|
255
|
+
});
|
|
256
|
+
return (_jsx(_Fragment, { children: _jsx(Progress, { value: usage, label: meterLabel, className: "mt-2" }) }));
|
|
257
|
+
}
|
|
258
|
+
function PricingSection({ useDefaults, model, readOnly, }) {
|
|
259
|
+
const { t } = useI18n();
|
|
260
|
+
return (_jsxs(Section, { number: "5", title: t('models.form.pricing'), right: _jsxs("span", { className: "inline-flex items-center gap-1.5 rounded border px-2 py-0.5 text-[11px] font-medium status-canary", children: [_jsx(DollarSign, { className: "size-3" }), t('models.form.costEstimateBasis')] }), children: [_jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [_jsx(Field, { label: t('models.form.inputTokenPrice'), required: true, help: t('models.form.inputTokenPriceHelp'), children: _jsx(FieldInput, { name: "inputPrice", type: "number", defaultValue: useDefaults ? model.pricing.inputPerMillion : undefined, placeholder: "2.50", suffix: "/ 1M tokens", readOnly: readOnly }) }), _jsx(Field, { label: t('models.form.outputTokenPrice'), required: true, help: t('models.form.outputTokenPriceHelp'), children: _jsx(FieldInput, { name: "outputPrice", type: "number", defaultValue: useDefaults ? model.pricing.outputPerMillion : undefined, placeholder: "10.00", suffix: "/ 1M tokens", readOnly: readOnly }) })] }), _jsx("div", { className: "rounded-md border bg-muted/45 px-3 py-2 font-mono text-[11px] text-muted-foreground", children: t('models.form.costFormula') })] }));
|
|
261
|
+
}
|
|
262
|
+
function draftImageCapability(form) {
|
|
263
|
+
const imageUrl = form.has('imageUrl');
|
|
264
|
+
const imageBase64 = form.has('imageBase64');
|
|
265
|
+
if (imageUrl && imageBase64)
|
|
266
|
+
return 'both';
|
|
267
|
+
if (imageUrl)
|
|
268
|
+
return 'url';
|
|
269
|
+
if (imageBase64)
|
|
270
|
+
return 'base64';
|
|
271
|
+
return 'none';
|
|
272
|
+
}
|
|
273
|
+
function positiveIntegerFromForm(form, key) {
|
|
274
|
+
const raw = String(form.get(key) ?? '').trim();
|
|
275
|
+
const value = Number(raw);
|
|
276
|
+
return Number.isInteger(value) && value > 0 ? value : null;
|
|
277
|
+
}
|
|
278
|
+
function rateLimitFromForm(form, key) {
|
|
279
|
+
const raw = String(form.get(key) ?? '').trim();
|
|
280
|
+
const value = Number(raw);
|
|
281
|
+
return Number.isInteger(value) && (value === MODEL_UNLIMITED_RATE_LIMIT || value > 0) ? value : null;
|
|
282
|
+
}
|
|
283
|
+
function concurrencyLimitFromForm(form, key) {
|
|
284
|
+
const raw = String(form.get(key) ?? '').trim();
|
|
285
|
+
const value = raw ? Number(raw) : MODEL_DEFAULT_CONCURRENCY_LIMIT;
|
|
286
|
+
return Number.isInteger(value) && value > 0 && value <= MODEL_MAX_CONCURRENCY_LIMIT ? value : null;
|
|
287
|
+
}
|
|
288
|
+
function nonnegativeNumberFromForm(form, key) {
|
|
289
|
+
const raw = String(form.get(key) ?? '').trim();
|
|
290
|
+
const value = Number(raw || '0');
|
|
291
|
+
return Number.isFinite(value) && value >= 0 ? value : null;
|
|
292
|
+
}
|
|
293
|
+
function textFromForm(form, key) {
|
|
294
|
+
return String(form.get(key) ?? '').trim();
|
|
295
|
+
}
|
|
296
|
+
function normalizedNumberSignature(raw) {
|
|
297
|
+
const trimmed = String(raw ?? '').trim();
|
|
298
|
+
if (!trimmed)
|
|
299
|
+
return '';
|
|
300
|
+
const value = Number(trimmed);
|
|
301
|
+
return Number.isFinite(value) ? value : trimmed;
|
|
302
|
+
}
|
|
303
|
+
function normalizedJsonSignature(raw) {
|
|
304
|
+
const trimmed = String(raw ?? '').trim();
|
|
305
|
+
if (!trimmed)
|
|
306
|
+
return {};
|
|
307
|
+
try {
|
|
308
|
+
const parsed = JSON.parse(trimmed);
|
|
309
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : trimmed;
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
return trimmed;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function jsonObjectFromForm(form, key) {
|
|
316
|
+
const raw = String(form.get(key) ?? '').trim();
|
|
317
|
+
if (!raw)
|
|
318
|
+
return {};
|
|
319
|
+
try {
|
|
320
|
+
const parsed = JSON.parse(raw);
|
|
321
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
322
|
+
return parsed;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
catch {
|
|
326
|
+
return null;
|
|
327
|
+
}
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
function projectEditSignatureFromModel(model) {
|
|
331
|
+
return JSON.stringify({
|
|
332
|
+
name: model.name.trim(),
|
|
333
|
+
providerModelId: model.providerModelId.trim(),
|
|
334
|
+
endpoint: model.endpoint.trim(),
|
|
335
|
+
apiKey: '',
|
|
336
|
+
contextWindowTokens: normalizedNumberSignature(model.contextWindowInput ?? toIntegerInputValue(model.contextWindow)),
|
|
337
|
+
rpmLimit: normalizedNumberSignature(model.rpm.limitInput ?? toIntegerInputValue(model.rpm.limit)),
|
|
338
|
+
tpmLimit: normalizedNumberSignature(model.tpm.limitInput ?? toIntegerInputValue(model.tpm.limit)),
|
|
339
|
+
concurrencyLimit: normalizedNumberSignature(model.concurrency.limitInput ?? toIntegerInputValue(model.concurrency.limit)),
|
|
340
|
+
autoConcurrency: model.autoConcurrency,
|
|
341
|
+
inputPrice: normalizedNumberSignature(model.pricing.inputPerMillion),
|
|
342
|
+
outputPrice: normalizedNumberSignature(model.pricing.outputPerMillion),
|
|
343
|
+
imageCapability: model.imageCapability,
|
|
344
|
+
extraBody: normalizedJsonSignature(model.extraBodyInput),
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
function projectEditSignatureFromForm(form, apiKeyEdited) {
|
|
348
|
+
const data = new FormData(form);
|
|
349
|
+
return JSON.stringify({
|
|
350
|
+
name: textFromForm(data, 'name'),
|
|
351
|
+
providerModelId: textFromForm(data, 'providerModelId'),
|
|
352
|
+
endpoint: textFromForm(data, 'endpoint'),
|
|
353
|
+
apiKey: apiKeyEdited ? textFromForm(data, 'apiKey') : '',
|
|
354
|
+
contextWindowTokens: normalizedNumberSignature(String(data.get('contextWindowTokens') ?? '')),
|
|
355
|
+
rpmLimit: normalizedNumberSignature(String(data.get('rpmLimit') ?? '')),
|
|
356
|
+
tpmLimit: normalizedNumberSignature(String(data.get('tpmLimit') ?? '')),
|
|
357
|
+
concurrencyLimit: normalizedNumberSignature(String(data.get('concurrencyLimit') ?? '')),
|
|
358
|
+
autoConcurrency: data.has('autoConcurrency'),
|
|
359
|
+
inputPrice: normalizedNumberSignature(String(data.get('inputPrice') ?? '')),
|
|
360
|
+
outputPrice: normalizedNumberSignature(String(data.get('outputPrice') ?? '')),
|
|
361
|
+
imageCapability: String(data.get('imageCapability') ?? 'none'),
|
|
362
|
+
extraBody: normalizedJsonSignature(String(data.get('extraBody') ?? '')),
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
function readProjectModelCreatePayload(form, intent) {
|
|
366
|
+
const data = new FormData(form);
|
|
367
|
+
const name = textFromForm(data, 'name');
|
|
368
|
+
const providerType = textFromForm(data, 'providerType');
|
|
369
|
+
const providerModelId = textFromForm(data, 'providerModelId');
|
|
370
|
+
const endpoint = textFromForm(data, 'endpoint');
|
|
371
|
+
const apiKey = textFromForm(data, 'apiKey');
|
|
372
|
+
const contextWindowTokens = positiveIntegerFromForm(data, 'contextWindowTokens');
|
|
373
|
+
const rpmLimit = rateLimitFromForm(data, 'rpmLimit');
|
|
374
|
+
const tpmLimit = rateLimitFromForm(data, 'tpmLimit');
|
|
375
|
+
const concurrencyLimit = concurrencyLimitFromForm(data, 'concurrencyLimit');
|
|
376
|
+
const inputPrice = nonnegativeNumberFromForm(data, 'inputPrice');
|
|
377
|
+
const outputPrice = nonnegativeNumberFromForm(data, 'outputPrice');
|
|
378
|
+
const extraBody = jsonObjectFromForm(data, 'extraBody');
|
|
379
|
+
const imageCapability = draftImageCapability(data);
|
|
380
|
+
if ([name, providerType, providerModelId, endpoint, apiKey].some((value) => !value.trim())) {
|
|
381
|
+
return { ok: false, error: 'required' };
|
|
382
|
+
}
|
|
383
|
+
if (extraBody === null) {
|
|
384
|
+
return { ok: false, error: 'json' };
|
|
385
|
+
}
|
|
386
|
+
if (contextWindowTokens === null ||
|
|
387
|
+
rpmLimit === null ||
|
|
388
|
+
tpmLimit === null ||
|
|
389
|
+
concurrencyLimit === null ||
|
|
390
|
+
inputPrice === null ||
|
|
391
|
+
outputPrice === null) {
|
|
392
|
+
return { ok: false, error: 'number' };
|
|
393
|
+
}
|
|
394
|
+
return {
|
|
395
|
+
ok: true,
|
|
396
|
+
body: {
|
|
397
|
+
name,
|
|
398
|
+
providerType,
|
|
399
|
+
providerModelId,
|
|
400
|
+
endpoint,
|
|
401
|
+
apiKey,
|
|
402
|
+
contextWindowTokens,
|
|
403
|
+
rpm: { limit: rpmLimit },
|
|
404
|
+
tpm: { limit: tpmLimit },
|
|
405
|
+
concurrency: { limit: concurrencyLimit },
|
|
406
|
+
autoConcurrency: data.has('autoConcurrency'),
|
|
407
|
+
pricing: { inputPerMillion: inputPrice, outputPerMillion: outputPrice },
|
|
408
|
+
capabilities: { image: imageCapability },
|
|
409
|
+
extraBody,
|
|
410
|
+
status: intent === 'draft' ? 'disabled' : 'enabled',
|
|
411
|
+
},
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
function projectModelCreateConnectivitySignature(body) {
|
|
415
|
+
return JSON.stringify({
|
|
416
|
+
name: body.name.trim(),
|
|
417
|
+
providerType: body.providerType.trim(),
|
|
418
|
+
providerModelId: body.providerModelId.trim(),
|
|
419
|
+
endpoint: body.endpoint.trim(),
|
|
420
|
+
apiKey: body.apiKey,
|
|
421
|
+
contextWindowTokens: body.contextWindowTokens ?? null,
|
|
422
|
+
rpmLimit: body.rpm.limit,
|
|
423
|
+
tpmLimit: body.tpm.limit,
|
|
424
|
+
concurrencyLimit: body.concurrency.limit,
|
|
425
|
+
inputPrice: body.pricing.inputPerMillion,
|
|
426
|
+
outputPrice: body.pricing.outputPerMillion,
|
|
427
|
+
imageCapability: body.capabilities.image,
|
|
428
|
+
extraBody: body.extraBody ?? {},
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
function readProjectModelUpdatePayload(form, includeApiKey) {
|
|
432
|
+
const data = new FormData(form);
|
|
433
|
+
const name = textFromForm(data, 'name');
|
|
434
|
+
const providerModelId = textFromForm(data, 'providerModelId');
|
|
435
|
+
const endpoint = textFromForm(data, 'endpoint');
|
|
436
|
+
const apiKey = textFromForm(data, 'apiKey');
|
|
437
|
+
const contextWindowTokens = positiveIntegerFromForm(data, 'contextWindowTokens');
|
|
438
|
+
const rpmLimit = rateLimitFromForm(data, 'rpmLimit');
|
|
439
|
+
const tpmLimit = rateLimitFromForm(data, 'tpmLimit');
|
|
440
|
+
const concurrencyLimit = concurrencyLimitFromForm(data, 'concurrencyLimit');
|
|
441
|
+
const inputPrice = nonnegativeNumberFromForm(data, 'inputPrice');
|
|
442
|
+
const outputPrice = nonnegativeNumberFromForm(data, 'outputPrice');
|
|
443
|
+
const extraBody = jsonObjectFromForm(data, 'extraBody');
|
|
444
|
+
const imageCapabilityValue = String(data.get('imageCapability') ?? 'none');
|
|
445
|
+
const imageCapability = imageCapabilityValue === 'url' ||
|
|
446
|
+
imageCapabilityValue === 'base64' ||
|
|
447
|
+
imageCapabilityValue === 'both' ||
|
|
448
|
+
imageCapabilityValue === 'none'
|
|
449
|
+
? imageCapabilityValue
|
|
450
|
+
: 'none';
|
|
451
|
+
if ([name, providerModelId, endpoint].some((value) => !value.trim())) {
|
|
452
|
+
return { ok: false, error: 'required' };
|
|
453
|
+
}
|
|
454
|
+
if (extraBody === null) {
|
|
455
|
+
return { ok: false, error: 'json' };
|
|
456
|
+
}
|
|
457
|
+
if (contextWindowTokens === null ||
|
|
458
|
+
rpmLimit === null ||
|
|
459
|
+
tpmLimit === null ||
|
|
460
|
+
concurrencyLimit === null ||
|
|
461
|
+
inputPrice === null ||
|
|
462
|
+
outputPrice === null) {
|
|
463
|
+
return { ok: false, error: 'number' };
|
|
464
|
+
}
|
|
465
|
+
const body = {
|
|
466
|
+
name,
|
|
467
|
+
providerModelId,
|
|
468
|
+
endpoint,
|
|
469
|
+
contextWindowTokens,
|
|
470
|
+
rpm: { limit: rpmLimit },
|
|
471
|
+
tpm: { limit: tpmLimit },
|
|
472
|
+
concurrency: { limit: concurrencyLimit },
|
|
473
|
+
autoConcurrency: data.has('autoConcurrency'),
|
|
474
|
+
pricing: { inputPerMillion: inputPrice, outputPerMillion: outputPrice },
|
|
475
|
+
capabilities: { image: imageCapability },
|
|
476
|
+
extraBody,
|
|
477
|
+
};
|
|
478
|
+
if (includeApiKey && apiKey) {
|
|
479
|
+
body.apiKey = apiKey;
|
|
480
|
+
}
|
|
481
|
+
return { ok: true, body };
|
|
482
|
+
}
|
|
483
|
+
function TestConnectivitySection({ feedback, isTesting, onTest, }) {
|
|
484
|
+
const { t } = useI18n();
|
|
485
|
+
return (_jsxs("section", { className: "rounded-lg border bg-card", children: [_jsxs("div", { className: "flex items-center gap-2 border-b px-4 py-3", children: [_jsx("span", { className: "inline-flex size-6 items-center justify-center rounded-full border border-[var(--status-canary-bd)] bg-[var(--status-canary-bg)] text-[var(--status-canary-fg)]", children: _jsx(Cable, { className: "size-3" }) }), _jsx("h2", { className: "text-sm font-semibold", children: t('models.form.testConnectivity') })] }), _jsxs("div", { className: "space-y-3 p-4", children: [_jsxs(Button, { type: "button", variant: "outline", size: "sm", className: "h-8", onClick: onTest, disabled: isTesting, "aria-busy": isTesting, children: [isTesting ? _jsx(Loader2, { className: "size-3.5 animate-spin" }) : _jsx(Cable, { className: "size-3.5" }), isTesting ? t('models.probe.running') : t('models.form.testMinimalRequest')] }), _jsx(ModelProbeStatus, { feedback: feedback })] })] }));
|
|
486
|
+
}
|
|
487
|
+
function UsagePanel({ model }) {
|
|
488
|
+
const { t } = useI18n();
|
|
489
|
+
const meters = [
|
|
490
|
+
{ key: 'rpm', label: 'RPM', current: model.rpm.current, limit: model.rpm.limit, usage: model.rpm.usage },
|
|
491
|
+
{ key: 'tpm', label: 'TPM', current: model.tpm.current, limit: model.tpm.limit, usage: model.tpm.usage },
|
|
492
|
+
{
|
|
493
|
+
key: 'concurrency',
|
|
494
|
+
label: t('models.table.concurrency'),
|
|
495
|
+
current: model.concurrency.current,
|
|
496
|
+
limit: model.concurrency.limit,
|
|
497
|
+
usage: model.concurrency.usage,
|
|
498
|
+
},
|
|
499
|
+
];
|
|
500
|
+
const maxUsage = meters.reduce((max, meter) => Math.max(max, isUnlimitedLimit(meter.limit) ? 0 : meter.usage), 0);
|
|
501
|
+
return (_jsxs("div", { className: "rounded-lg border bg-card", children: [_jsxs("div", { className: "flex items-center gap-2 border-b px-4 py-3", children: [_jsx(Gauge, { className: "size-4 text-[var(--status-canary-fg)]" }), _jsx("h3", { className: "text-sm font-semibold", children: t('models.form.usagePanel') }), _jsxs("span", { className: cn('ml-auto rounded border px-2 py-0.5 font-mono text-[11px]', usageBadgeClassName(maxUsage)), children: [t('models.form.usageMaxCapacity'), " ", maxUsage, "%"] })] }), _jsx("div", { className: "divide-y p-4", children: meters.map((meter) => (_jsx(UsageGauge, { label: meter.label, current: meter.current, limit: meter.limit, usage: meter.usage }, meter.key))) })] }));
|
|
502
|
+
}
|
|
503
|
+
function UsageGauge({ label, current, limit, usage, }) {
|
|
504
|
+
const { t } = useI18n();
|
|
505
|
+
const unlimited = isUnlimitedLimit(limit);
|
|
506
|
+
const boundedUsage = Math.max(0, Math.min(100, Math.round(usage)));
|
|
507
|
+
const tone = usageTone(boundedUsage, unlimited);
|
|
508
|
+
const capacityLabel = unlimited ? t('models.form.usageUnlimited') : `${boundedUsage}%`;
|
|
509
|
+
return (_jsxs("div", { className: "grid grid-cols-[96px_minmax(0,1fr)] items-center gap-3 py-3 first:pt-0 last:pb-0", children: [_jsxs("div", { className: "relative h-[72px] w-24", "aria-label": `${label} ${t('models.form.usageCapacity')} ${capacityLabel}`, children: [_jsxs("svg", { viewBox: "0 0 120 78", className: "h-full w-full overflow-visible", role: "img", children: [_jsx("path", { d: "M 14 64 A 46 46 0 0 1 106 64", fill: "none", stroke: "var(--border)", strokeLinecap: "round", strokeWidth: "12" }), _jsx("path", { d: "M 14 64 A 46 46 0 0 1 106 64", fill: "none", pathLength: 100, stroke: tone.stroke, strokeDasharray: unlimited ? '4 8' : `${boundedUsage} 100`, strokeLinecap: "round", strokeWidth: "12" })] }), _jsxs("div", { className: "absolute inset-x-0 bottom-1 text-center", children: [_jsx("div", { className: "font-mono text-lg font-semibold leading-none", style: { color: tone.text }, children: capacityLabel }), _jsx("div", { className: "mt-1 font-mono text-[10px] uppercase text-muted-foreground", children: t('models.form.usageCapacity') })] })] }), _jsxs("div", { className: "min-w-0", children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("div", { className: "font-mono text-[11px] font-semibold uppercase text-foreground", children: label }), _jsx("span", { className: cn('rounded border px-1.5 py-0.5 font-mono text-[10.5px]', usageBadgeClassName(boundedUsage, unlimited)), children: capacityLabel })] }), _jsxs("div", { className: "mt-2 grid grid-cols-2 gap-2", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "text-[10.5px] text-muted-foreground", children: t('models.form.usageCurrent') }), _jsx("div", { className: "truncate font-mono text-base font-semibold leading-tight", children: formatUsageNumber(current) })] }), _jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "text-[10.5px] text-muted-foreground", children: t('models.form.usageLimit') }), _jsx("div", { className: "truncate font-mono text-base font-semibold leading-tight", children: unlimited ? t('models.form.usageUnlimited') : formatUsageNumber(limit) })] })] })] })] }));
|
|
510
|
+
}
|
|
511
|
+
function isUnlimitedLimit(limit) {
|
|
512
|
+
const value = Number(limit);
|
|
513
|
+
return Number.isFinite(value) && value < 0;
|
|
514
|
+
}
|
|
515
|
+
function formatUsageNumber(value) {
|
|
516
|
+
const numeric = Number(value);
|
|
517
|
+
if (!Number.isFinite(numeric))
|
|
518
|
+
return value || '0';
|
|
519
|
+
return new Intl.NumberFormat('en-US').format(numeric);
|
|
520
|
+
}
|
|
521
|
+
function usageBadgeClassName(usage, unlimited = false) {
|
|
522
|
+
if (unlimited)
|
|
523
|
+
return 'border-[var(--status-archived-bd)] bg-[var(--status-archived-bg)] text-[var(--status-archived-fg)]';
|
|
524
|
+
if (usage >= 90)
|
|
525
|
+
return 'border-destructive/30 bg-destructive/10 text-destructive';
|
|
526
|
+
if (usage >= 80)
|
|
527
|
+
return 'border-[var(--status-pending-bd)] bg-[var(--status-pending-bg)] text-[var(--status-pending-fg)]';
|
|
528
|
+
return 'border-[var(--status-canary-bd)] bg-[var(--status-canary-bg)] text-[var(--status-canary-fg)]';
|
|
529
|
+
}
|
|
530
|
+
function usageTone(usage, unlimited) {
|
|
531
|
+
if (unlimited) {
|
|
532
|
+
return { stroke: 'var(--status-archived-dot)', text: 'var(--status-archived-fg)' };
|
|
533
|
+
}
|
|
534
|
+
if (usage >= 90) {
|
|
535
|
+
return { stroke: 'var(--destructive)', text: 'var(--destructive)' };
|
|
536
|
+
}
|
|
537
|
+
if (usage >= 80) {
|
|
538
|
+
return { stroke: 'var(--status-pending-dot)', text: 'var(--status-pending-fg)' };
|
|
539
|
+
}
|
|
540
|
+
return { stroke: 'var(--status-canary-dot)', text: 'var(--status-canary-fg)' };
|
|
541
|
+
}
|
|
542
|
+
function ReferencePanel({ references, loading }) {
|
|
543
|
+
const { t } = useI18n();
|
|
544
|
+
const items = Object.keys(MODEL_REFERENCE_LABEL_KEYS).map((key) => ({
|
|
545
|
+
key,
|
|
546
|
+
label: t(MODEL_REFERENCE_LABEL_KEYS[key]),
|
|
547
|
+
count: references[key],
|
|
548
|
+
}));
|
|
549
|
+
return (_jsxs("div", { className: "rounded-lg border bg-card", children: [_jsxs("div", { className: "flex items-center gap-2 border-b px-4 py-3", children: [_jsx(Link2, { className: "size-4 text-muted-foreground" }), _jsx("h3", { className: "text-sm font-semibold", children: t('models.form.referencedBy') }), _jsx("span", { className: "ml-auto font-mono text-[11px] text-muted-foreground", children: loading ? t('common.loading') : `${t('models.form.activeReferences')} ${references.total}` })] }), _jsx("div", { className: "p-4", children: references.total === 0 && !loading ? (_jsx("div", { className: "rounded-md border bg-muted/35 px-3 py-2 text-sm text-muted-foreground", children: t('models.form.noActiveReferences') })) : (items.map((item) => (_jsxs("div", { className: "-mx-4 flex items-center justify-between gap-2 border-b px-4 py-2.5 last:border-b-0", children: [_jsx("div", { className: "min-w-0 text-xs font-medium", children: item.label }), _jsx("div", { className: "font-mono text-[11px] text-muted-foreground", children: item.count })] }, item.key)))) })] }));
|
|
550
|
+
}
|
|
551
|
+
function ReadonlyNotice() {
|
|
552
|
+
const { t } = useI18n();
|
|
553
|
+
return (_jsx("div", { className: "rounded-lg border border-[var(--status-canary-bd)] bg-[var(--status-canary-bg)] p-4 text-[var(--status-canary-fg)]", children: _jsxs("div", { className: "flex items-start gap-3", children: [_jsx(Lock, { className: "mt-0.5 size-4 shrink-0" }), _jsxs("div", { className: "min-w-0", children: [_jsx("div", { className: "text-sm font-semibold", children: t('models.form.readonlyTitle') }), _jsx("div", { className: "mt-1 text-[12.5px] leading-relaxed", children: t('models.form.readonlyDescription') })] })] }) }));
|
|
554
|
+
}
|
|
555
|
+
function DangerPanel({ model, references, pending, disabled, onToggleStatus, onDelete, }) {
|
|
556
|
+
const { t } = useI18n();
|
|
557
|
+
const statusLabel = model.status === 'disabled' ? t('models.action.enable') : t('models.action.disable');
|
|
558
|
+
return (_jsxs("div", { className: "rounded-lg border border-destructive/40 bg-card", children: [_jsxs("div", { className: "flex items-center gap-2 border-b border-destructive/30 px-4 py-3 text-destructive", children: [_jsx(AlertTriangle, { className: "size-4" }), _jsx("h3", { className: "text-sm font-semibold", children: t('models.form.dangerZone') })] }), _jsxs("div", { className: "space-y-3 p-4", children: [_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsxs("div", { children: [_jsx("div", { className: "text-xs font-medium", children: t('models.form.disableTemporarily') }), _jsx("div", { className: "mt-0.5 text-[11.5px] text-muted-foreground", children: t('models.form.disableHelp') })] }), _jsxs(Button, { type: "button", variant: "outline", size: "sm", className: "h-8", disabled: disabled || pending, onClick: onToggleStatus, children: [pending ? _jsx(Loader2, { className: "size-3.5 animate-spin" }) : null, statusLabel] })] }), _jsxs("div", { className: "flex items-center justify-between gap-3 border-t pt-3", children: [_jsxs("div", { children: [_jsx("div", { className: "text-xs font-medium", children: t('models.action.delete') }), _jsx("div", { className: "mt-0.5 text-[11.5px] text-destructive", children: references.total > 0 ? t('models.form.deleteBlockedHelp') : t('models.deleteDialogDescription') })] }), _jsx(Button, { type: "button", variant: "destructive", size: "sm", className: "h-8", disabled: disabled || pending, onClick: onDelete, children: t('models.action.delete') })] })] })] }));
|
|
559
|
+
}
|
|
560
|
+
export function ModelFormPage({ mode, projectId, modelId, copyFromId, }) {
|
|
561
|
+
const { t } = useI18n();
|
|
562
|
+
const { formatDateTime } = useDateTimeFormatter();
|
|
563
|
+
const router = useRouter();
|
|
564
|
+
const isNew = mode === 'new';
|
|
565
|
+
const modelQuery = useProjectModel(projectId, isNew ? '' : (modelId ?? ''));
|
|
566
|
+
const copyQuery = useProjectModel(projectId, isNew ? (copyFromId ?? '') : '');
|
|
567
|
+
const projectModelsQuery = useProjectModels(projectId, { autoRefresh: false });
|
|
568
|
+
const referencesQuery = useProjectModelReferences(projectId, isNew ? '' : (modelId ?? ''), !isNew && Boolean(modelId));
|
|
569
|
+
const probeMutation = useProbeProjectModel(projectId);
|
|
570
|
+
const draftProbeMutation = useProbeDraftProjectModel(projectId);
|
|
571
|
+
const createMutation = useCreateProjectModel(projectId);
|
|
572
|
+
const updateMutation = useUpdateProjectModel(projectId);
|
|
573
|
+
const deleteMutation = useDeleteProjectModel(projectId);
|
|
574
|
+
const newModelFormRef = useRef(null);
|
|
575
|
+
const editModelFormRef = useRef(null);
|
|
576
|
+
const [deleteOpen, setDeleteOpen] = useState(false);
|
|
577
|
+
const [editDirty, setEditDirty] = useState(false);
|
|
578
|
+
const [editDraftVersion, setEditDraftVersion] = useState(0);
|
|
579
|
+
const [apiKeyEdited, setApiKeyEdited] = useState(false);
|
|
580
|
+
const [newFormVersion, setNewFormVersion] = useState(0);
|
|
581
|
+
const [newApiKeySeed, setNewApiKeySeed] = useState('');
|
|
582
|
+
const [quickFillDraft, setQuickFillDraft] = useState(null);
|
|
583
|
+
const [newNameDraft, setNewNameDraft] = useState('');
|
|
584
|
+
const [editNameDraft, setEditNameDraft] = useState('');
|
|
585
|
+
const [pendingNewIntent, setPendingNewIntent] = useState(null);
|
|
586
|
+
const [submitError, setSubmitError] = useState(null);
|
|
587
|
+
const [probeFeedback, setProbeFeedback] = useState(null);
|
|
588
|
+
const [draftProbeFeedback, setDraftProbeFeedback] = useState(null);
|
|
589
|
+
const [draftProbeRecord, setDraftProbeRecord] = useState(null);
|
|
590
|
+
const copySuffix = t('models.copySuffix');
|
|
591
|
+
const copySource = useMemo(() => isNew && copyFromId && copyQuery.data ? projectModelForCopy(dtoToProjectModel(copyQuery.data), copySuffix) : null, [isNew, copyFromId, copyQuery.data, copySuffix]);
|
|
592
|
+
const waitingForCopy = isNew && !!copyFromId && !copySource;
|
|
593
|
+
// Gate the copy-source skeleton behind the 300ms threshold so a fast copy fetch doesn't flash the full-page skeleton.
|
|
594
|
+
const copyLoading = useDelayedLoading(waitingForCopy);
|
|
595
|
+
const fetchedModel = useMemo(() => (modelQuery.data ? dtoToProjectModel(modelQuery.data) : null), [modelQuery.data]);
|
|
596
|
+
const quickFillModel = useMemo(() => (isNew && quickFillDraft ? projectModelFromQuickFillDraft(quickFillDraft) : null), [isNew, quickFillDraft]);
|
|
597
|
+
const projectModels = useMemo(() => projectModelsQuery.data?.data ?? [], [projectModelsQuery.data]);
|
|
598
|
+
const model = quickFillModel ?? copySource ?? fetchedModel ?? PROJECT_MODEL_FALLBACK;
|
|
599
|
+
const useDefaults = !isNew || !!copySource || !!quickFillModel;
|
|
600
|
+
const liveModel = model;
|
|
601
|
+
const isEditable = isNew || isProjectModelEditable(model);
|
|
602
|
+
const readOnly = !isEditable;
|
|
603
|
+
const references = referencesQuery.data ?? EMPTY_MODEL_REFERENCES;
|
|
604
|
+
const deleteBlocked = references.total > 0;
|
|
605
|
+
const initialEditSignature = useMemo(() => (!isNew && model.id ? projectEditSignatureFromModel(model) : ''), [isNew, model]);
|
|
606
|
+
const nameTakenMessage = t('common.formError.nameTaken');
|
|
607
|
+
const newNameTaken = isNew && isProjectNameTaken(newNameDraft, projectModels);
|
|
608
|
+
const editNameTaken = !isNew && isProjectNameTaken(editNameDraft, projectModels, model.id);
|
|
609
|
+
const activeNameError = newNameTaken || editNameTaken ? nameTakenMessage : null;
|
|
610
|
+
const refreshEditDirty = useCallback(() => {
|
|
611
|
+
if (isNew || !editModelFormRef.current || !initialEditSignature)
|
|
612
|
+
return;
|
|
613
|
+
setEditDirty(projectEditSignatureFromForm(editModelFormRef.current, apiKeyEdited) !== initialEditSignature);
|
|
614
|
+
}, [apiKeyEdited, initialEditSignature, isNew]);
|
|
615
|
+
const scheduleEditDirtyRefresh = useCallback(() => {
|
|
616
|
+
if (typeof window === 'undefined')
|
|
617
|
+
return;
|
|
618
|
+
window.requestAnimationFrame(refreshEditDirty);
|
|
619
|
+
}, [refreshEditDirty]);
|
|
620
|
+
const applyQuickFillDraft = useCallback((draft) => {
|
|
621
|
+
const currentApiKey = newModelFormRef.current
|
|
622
|
+
? String(new FormData(newModelFormRef.current).get('apiKey') ?? '')
|
|
623
|
+
: '';
|
|
624
|
+
setNewApiKeySeed(currentApiKey);
|
|
625
|
+
setQuickFillDraft(draft);
|
|
626
|
+
setSubmitError(null);
|
|
627
|
+
setDraftProbeFeedback(null);
|
|
628
|
+
setDraftProbeRecord(null);
|
|
629
|
+
setNewFormVersion((version) => version + 1);
|
|
630
|
+
}, []);
|
|
631
|
+
useEffect(() => {
|
|
632
|
+
if (!isNew)
|
|
633
|
+
return;
|
|
634
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect -- copied / quick-filled model name seeds an uncontrolled form field
|
|
635
|
+
setNewNameDraft(model.name);
|
|
636
|
+
}, [isNew, model.name, newFormVersion]);
|
|
637
|
+
useEffect(() => {
|
|
638
|
+
if (isNew)
|
|
639
|
+
return;
|
|
640
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect -- loaded model name seeds duplicate-name validation
|
|
641
|
+
setEditNameDraft(model.name);
|
|
642
|
+
}, [editDraftVersion, isNew, model.id, model.name]);
|
|
643
|
+
useEffect(() => {
|
|
644
|
+
if (isNew)
|
|
645
|
+
return;
|
|
646
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect -- async model detail establishes the clean edit baseline
|
|
647
|
+
setEditDirty(false);
|
|
648
|
+
setApiKeyEdited(false);
|
|
649
|
+
}, [initialEditSignature, isNew]);
|
|
650
|
+
useEffect(() => {
|
|
651
|
+
refreshEditDirty();
|
|
652
|
+
}, [refreshEditDirty]);
|
|
653
|
+
const handleEditSubmit = (event) => {
|
|
654
|
+
event.preventDefault();
|
|
655
|
+
if (readOnly || !model.id || !editDirty || updateMutation.isPending)
|
|
656
|
+
return;
|
|
657
|
+
const result = readProjectModelUpdatePayload(event.currentTarget, apiKeyEdited);
|
|
658
|
+
if (!result.ok) {
|
|
659
|
+
setSubmitError(result.error === 'required'
|
|
660
|
+
? t('common.formError.requiredMissing')
|
|
661
|
+
: result.error === 'json'
|
|
662
|
+
? t('common.formError.invalidJson')
|
|
663
|
+
: t('common.formError.invalidNumber'));
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
if (isProjectNameTaken(result.body.name, projectModels, model.id)) {
|
|
667
|
+
setSubmitError(nameTakenMessage);
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
setSubmitError(null);
|
|
671
|
+
updateMutation.mutate({ modelId: model.id, body: result.body }, {
|
|
672
|
+
onSuccess: () => {
|
|
673
|
+
setEditDirty(false);
|
|
674
|
+
setApiKeyEdited(false);
|
|
675
|
+
},
|
|
676
|
+
onError: (error) => {
|
|
677
|
+
const message = getApiErrorMessage(error);
|
|
678
|
+
setSubmitError(message === 'model_name_taken' ? nameTakenMessage : (message ?? t('common.loadFailedRefresh')));
|
|
679
|
+
},
|
|
680
|
+
});
|
|
681
|
+
};
|
|
682
|
+
const resetEditDraft = () => {
|
|
683
|
+
setSubmitError(null);
|
|
684
|
+
setApiKeyEdited(false);
|
|
685
|
+
setEditDirty(false);
|
|
686
|
+
setEditDraftVersion((version) => version + 1);
|
|
687
|
+
};
|
|
688
|
+
const toggleModelStatus = () => {
|
|
689
|
+
if (!model.id || editDirty || updateMutation.isPending)
|
|
690
|
+
return;
|
|
691
|
+
const status = model.status === 'disabled' ? 'enabled' : 'disabled';
|
|
692
|
+
updateMutation.mutate({ modelId: model.id, body: { status } }, {
|
|
693
|
+
onError: (error) => setSubmitError(error.message),
|
|
694
|
+
});
|
|
695
|
+
};
|
|
696
|
+
const confirmDeleteModel = () => {
|
|
697
|
+
if (!model.id || deleteBlocked || deleteMutation.isPending)
|
|
698
|
+
return;
|
|
699
|
+
deleteMutation.mutate({ modelId: model.id }, {
|
|
700
|
+
onSuccess: () => router.push(`/models`),
|
|
701
|
+
onError: (error) => setSubmitError(error.message),
|
|
702
|
+
});
|
|
703
|
+
};
|
|
704
|
+
const testConnectivity = () => {
|
|
705
|
+
if (!model.id)
|
|
706
|
+
return;
|
|
707
|
+
const startedAt = Date.now();
|
|
708
|
+
setProbeFeedback({ status: 'running', durationMs: null });
|
|
709
|
+
probeMutation.mutate(model.id, {
|
|
710
|
+
onSuccess: (result) => {
|
|
711
|
+
setProbeFeedback({
|
|
712
|
+
status: result.status === 'success' ? 'success' : 'failed',
|
|
713
|
+
durationMs: result.durationMs,
|
|
714
|
+
errorMessage: result.error,
|
|
715
|
+
});
|
|
716
|
+
},
|
|
717
|
+
onError: (error) => {
|
|
718
|
+
setProbeFeedback({
|
|
719
|
+
status: 'failed',
|
|
720
|
+
durationMs: Date.now() - startedAt,
|
|
721
|
+
errorMessage: getApiErrorMessage(error),
|
|
722
|
+
});
|
|
723
|
+
},
|
|
724
|
+
});
|
|
725
|
+
};
|
|
726
|
+
const refreshDraftProbeFreshness = useCallback(() => {
|
|
727
|
+
if (!isNew || !draftProbeRecord || !newModelFormRef.current)
|
|
728
|
+
return;
|
|
729
|
+
const result = readProjectModelCreatePayload(newModelFormRef.current, 'enable');
|
|
730
|
+
if (!result.ok || projectModelCreateConnectivitySignature(result.body) !== draftProbeRecord.signature) {
|
|
731
|
+
setDraftProbeFeedback(null);
|
|
732
|
+
setDraftProbeRecord(null);
|
|
733
|
+
}
|
|
734
|
+
}, [draftProbeRecord, isNew]);
|
|
735
|
+
const testDraftConnectivity = () => {
|
|
736
|
+
if (!newModelFormRef.current)
|
|
737
|
+
return;
|
|
738
|
+
const startedAt = Date.now();
|
|
739
|
+
const form = new FormData(newModelFormRef.current);
|
|
740
|
+
const name = textFromForm(form, 'name');
|
|
741
|
+
const providerType = textFromForm(form, 'providerType');
|
|
742
|
+
const providerModelId = textFromForm(form, 'providerModelId');
|
|
743
|
+
const endpoint = textFromForm(form, 'endpoint');
|
|
744
|
+
const apiKey = String(form.get('apiKey') ?? '');
|
|
745
|
+
const contextWindowTokens = positiveIntegerFromForm(form, 'contextWindowTokens');
|
|
746
|
+
const rpmLimit = rateLimitFromForm(form, 'rpmLimit');
|
|
747
|
+
const tpmLimit = rateLimitFromForm(form, 'tpmLimit');
|
|
748
|
+
const concurrencyLimit = concurrencyLimitFromForm(form, 'concurrencyLimit');
|
|
749
|
+
const inputPrice = nonnegativeNumberFromForm(form, 'inputPrice');
|
|
750
|
+
const outputPrice = nonnegativeNumberFromForm(form, 'outputPrice');
|
|
751
|
+
const extraBody = jsonObjectFromForm(form, 'extraBody');
|
|
752
|
+
const imageCapability = draftImageCapability(form);
|
|
753
|
+
setDraftProbeFeedback({ status: 'running', durationMs: null });
|
|
754
|
+
setDraftProbeRecord(null);
|
|
755
|
+
if ([name, providerType, providerModelId, endpoint, apiKey].some((value) => !value.trim()) ||
|
|
756
|
+
contextWindowTokens === null ||
|
|
757
|
+
rpmLimit === null ||
|
|
758
|
+
tpmLimit === null ||
|
|
759
|
+
concurrencyLimit === null ||
|
|
760
|
+
inputPrice === null ||
|
|
761
|
+
outputPrice === null) {
|
|
762
|
+
setDraftProbeFeedback({
|
|
763
|
+
status: 'failed',
|
|
764
|
+
durationMs: 0,
|
|
765
|
+
errorMessage: t('common.formError.requiredMissing'),
|
|
766
|
+
});
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
if (extraBody === null) {
|
|
770
|
+
setDraftProbeFeedback({
|
|
771
|
+
status: 'failed',
|
|
772
|
+
durationMs: 0,
|
|
773
|
+
errorMessage: t('common.formError.invalidJson'),
|
|
774
|
+
});
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
const draftBody = {
|
|
778
|
+
name,
|
|
779
|
+
providerType,
|
|
780
|
+
providerModelId,
|
|
781
|
+
endpoint,
|
|
782
|
+
apiKey,
|
|
783
|
+
contextWindowTokens,
|
|
784
|
+
rpm: { limit: rpmLimit },
|
|
785
|
+
tpm: { limit: tpmLimit },
|
|
786
|
+
concurrency: { limit: concurrencyLimit },
|
|
787
|
+
autoConcurrency: form.has('autoConcurrency'),
|
|
788
|
+
pricing: { inputPerMillion: inputPrice, outputPerMillion: outputPrice },
|
|
789
|
+
capabilities: { image: imageCapability },
|
|
790
|
+
extraBody,
|
|
791
|
+
};
|
|
792
|
+
const draftSignature = projectModelCreateConnectivitySignature(draftBody);
|
|
793
|
+
draftProbeMutation.mutate(draftBody, {
|
|
794
|
+
onSuccess: (result) => {
|
|
795
|
+
const currentResult = newModelFormRef.current
|
|
796
|
+
? readProjectModelCreatePayload(newModelFormRef.current, 'enable')
|
|
797
|
+
: null;
|
|
798
|
+
if (!currentResult?.ok || projectModelCreateConnectivitySignature(currentResult.body) !== draftSignature) {
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
setDraftProbeFeedback({
|
|
802
|
+
status: result.status === 'success' ? 'success' : 'failed',
|
|
803
|
+
durationMs: result.durationMs,
|
|
804
|
+
errorMessage: result.error,
|
|
805
|
+
});
|
|
806
|
+
setDraftProbeRecord({
|
|
807
|
+
status: result.status,
|
|
808
|
+
probedAt: result.probedAt,
|
|
809
|
+
error: result.error,
|
|
810
|
+
signature: draftSignature,
|
|
811
|
+
});
|
|
812
|
+
},
|
|
813
|
+
onError: (error) => {
|
|
814
|
+
setDraftProbeRecord(null);
|
|
815
|
+
setDraftProbeFeedback({
|
|
816
|
+
status: 'failed',
|
|
817
|
+
durationMs: Date.now() - startedAt,
|
|
818
|
+
errorMessage: getApiErrorMessage(error),
|
|
819
|
+
});
|
|
820
|
+
},
|
|
821
|
+
});
|
|
822
|
+
};
|
|
823
|
+
const handleNewSubmit = (event) => {
|
|
824
|
+
event.preventDefault();
|
|
825
|
+
if (createMutation.isPending || draftProbeMutation.isPending)
|
|
826
|
+
return;
|
|
827
|
+
const submitter = event.nativeEvent.submitter;
|
|
828
|
+
const intent = submitter instanceof HTMLElement && submitter.dataset.modelSubmitIntent === 'draft' ? 'draft' : 'enable';
|
|
829
|
+
const result = readProjectModelCreatePayload(event.currentTarget, intent);
|
|
830
|
+
if (!result.ok) {
|
|
831
|
+
setSubmitError(result.error === 'required'
|
|
832
|
+
? t('common.formError.requiredMissing')
|
|
833
|
+
: result.error === 'json'
|
|
834
|
+
? t('common.formError.invalidJson')
|
|
835
|
+
: t('common.formError.invalidNumber'));
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
if (isProjectNameTaken(result.body.name, projectModels)) {
|
|
839
|
+
setSubmitError(nameTakenMessage);
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
setSubmitError(null);
|
|
843
|
+
setPendingNewIntent(intent);
|
|
844
|
+
const currentSignature = projectModelCreateConnectivitySignature(result.body);
|
|
845
|
+
const createBody = draftProbeRecord && draftProbeRecord.signature === currentSignature
|
|
846
|
+
? {
|
|
847
|
+
...result.body,
|
|
848
|
+
initialProbe: {
|
|
849
|
+
status: draftProbeRecord.status,
|
|
850
|
+
probedAt: draftProbeRecord.probedAt,
|
|
851
|
+
error: draftProbeRecord.error,
|
|
852
|
+
},
|
|
853
|
+
}
|
|
854
|
+
: result.body;
|
|
855
|
+
createMutation.mutate(createBody, {
|
|
856
|
+
onSuccess: () => router.push(`/models`),
|
|
857
|
+
onError: (error) => {
|
|
858
|
+
const message = getApiErrorMessage(error);
|
|
859
|
+
setSubmitError(message === 'model_name_taken' ? nameTakenMessage : (message ?? t('common.loadFailedRefresh')));
|
|
860
|
+
},
|
|
861
|
+
onSettled: () => setPendingNewIntent(null),
|
|
862
|
+
});
|
|
863
|
+
};
|
|
864
|
+
const headerProbePending = isNew ? draftProbeMutation.isPending : probeMutation.isPending;
|
|
865
|
+
const headerProbeFeedback = isNew ? draftProbeFeedback : probeFeedback;
|
|
866
|
+
const headerProbeDisabled = isNew ? draftProbeMutation.isPending : !model.id || probeMutation.isPending;
|
|
867
|
+
const headerProbeAction = isNew ? testDraftConnectivity : testConnectivity;
|
|
868
|
+
if (waitingForCopy) {
|
|
869
|
+
return (_jsx(Main, { className: "gap-0 bg-muted/35 p-0", children: _jsx("div", { className: "mx-auto w-full max-w-[1440px] px-4 pb-24 pt-6 sm:px-6 lg:px-8", "data-testid": "model-new-page", children: copyLoading ? _jsx(DetailPageSkeleton, {}) : null }) }));
|
|
870
|
+
}
|
|
871
|
+
return (_jsxs(Main, { className: "gap-0 bg-muted/35 p-0", children: [_jsxs("div", { className: "mx-auto w-full max-w-[1440px] px-4 pb-24 pt-6 sm:px-6 lg:px-8", "data-testid": isNew ? 'model-new-page' : 'model-edit-page', children: [_jsxs("div", { className: "mb-6 flex flex-col gap-4 xl:flex-row xl:items-start xl:justify-between", children: [_jsxs("div", { className: "min-w-0", children: [_jsxs("div", { className: "mb-1 font-mono text-[11.5px] text-muted-foreground", children: [_jsx(Link, { className: "hover:text-foreground", href: `/models`, children: t('models.title') }), _jsx("span", { className: "px-1.5", children: "/" }), _jsx("span", { className: "text-foreground", children: isNew ? t('models.create') : readOnly ? t('models.form.detail') : t('models.form.edit') })] }), _jsx("h1", { className: "text-[26px] font-semibold", children: isNew ? t('models.create') : model.name }), !isNew && (_jsxs("div", { className: "mt-2 flex flex-wrap items-center gap-2", children: [_jsx(SourceAndStatus, { model: model }), _jsxs("span", { className: "font-mono text-xs text-muted-foreground", children: [model.provider, " \u00B7 ", model.providerModelId, " \u00B7 ", t('models.form.updated'), ' ', formatDateTime(model.lastUpdated)] })] }))] }), _jsxs("div", { className: "flex flex-col items-start gap-2 xl:items-end", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(Button, { asChild: true, variant: "outline", size: "sm", className: "h-9", children: _jsx(Link, { href: `/models`, children: isNew ? t('common.cancel') : t('common.back') }) }), !isNew && isEditable && model.id && (_jsx(Button, { asChild: true, variant: "outline", size: "sm", className: "h-9", title: t('models.action.copyHelp'), children: _jsxs(Link, { href: `/models/new?copyFrom=${model.id}`, "aria-label": t('models.action.copy'), children: [_jsx(CopyPlus, { className: "size-4" }), t('models.action.copy')] }) })), _jsxs(Button, { type: "button", variant: "outline", size: "sm", className: "h-9", onClick: headerProbeAction, disabled: headerProbeDisabled, "aria-busy": headerProbePending, children: [headerProbePending ? _jsx(Loader2, { className: "size-4 animate-spin" }) : _jsx(Cable, { className: "size-4" }), headerProbePending ? t('models.probe.running') : t('models.action.test')] }), isNew ? (_jsxs(_Fragment, { children: [_jsxs(Button, { type: "submit", form: "project-model-new-form", variant: "outline", size: "sm", className: "h-9", "data-model-submit-intent": "draft", disabled: createMutation.isPending || draftProbeMutation.isPending || newNameTaken, "aria-busy": pendingNewIntent === 'draft', children: [pendingNewIntent === 'draft' ? (_jsx(Loader2, { className: "size-4 animate-spin" })) : (_jsx(Save, { className: "size-4" })), t('models.form.saveDraft')] }), _jsxs(Button, { type: "submit", form: "project-model-new-form", size: "sm", className: "h-9", "data-model-submit-intent": "enable", "data-testid": "model-new-submit", disabled: createMutation.isPending || draftProbeMutation.isPending || newNameTaken, "aria-busy": pendingNewIntent === 'enable', children: [pendingNewIntent === 'enable' ? (_jsx(Loader2, { className: "size-4 animate-spin" })) : (_jsx(Check, { className: "size-4" })), t('models.form.saveAndEnable')] })] })) : isEditable ? (_jsxs(_Fragment, { children: [_jsxs(Button, { type: "button", variant: "outline", size: "sm", className: "h-9", disabled: editDirty || updateMutation.isPending, onClick: toggleModelStatus, children: [_jsx(KeyRound, { className: "size-4" }), model.status === 'disabled' ? t('models.action.enable') : t('models.action.disable')] }), _jsxs(Button, { type: "button", variant: "destructive", size: "sm", className: "h-9", disabled: editDirty || referencesQuery.isLoading || updateMutation.isPending || deleteMutation.isPending, onClick: () => setDeleteOpen(true), children: [_jsx(Trash2, { className: "size-4" }), t('models.action.delete')] })] })) : null] }), _jsx(ModelProbeStatus, { feedback: headerProbeFeedback, className: "w-full xl:w-[380px]" })] })] }), isNew ? (_jsxs("form", { id: "project-model-new-form", ref: newModelFormRef, onSubmit: handleNewSubmit, onInput: refreshDraftProbeFreshness, onChange: refreshDraftProbeFreshness, className: "space-y-4", children: [_jsx(ModelPresetQuickFill, { selectedKey: quickFillDraft?.key, disabled: createMutation.isPending, onApply: applyQuickFillDraft }), submitError && (_jsx("div", { className: "rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive", children: submitError })), _jsx(BasicSection, { mode: mode, useDefaults: useDefaults, model: model, readOnly: readOnly, nameError: activeNameError, onNameChange: setNewNameDraft }), _jsx(CredentialSection, { mode: mode, useDefaults: useDefaults, model: model, readOnly: readOnly, projectId: projectId, initialApiKey: newApiKeySeed }), _jsx(CapabilitiesSection, { mode: mode, useDefaults: useDefaults, model: model, readOnly: readOnly }), _jsx(QuotaSection, { mode: mode, useDefaults: useDefaults, model: liveModel, readOnly: readOnly }), _jsx(PricingSection, { useDefaults: useDefaults, model: model, readOnly: readOnly }), _jsx(TestConnectivitySection, { feedback: draftProbeFeedback, isTesting: draftProbeMutation.isPending, onTest: testDraftConnectivity })] }, newFormVersion)) : (_jsxs("form", { id: "project-model-edit-form", ref: editModelFormRef, onSubmit: handleEditSubmit, onInput: scheduleEditDirtyRefresh, onChange: scheduleEditDirtyRefresh, className: "grid gap-5 xl:grid-cols-[minmax(0,1fr)_380px]", children: [_jsxs("div", { className: "space-y-4", children: [submitError && (_jsx("div", { className: "rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive", children: submitError })), readOnly && _jsx(ReadonlyNotice, {}), _jsx(BasicSection, { mode: mode, useDefaults: useDefaults, model: model, readOnly: readOnly, nameError: activeNameError, onNameChange: setEditNameDraft, onDraftChange: scheduleEditDirtyRefresh }), _jsx(CredentialSection, { mode: mode, useDefaults: useDefaults, model: model, readOnly: readOnly, projectId: projectId, onDraftChange: scheduleEditDirtyRefresh, onApiKeyEdited: () => {
|
|
872
|
+
setApiKeyEdited(true);
|
|
873
|
+
scheduleEditDirtyRefresh();
|
|
874
|
+
} }), _jsx(CapabilitiesSection, { mode: mode, useDefaults: useDefaults, model: model, readOnly: readOnly, onDraftChange: scheduleEditDirtyRefresh }), _jsx(QuotaSection, { mode: mode, useDefaults: useDefaults, model: liveModel, readOnly: readOnly }), _jsx(PricingSection, { useDefaults: useDefaults, model: model, readOnly: readOnly })] }), _jsxs("aside", { className: "space-y-4", children: [_jsx(UsagePanel, { model: liveModel }), _jsx(ReferencePanel, { references: references, loading: referencesQuery.isLoading }), isEditable && (_jsx(DangerPanel, { model: model, references: references, pending: updateMutation.isPending || deleteMutation.isPending, disabled: editDirty || referencesQuery.isLoading, onToggleStatus: toggleModelStatus, onDelete: () => setDeleteOpen(true) }))] })] }, `${model.id}-${editDraftVersion}`))] }), isNew && (_jsx("div", { className: "fixed bottom-0 left-0 right-0 z-20 border-t bg-background/95 px-4 py-3 backdrop-blur supports-[backdrop-filter]:bg-background/75 md:left-[var(--sidebar-width)]", children: _jsx("div", { className: "mx-auto flex max-w-[1440px] justify-end", children: _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(Button, { asChild: true, variant: "outline", size: "sm", children: _jsx(Link, { href: `/models`, children: t('common.cancel') }) }), _jsxs(Button, { type: "submit", form: "project-model-new-form", variant: "outline", size: "sm", "data-model-submit-intent": "draft", disabled: createMutation.isPending || draftProbeMutation.isPending || newNameTaken, "aria-busy": pendingNewIntent === 'draft', children: [pendingNewIntent === 'draft' ? (_jsx(Loader2, { className: "size-4 animate-spin" })) : (_jsx(Save, { className: "size-4" })), t('models.form.saveDraft')] }), _jsxs(Button, { type: "submit", form: "project-model-new-form", size: "sm", "data-model-submit-intent": "enable", disabled: createMutation.isPending || draftProbeMutation.isPending || newNameTaken, "aria-busy": pendingNewIntent === 'enable', children: [pendingNewIntent === 'enable' ? (_jsx(Loader2, { className: "size-4 animate-spin" })) : (_jsx(Check, { className: "size-4" })), t('models.form.saveAndEnable')] })] }) }) })), !isNew && isEditable && (_jsx("div", { className: "fixed bottom-0 left-0 right-0 z-20 border-t bg-background/95 px-4 py-3 backdrop-blur supports-[backdrop-filter]:bg-background/75 md:left-[var(--sidebar-width)]", children: _jsx("div", { className: "mx-auto flex max-w-[1440px] justify-end", children: _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(Button, { type: "button", variant: "outline", size: "sm", disabled: !editDirty || updateMutation.isPending, onClick: resetEditDraft, children: t('models.form.cancelChanges') }), _jsxs(Button, { type: "submit", form: "project-model-edit-form", size: "sm", disabled: !editDirty || updateMutation.isPending || editNameTaken, "aria-busy": updateMutation.isPending, children: [updateMutation.isPending ? (_jsx(Loader2, { className: "size-4 animate-spin" })) : (_jsx(Save, { className: "size-4" })), t('models.form.saveChanges')] })] }) }) })), _jsx(Dialog, { open: deleteOpen, onOpenChange: setDeleteOpen, children: _jsxs(DialogContent, { children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: deleteBlocked ? t('models.form.deleteBlockedTitle') : t('models.deleteDialogTitle') }), _jsx(DialogDescription, { children: deleteBlocked ? t('models.form.deleteBlockedDescription') : t('models.deleteDialogDescription') })] }), _jsxs("div", { className: "space-y-2", children: [_jsxs("div", { className: cn('rounded-md border p-3 text-sm', deleteBlocked ? 'border-destructive/30 bg-destructive/5 text-destructive' : 'bg-muted/45'), children: [_jsx("div", { className: "text-xs font-medium text-muted-foreground", children: deleteBlocked ? t('models.form.activeReferences') : t('models.deleteDialogTarget') }), _jsx("div", { className: "mt-1 font-medium", children: model.name }), deleteBlocked && _jsx("div", { className: "mt-1 text-xs", children: t('models.form.deleteBlockedHelp') })] }), deleteBlocked && (_jsx("div", { className: "grid gap-2 sm:grid-cols-2", children: Object.keys(MODEL_REFERENCE_LABEL_KEYS).map((key) => (_jsxs("div", { className: "flex items-center justify-between rounded-md border p-2 text-sm", children: [_jsx("span", { children: t(MODEL_REFERENCE_LABEL_KEYS[key]) }), _jsx("span", { className: "font-mono text-xs", children: references[key] })] }, key))) }))] }), _jsxs("div", { className: "flex justify-end gap-2", children: [_jsxs(Button, { type: "button", variant: "outline", onClick: () => setDeleteOpen(false), children: [_jsx(X, { className: "size-4" }), deleteBlocked ? t('common.close') : t('common.cancel')] }), !deleteBlocked && (_jsxs(Button, { type: "button", variant: "destructive", disabled: deleteMutation.isPending, onClick: confirmDeleteModel, children: [deleteMutation.isPending ? _jsx(Loader2, { className: "size-4 animate-spin" }) : null, t('models.deleteDialogConfirm')] }))] })] }) })] }));
|
|
875
|
+
}
|
|
876
|
+
//# sourceMappingURL=model-form-page.js.map
|