constants.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // ========== 消息相关常量 ==========
  2. export const MESSAGE_STATUS = {
  3. LOADING: 'loading',
  4. INCOMPLETE: 'incomplete',
  5. COMPLETE: 'complete',
  6. ERROR: 'error',
  7. };
  8. export const MESSAGE_ROLES = {
  9. USER: 'user',
  10. ASSISTANT: 'assistant',
  11. SYSTEM: 'system',
  12. };
  13. // 默认消息示例
  14. export const DEFAULT_MESSAGES = [
  15. {
  16. role: MESSAGE_ROLES.USER,
  17. id: '2',
  18. createAt: 1715676751919,
  19. content: '你好',
  20. },
  21. {
  22. role: MESSAGE_ROLES.ASSISTANT,
  23. id: '3',
  24. createAt: 1715676751919,
  25. content: '你好,请问有什么可以帮助您的吗?',
  26. reasoningContent: '',
  27. isReasoningExpanded: false,
  28. },
  29. ];
  30. // ========== UI 相关常量 ==========
  31. export const DEBUG_TABS = {
  32. PREVIEW: 'preview',
  33. REQUEST: 'request',
  34. RESPONSE: 'response',
  35. };
  36. // ========== API 相关常量 ==========
  37. export const API_ENDPOINTS = {
  38. CHAT_COMPLETIONS: '/pg/chat/completions',
  39. USER_MODELS: '/api/user/models',
  40. USER_GROUPS: '/api/user/self/groups',
  41. };
  42. // ========== 配置默认值 ==========
  43. export const DEFAULT_CONFIG = {
  44. inputs: {
  45. model: 'gpt-4o',
  46. group: '',
  47. temperature: 0.7,
  48. top_p: 1,
  49. max_tokens: 4096,
  50. frequency_penalty: 0,
  51. presence_penalty: 0,
  52. seed: null,
  53. stream: true,
  54. imageEnabled: false,
  55. imageUrls: [''],
  56. },
  57. parameterEnabled: {
  58. temperature: true,
  59. top_p: true,
  60. max_tokens: false,
  61. frequency_penalty: true,
  62. presence_penalty: true,
  63. seed: false,
  64. },
  65. systemPrompt: '',
  66. showDebugPanel: false,
  67. customRequestMode: false,
  68. customRequestBody: '',
  69. };
  70. // ========== 正则表达式 ==========
  71. export const THINK_TAG_REGEX = /<think>([\s\S]*?)<\/think>/g;
  72. // ========== 错误消息 ==========
  73. export const ERROR_MESSAGES = {
  74. NO_TEXT_CONTENT: '此消息没有可复制的文本内容',
  75. INVALID_MESSAGE_TYPE: '无法复制此类型的消息内容',
  76. COPY_FAILED: '复制失败,请手动选择文本复制',
  77. COPY_HTTPS_REQUIRED: '复制功能需要 HTTPS 环境,请手动复制',
  78. BROWSER_NOT_SUPPORTED: '浏览器不支持复制功能,请手动复制',
  79. JSON_PARSE_ERROR: '自定义请求体格式错误,请检查JSON格式',
  80. API_REQUEST_ERROR: '请求发生错误',
  81. NETWORK_ERROR: '网络连接失败或服务器无响应',
  82. };
  83. // ========== 存储键名 ==========
  84. export const STORAGE_KEYS = {
  85. CONFIG: 'playground_config',
  86. MESSAGES: 'playground_messages',
  87. };