Files
chaos-api/web/default/src/features/playground/constants.ts
T
Calcium-Ion 469d3747af fix: defaut ui triage (#4802)
* fix: theme-aware payment paths, auto-group validation, route guards, perf group filtering

- Add common.ThemeAwarePath to generate correct redirect URLs based on
  active theme (default vs classic), replacing hardcoded /console/* paths
  in 7 controllers and service/quota.go (#4765)
- Validate auto-group availability against getUserGroups before defaulting
  form values; playground falls back to 'default' group when 'auto' is
  unavailable (#4796, #4799)
- Enforce HeaderNavModules settings in rankings route (frontend + backend
  API) and SidebarModulesAdmin in playground route to block direct URL
  access when features are disabled (#4704, #4512)
- Filter perf_metrics API response to only include currently configured
  groups, hiding stale data from deleted groups (#4790)
- Preserve query params (pay=success/fail) in /console/topup → /wallet
  frontend redirect

* fix: update hero section text and localization strings for clarity
2026-05-12 16:47:02 +08:00

102 lines
2.9 KiB
TypeScript
Vendored

/*
Copyright (C) 2023-2026 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import type { PlaygroundConfig, ParameterEnabled } from './types'
// Message constants
export const MESSAGE_ROLES = {
USER: 'user',
ASSISTANT: 'assistant',
SYSTEM: 'system',
} as const
export const MESSAGE_STATUS = {
LOADING: 'loading',
STREAMING: 'streaming',
COMPLETE: 'complete',
ERROR: 'error',
} as const
// API endpoints
export const API_ENDPOINTS = {
CHAT_COMPLETIONS: '/pg/chat/completions',
USER_MODELS: '/api/user/models',
USER_GROUPS: '/api/user/self/groups',
} as const
// Default group — uses 'default' as the safe fallback; auto-group is
// only selected when the backend confirms it is available for the user.
export const DEFAULT_GROUP = 'default' as const
// Default configuration
export const DEFAULT_CONFIG: PlaygroundConfig = {
model: 'gpt-4o',
group: DEFAULT_GROUP,
temperature: 0.7,
top_p: 1,
max_tokens: 4096,
frequency_penalty: 0,
presence_penalty: 0,
seed: null,
stream: true,
}
export const DEFAULT_PARAMETER_ENABLED: ParameterEnabled = {
temperature: true,
top_p: true,
max_tokens: false,
frequency_penalty: true,
presence_penalty: true,
seed: false,
}
// Storage keys
export const STORAGE_KEYS = {
CONFIG: 'playground_config',
MESSAGES: 'playground_messages',
PARAMETER_ENABLED: 'playground_parameter_enabled',
} as const
// Error messages
export const ERROR_MESSAGES = {
API_REQUEST_ERROR: 'Request error occurred',
NETWORK_ERROR: 'Network connection failed or server not responding',
PARSE_ERROR: 'Error parsing response data',
STREAM_START_ERROR: 'Error establishing connection',
CONNECTION_CLOSED: 'Connection closed',
INTERRUPTED: 'Generation was interrupted',
} as const
// Message action button styles
export const MESSAGE_ACTION_BUTTON_STYLES = {
BASE: 'size-7 text-muted-foreground hover:text-foreground',
DELETE: 'size-7 text-muted-foreground hover:text-destructive',
ICON: 'size-4',
} as const
// Message action labels
export const MESSAGE_ACTION_LABELS = {
COPY: 'Copy',
COPIED: 'Copied!',
REGENERATE: 'Regenerate',
EDIT: 'Edit',
DELETE: 'Delete',
NO_CONTENT: 'No content to copy',
WAIT_GENERATION: 'Please wait for the current generation to complete',
} as const