provider.tsx 2.2 KB

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