__init__.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. from typing import Optional
  2. from pydantic import Field, NonNegativeInt
  3. from pydantic_settings import BaseSettings
  4. class HostedOpenAiConfig(BaseSettings):
  5. """
  6. Hosted OpenAI service config
  7. """
  8. HOSTED_OPENAI_API_KEY: Optional[str] = Field(
  9. description='',
  10. default=None,
  11. )
  12. HOSTED_OPENAI_API_BASE: Optional[str] = Field(
  13. description='',
  14. default=None,
  15. )
  16. HOSTED_OPENAI_API_ORGANIZATION: Optional[str] = Field(
  17. description='',
  18. default=None,
  19. )
  20. HOSTED_OPENAI_TRIAL_ENABLED: bool = Field(
  21. description='',
  22. default=False,
  23. )
  24. HOSTED_OPENAI_TRIAL_MODELS: str = Field(
  25. description='',
  26. default='gpt-3.5-turbo,'
  27. 'gpt-3.5-turbo-1106,'
  28. 'gpt-3.5-turbo-instruct,'
  29. 'gpt-3.5-turbo-16k,'
  30. 'gpt-3.5-turbo-16k-0613,'
  31. 'gpt-3.5-turbo-0613,'
  32. 'gpt-3.5-turbo-0125,'
  33. 'text-davinci-003',
  34. )
  35. HOSTED_OPENAI_QUOTA_LIMIT: NonNegativeInt = Field(
  36. description='',
  37. default=200,
  38. )
  39. HOSTED_OPENAI_PAID_ENABLED: bool = Field(
  40. description='',
  41. default=False,
  42. )
  43. HOSTED_OPENAI_PAID_MODELS: str = Field(
  44. description='',
  45. default='gpt-4,'
  46. 'gpt-4-turbo-preview,'
  47. 'gpt-4-turbo-2024-04-09,'
  48. 'gpt-4-1106-preview,'
  49. 'gpt-4-0125-preview,'
  50. 'gpt-3.5-turbo,'
  51. 'gpt-3.5-turbo-16k,'
  52. 'gpt-3.5-turbo-16k-0613,'
  53. 'gpt-3.5-turbo-1106,'
  54. 'gpt-3.5-turbo-0613,'
  55. 'gpt-3.5-turbo-0125,'
  56. 'gpt-3.5-turbo-instruct,'
  57. 'text-davinci-003',
  58. )
  59. class HostedAzureOpenAiConfig(BaseSettings):
  60. """
  61. Hosted OpenAI service config
  62. """
  63. HOSTED_AZURE_OPENAI_ENABLED: bool = Field(
  64. description='',
  65. default=False,
  66. )
  67. HOSTED_AZURE_OPENAI_API_KEY: Optional[str] = Field(
  68. description='',
  69. default=None,
  70. )
  71. HOSTED_AZURE_OPENAI_API_BASE: Optional[str] = Field(
  72. description='',
  73. default=None,
  74. )
  75. HOSTED_AZURE_OPENAI_QUOTA_LIMIT: NonNegativeInt = Field(
  76. description='',
  77. default=200,
  78. )
  79. class HostedAnthropicConfig(BaseSettings):
  80. """
  81. Hosted Azure OpenAI service config
  82. """
  83. HOSTED_ANTHROPIC_API_BASE: Optional[str] = Field(
  84. description='',
  85. default=None,
  86. )
  87. HOSTED_ANTHROPIC_API_KEY: Optional[str] = Field(
  88. description='',
  89. default=None,
  90. )
  91. HOSTED_ANTHROPIC_TRIAL_ENABLED: bool = Field(
  92. description='',
  93. default=False,
  94. )
  95. HOSTED_ANTHROPIC_QUOTA_LIMIT: NonNegativeInt = Field(
  96. description='',
  97. default=600000,
  98. )
  99. HOSTED_ANTHROPIC_PAID_ENABLED: bool = Field(
  100. description='',
  101. default=False,
  102. )
  103. class HostedMinmaxConfig(BaseSettings):
  104. """
  105. Hosted Minmax service config
  106. """
  107. HOSTED_MINIMAX_ENABLED: bool = Field(
  108. description='',
  109. default=False,
  110. )
  111. class HostedSparkConfig(BaseSettings):
  112. """
  113. Hosted Spark service config
  114. """
  115. HOSTED_SPARK_ENABLED: bool = Field(
  116. description='',
  117. default=False,
  118. )
  119. class HostedZhipuAIConfig(BaseSettings):
  120. """
  121. Hosted Minmax service config
  122. """
  123. HOSTED_ZHIPUAI_ENABLED: bool = Field(
  124. description='',
  125. default=False,
  126. )
  127. class HostedModerationConfig(BaseSettings):
  128. """
  129. Hosted Moderation service config
  130. """
  131. HOSTED_MODERATION_ENABLED: bool = Field(
  132. description='',
  133. default=False,
  134. )
  135. HOSTED_MODERATION_PROVIDERS: str = Field(
  136. description='',
  137. default='',
  138. )
  139. class HostedFetchAppTemplateConfig(BaseSettings):
  140. """
  141. Hosted Moderation service config
  142. """
  143. HOSTED_FETCH_APP_TEMPLATES_MODE: str = Field(
  144. description='the mode for fetching app templates,'
  145. ' default to remote,'
  146. ' available values: remote, db, builtin',
  147. default='remote',
  148. )
  149. HOSTED_FETCH_APP_TEMPLATES_REMOTE_DOMAIN: str = Field(
  150. description='the domain for fetching remote app templates',
  151. default='https://tmpl.dify.ai',
  152. )
  153. class HostedServiceConfig(
  154. # place the configs in alphabet order
  155. HostedAnthropicConfig,
  156. HostedAzureOpenAiConfig,
  157. HostedFetchAppTemplateConfig,
  158. HostedMinmaxConfig,
  159. HostedOpenAiConfig,
  160. HostedSparkConfig,
  161. HostedZhipuAIConfig,
  162. # moderation
  163. HostedModerationConfig,
  164. ):
  165. pass