OpenAISettings.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <script setup lang="ts">
  2. import type { Settings } from '@/api/settings'
  3. const data: Settings = inject('data')!
  4. const errors: Record<string, Record<string, string>> = inject('errors') as Record<string, Record<string, string>>
  5. const models = shallowRef([
  6. {
  7. value: 'gpt-4o-mini',
  8. },
  9. {
  10. value: 'gpt-4o',
  11. },
  12. {
  13. value: 'gpt-4-1106-preview',
  14. },
  15. {
  16. value: 'gpt-4',
  17. },
  18. {
  19. value: 'gpt-4-32k',
  20. },
  21. {
  22. value: 'gpt-3.5-turbo',
  23. },
  24. ])
  25. </script>
  26. <template>
  27. <AForm layout="vertical">
  28. <AFormItem
  29. :label="$gettext('Model')"
  30. :validate-status="errors?.openai?.model ? 'error' : ''"
  31. :help="errors?.openai?.model === 'safety_text'
  32. ? $gettext('The model name should only contain letters, unicode, numbers, hyphens, dashes, colons, and dots.')
  33. : ''"
  34. >
  35. <AAutoComplete
  36. v-model:value="data.openai.model"
  37. :options="models"
  38. />
  39. </AFormItem>
  40. <AFormItem
  41. :label="$gettext('API Base Url')"
  42. :validate-status="errors?.openai?.base_url ? 'error' : ''"
  43. :help="errors?.openai?.base_url === 'url'
  44. ? $gettext('The url is invalid.')
  45. : $gettext('To use a local large model, deploy it with ollama, vllm or imdeploy. '
  46. + 'They provide an OpenAI-compatible API endpoint, so just set the baseUrl to your local API.')"
  47. >
  48. <AInput
  49. v-model:value="data.openai.base_url"
  50. :placeholder="$gettext('Leave blank for the default: https://api.openai.com/')"
  51. />
  52. </AFormItem>
  53. <AFormItem
  54. :label="$gettext('API Proxy')"
  55. :validate-status="errors?.openai?.proxy ? 'error' : ''"
  56. :help="errors?.openai?.proxy === 'url'
  57. ? $gettext('The url is invalid.')
  58. : ''"
  59. >
  60. <AInput
  61. v-model:value="data.openai.proxy"
  62. placeholder="http://127.0.0.1:1087"
  63. />
  64. </AFormItem>
  65. <AFormItem
  66. :label="$gettext('API Token')"
  67. :validate-status="errors?.openai?.token ? 'error' : ''"
  68. :help="errors?.openai?.token === 'safety_text'
  69. ? $gettext('Token is not valid')
  70. : ''"
  71. >
  72. <AInputPassword v-model:value="data.openai.token" />
  73. </AFormItem>
  74. <AFormItem
  75. :label="$gettext('API Type')"
  76. :validate-status="errors?.openai?.apt_type ? 'error' : ''"
  77. >
  78. <ASelect v-model:value="data.openai.api_type">
  79. <ASelectOption value="OPEN_AI">
  80. OpenAI
  81. </ASelectOption>
  82. <ASelectOption value="AZURE">
  83. Azure
  84. </ASelectOption>
  85. </ASelect>
  86. </AFormItem>
  87. </AForm>
  88. </template>
  89. <style lang="less" scoped>
  90. </style>