provider.tsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { ProviderConfig } from "@/app/store";
  2. import { ProviderConfigProps } from "../types";
  3. import { ListItem, PasswordInput } from "../../ui-lib";
  4. import Locale from "@/app/locales";
  5. import { REMOTE_API_HOST } from "@/app/constant";
  6. export function OpenAIProviderConfig(
  7. props: ProviderConfigProps<ProviderConfig["openai"]>,
  8. ) {
  9. return (
  10. <>
  11. <ListItem
  12. title={Locale.Settings.Endpoint.Title}
  13. subTitle={Locale.Settings.Endpoint.SubTitle}
  14. >
  15. <input
  16. type="text"
  17. value={props.config.endpoint}
  18. placeholder={REMOTE_API_HOST}
  19. onChange={(e) =>
  20. props.updateConfig(
  21. (config) => (config.endpoint = e.currentTarget.value),
  22. )
  23. }
  24. ></input>
  25. </ListItem>
  26. <ListItem
  27. title={Locale.Settings.Token.Title}
  28. subTitle={Locale.Settings.Token.SubTitle}
  29. >
  30. <PasswordInput
  31. value={props.config.apiKey}
  32. type="text"
  33. placeholder={Locale.Settings.Token.Placeholder}
  34. onChange={(e) => {
  35. props.updateConfig(
  36. (config) => (config.apiKey = e.currentTarget.value),
  37. );
  38. }}
  39. />
  40. </ListItem>
  41. <ListItem
  42. title={Locale.Settings.CustomModel.Title}
  43. subTitle={Locale.Settings.CustomModel.SubTitle}
  44. >
  45. <input
  46. type="text"
  47. value={props.config.customModels}
  48. placeholder="model1,model2,model3"
  49. onChange={(e) =>
  50. props.updateConfig(
  51. (config) => (config.customModels = e.currentTarget.value),
  52. )
  53. }
  54. ></input>
  55. </ListItem>
  56. <ListItem title="自动拉取可用模型" subTitle="尝试拉取所有可用模型">
  57. <input
  58. type="checkbox"
  59. checked={props.config.autoFetchModels}
  60. onChange={(e) =>
  61. props.updateConfig(
  62. (config) => (config.autoFetchModels = e.currentTarget.checked),
  63. )
  64. }
  65. ></input>
  66. </ListItem>
  67. </>
  68. );
  69. }