openai.tsx 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import { ProviderEnum } from '../declarations'
  2. import type { ProviderConfig } from '../declarations'
  3. import { OpenaiBlack, OpenaiText, OpenaiTransparent } from '@/app/components/base/icons/src/public/llm'
  4. import { IS_CE_EDITION } from '@/config'
  5. const config: ProviderConfig = {
  6. selector: {
  7. name: {
  8. 'en': 'OpenAI',
  9. 'zh-Hans': 'OpenAI',
  10. },
  11. icon: <OpenaiBlack className='w-full h-full' />,
  12. },
  13. item: {
  14. key: ProviderEnum.openai,
  15. titleIcon: {
  16. 'en': <OpenaiText className='h-5' />,
  17. 'zh-Hans': <OpenaiText className='h-5' />,
  18. },
  19. subTitleIcon: <OpenaiBlack className='w-6 h-6' />,
  20. desc: {
  21. 'en': 'Models provided by OpenAI, such as GPT-3.5-Turbo and GPT-4.',
  22. 'zh-Hans': 'OpenAI 提供的模型,例如 GPT-3.5-Turbo 和 GPT-4。',
  23. },
  24. bgColor: 'bg-gray-200',
  25. },
  26. modal: {
  27. key: ProviderEnum.openai,
  28. title: {
  29. 'en': 'OpenAI',
  30. 'zh-Hans': 'OpenAI',
  31. },
  32. icon: <OpenaiTransparent className='w-6 h-6' />,
  33. link: {
  34. href: 'https://platform.openai.com/account/api-keys',
  35. label: {
  36. 'en': 'Get your API key from OpenAI',
  37. 'zh-Hans': '从 OpenAI 获取 API Key',
  38. },
  39. },
  40. validateKeys: ['openai_api_key'],
  41. fields: [
  42. {
  43. type: 'text',
  44. key: 'openai_api_key',
  45. required: true,
  46. label: {
  47. 'en': 'API Key',
  48. 'zh-Hans': 'API Key',
  49. },
  50. placeholder: {
  51. 'en': 'Enter your API key here',
  52. 'zh-Hans': '在此输入您的 API Key',
  53. },
  54. },
  55. {
  56. type: 'text',
  57. key: 'openai_organization',
  58. required: false,
  59. label: {
  60. 'en': 'Organization ID',
  61. 'zh-Hans': '组织 ID',
  62. },
  63. placeholder: {
  64. 'en': 'Enter your Organization ID(Optional)',
  65. 'zh-Hans': '在此输入您的组织 ID(选填)',
  66. },
  67. },
  68. ...(
  69. IS_CE_EDITION
  70. ? [{
  71. type: 'text',
  72. key: 'openai_api_base',
  73. required: false,
  74. label: {
  75. 'en': 'Custom API Domain',
  76. 'zh-Hans': '自定义 API 域名',
  77. },
  78. placeholder: {
  79. 'en': 'Enter your API domain, eg: https://example.com/xxx(Optional)',
  80. 'zh-Hans': '在此输入您的 API 域名,如:https://example.com/xxx(选填)',
  81. },
  82. help: {
  83. 'en': 'You can configure your server compatible with the OpenAI API specification, or proxy mirror address',
  84. 'zh-Hans': '可配置您的兼容 OpenAI API 规范的服务器,或者代理镜像地址',
  85. },
  86. }]
  87. : []
  88. ),
  89. ],
  90. },
  91. }
  92. export default config