Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

133 строки
3.4 KiB

  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 support@quantumnous.com
  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. // 默认消息示例 - 使用函数生成以支持 i18n
  27. export const getDefaultMessages = (t) => [
  28. {
  29. role: MESSAGE_ROLES.USER,
  30. id: '2',
  31. createAt: 1715676751919,
  32. content: t('默认用户消息'),
  33. },
  34. {
  35. role: MESSAGE_ROLES.ASSISTANT,
  36. id: '3',
  37. createAt: 1715676751919,
  38. content: t('默认助手消息'),
  39. reasoningContent: '',
  40. isReasoningExpanded: false,
  41. },
  42. ];
  43. // 保留旧的导出以保持向后兼容
  44. export const DEFAULT_MESSAGES = [
  45. {
  46. role: MESSAGE_ROLES.USER,
  47. id: '2',
  48. createAt: 1715676751919,
  49. content: 'Hello',
  50. },
  51. {
  52. role: MESSAGE_ROLES.ASSISTANT,
  53. id: '3',
  54. createAt: 1715676751919,
  55. content: 'Hello! How can I help you today?',
  56. reasoningContent: '',
  57. isReasoningExpanded: false,
  58. },
  59. ];
  60. // ========== UI 相关常量 ==========
  61. export const DEBUG_TABS = {
  62. PREVIEW: 'preview',
  63. REQUEST: 'request',
  64. RESPONSE: 'response',
  65. };
  66. // ========== API 相关常量 ==========
  67. export const API_ENDPOINTS = {
  68. CHAT_COMPLETIONS: '/pg/chat/completions',
  69. USER_MODELS: '/api/user/models',
  70. USER_GROUPS: '/api/user/self/groups',
  71. };
  72. // ========== 配置默认值 ==========
  73. export const DEFAULT_CONFIG = {
  74. inputs: {
  75. model: 'gpt-4o',
  76. group: '',
  77. channelId: 0,
  78. temperature: 0.7,
  79. top_p: 1,
  80. max_tokens: 4096,
  81. frequency_penalty: 0,
  82. presence_penalty: 0,
  83. seed: null,
  84. stream: true,
  85. imageEnabled: false,
  86. imageUrls: [''],
  87. },
  88. parameterEnabled: {
  89. temperature: true,
  90. top_p: true,
  91. max_tokens: false,
  92. frequency_penalty: true,
  93. presence_penalty: true,
  94. seed: false,
  95. },
  96. systemPrompt: '',
  97. showDebugPanel: false,
  98. customRequestMode: false,
  99. customRequestBody: '',
  100. };
  101. // ========== 正则表达式 ==========
  102. export const THINK_TAG_REGEX = /<think>([\s\S]*?)<\/think>/g;
  103. // ========== 错误消息 ==========
  104. export const ERROR_MESSAGES = {
  105. NO_TEXT_CONTENT: '此消息没有可复制的文本内容',
  106. INVALID_MESSAGE_TYPE: '无法复制此类型的消息内容',
  107. COPY_FAILED: '复制失败,请手动选择文本复制',
  108. COPY_HTTPS_REQUIRED: '复制功能需要 HTTPS 环境,请手动复制',
  109. BROWSER_NOT_SUPPORTED: '浏览器不支持复制功能,请手动复制',
  110. JSON_PARSE_ERROR: '自定义请求体格式错误,请检查JSON格式',
  111. API_REQUEST_ERROR: '请求发生错误',
  112. NETWORK_ERROR: '网络连接失败或服务器无响应',
  113. };
  114. // ========== 存储键名 ==========
  115. export const STORAGE_KEYS = {
  116. CONFIG: 'playground_config',
  117. MESSAGES: 'playground_messages',
  118. };