playground.constants.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. Copyright (C) 2025 QuantumNous
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU Affero General Public License as
  5. published by the Free Software Foundation, either version 3 of the
  6. License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU Affero General Public License for more details.
  11. You should have received a copy of the GNU Affero General Public License
  12. along with this program. If not, see <https://www.gnu.org/licenses/>.
  13. For commercial licensing, please contact [email protected]
  14. */
  15. export const MESSAGE_STATUS = {
  16. LOADING: 'loading',
  17. INCOMPLETE: 'incomplete',
  18. COMPLETE: 'complete',
  19. ERROR: 'error',
  20. };
  21. export const MESSAGE_ROLES = {
  22. USER: 'user',
  23. ASSISTANT: 'assistant',
  24. SYSTEM: 'system',
  25. };
  26. // 默认消息示例
  27. export const DEFAULT_MESSAGES = [
  28. {
  29. role: MESSAGE_ROLES.USER,
  30. id: '2',
  31. createAt: 1715676751919,
  32. content: '你好',
  33. },
  34. {
  35. role: MESSAGE_ROLES.ASSISTANT,
  36. id: '3',
  37. createAt: 1715676751919,
  38. content: '你好,请问有什么可以帮助您的吗?',
  39. reasoningContent: '',
  40. isReasoningExpanded: false,
  41. },
  42. ];
  43. // ========== UI 相关常量 ==========
  44. export const DEBUG_TABS = {
  45. PREVIEW: 'preview',
  46. REQUEST: 'request',
  47. RESPONSE: 'response',
  48. };
  49. // ========== API 相关常量 ==========
  50. export const API_ENDPOINTS = {
  51. CHAT_COMPLETIONS: '/pg/chat/completions',
  52. USER_MODELS: '/api/user/models',
  53. USER_GROUPS: '/api/user/self/groups',
  54. };
  55. // ========== 配置默认值 ==========
  56. export const DEFAULT_CONFIG = {
  57. inputs: {
  58. model: 'gpt-4o',
  59. group: '',
  60. temperature: 0.7,
  61. top_p: 1,
  62. max_tokens: 4096,
  63. frequency_penalty: 0,
  64. presence_penalty: 0,
  65. seed: null,
  66. stream: true,
  67. imageEnabled: false,
  68. imageUrls: [''],
  69. },
  70. parameterEnabled: {
  71. temperature: true,
  72. top_p: true,
  73. max_tokens: false,
  74. frequency_penalty: true,
  75. presence_penalty: true,
  76. seed: false,
  77. },
  78. systemPrompt: '',
  79. showDebugPanel: false,
  80. customRequestMode: false,
  81. customRequestBody: '',
  82. };
  83. // ========== 正则表达式 ==========
  84. export const THINK_TAG_REGEX = /<think>([\s\S]*?)<\/think>/g;
  85. // ========== 错误消息 ==========
  86. export const ERROR_MESSAGES = {
  87. NO_TEXT_CONTENT: '此消息没有可复制的文本内容',
  88. INVALID_MESSAGE_TYPE: '无法复制此类型的消息内容',
  89. COPY_FAILED: '复制失败,请手动选择文本复制',
  90. COPY_HTTPS_REQUIRED: '复制功能需要 HTTPS 环境,请手动复制',
  91. BROWSER_NOT_SUPPORTED: '浏览器不支持复制功能,请手动复制',
  92. JSON_PARSE_ERROR: '自定义请求体格式错误,请检查JSON格式',
  93. API_REQUEST_ERROR: '请求发生错误',
  94. NETWORK_ERROR: '网络连接失败或服务器无响应',
  95. };
  96. // ========== 存储键名 ==========
  97. export const STORAGE_KEYS = {
  98. CONFIG: 'playground_config',
  99. MESSAGES: 'playground_messages',
  100. };