__init__.py 4.5 KB

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