common.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. import type { I18nText } from '@/utils/language'
  2. export type CommonResponse = {
  3. result: 'success' | 'fail'
  4. }
  5. export type OauthResponse = {
  6. redirect_url: string
  7. }
  8. export type SetupStatusResponse = {
  9. step: 'finished' | 'not_started'
  10. setup_at?: Date
  11. }
  12. export type UserProfileResponse = {
  13. id: string
  14. name: string
  15. email: string
  16. avatar: string
  17. is_password_set: boolean
  18. interface_language?: string
  19. interface_theme?: string
  20. timezone?: string
  21. last_login_at?: string
  22. last_login_ip?: string
  23. created_at?: string
  24. }
  25. export type UserProfileOriginResponse = {
  26. json: () => Promise<UserProfileResponse>
  27. bodyUsed: boolean
  28. headers: any
  29. }
  30. export type LangGeniusVersionResponse = {
  31. current_version: string
  32. latest_version: string
  33. version: string
  34. release_date: string
  35. release_notes: string
  36. can_auto_update: boolean
  37. current_env: string
  38. }
  39. export type TenantInfoResponse = {
  40. name: string
  41. created_at: string
  42. providers: Array<{
  43. provider: string
  44. provider_name: string
  45. token_is_set: boolean
  46. is_valid: boolean
  47. token_is_valid: boolean
  48. }>
  49. in_trail: boolean
  50. trial_end_reason: null | 'trial_exceeded' | 'using_custom'
  51. }
  52. export type Member = Pick<UserProfileResponse, 'id' | 'name' | 'email' | 'last_login_at' | 'created_at'> & {
  53. avatar: string
  54. status: 'pending' | 'active' | 'banned' | 'closed'
  55. role: 'owner' | 'admin' | 'normal'
  56. }
  57. export enum ProviderName {
  58. OPENAI = 'openai',
  59. AZURE_OPENAI = 'azure_openai',
  60. ANTHROPIC = 'anthropic',
  61. Replicate = 'replicate',
  62. HuggingfaceHub = 'huggingface_hub',
  63. MiniMax = 'minimax',
  64. Spark = 'spark',
  65. Tongyi = 'tongyi',
  66. ChatGLM = 'chatglm',
  67. }
  68. export type ProviderAzureToken = {
  69. openai_api_base?: string
  70. openai_api_key?: string
  71. }
  72. export type ProviderAnthropicToken = {
  73. anthropic_api_key?: string
  74. }
  75. export type ProviderTokenType = {
  76. [ProviderName.OPENAI]: string
  77. [ProviderName.AZURE_OPENAI]: ProviderAzureToken
  78. [ProviderName.ANTHROPIC]: ProviderAnthropicToken
  79. }
  80. export type Provider = {
  81. [Name in ProviderName]: {
  82. provider_name: Name
  83. } & {
  84. provider_type: 'custom' | 'system'
  85. is_valid: boolean
  86. is_enabled: boolean
  87. last_used: string
  88. token?: string | ProviderAzureToken | ProviderAnthropicToken
  89. }
  90. }[ProviderName]
  91. export type ProviderHosted = Provider & {
  92. quota_type: string
  93. quota_limit: number
  94. quota_used: number
  95. }
  96. export type AccountIntegrate = {
  97. provider: 'google' | 'github'
  98. created_at: number
  99. is_bound: boolean
  100. link: string
  101. }
  102. export type IWorkspace = {
  103. id: string
  104. name: string
  105. plan: string
  106. status: string
  107. created_at: number
  108. current: boolean
  109. }
  110. export type ICurrentWorkspace = Omit<IWorkspace, 'current'> & {
  111. role: 'normal' | 'admin' | 'owner'
  112. providers: Provider[]
  113. in_trail: boolean
  114. trial_end_reason?: string
  115. custom_config?: {
  116. remove_webapp_brand?: boolean
  117. replace_webapp_logo?: string
  118. }
  119. }
  120. export type DataSourceNotionPage = {
  121. page_icon: null | {
  122. type: string | null
  123. url: string | null
  124. emoji: string | null
  125. }
  126. page_id: string
  127. page_name: string
  128. parent_id: string
  129. type: string
  130. is_bound: boolean
  131. }
  132. export type NotionPage = DataSourceNotionPage & {
  133. workspace_id: string
  134. }
  135. export type DataSourceNotionPageMap = Record<string, DataSourceNotionPage & { workspace_id: string }>
  136. export type DataSourceNotionWorkspace = {
  137. workspace_name: string
  138. workspace_id: string
  139. workspace_icon: string | null
  140. total?: number
  141. pages: DataSourceNotionPage[]
  142. }
  143. export type DataSourceNotionWorkspaceMap = Record<string, DataSourceNotionWorkspace>
  144. export type DataSourceNotion = {
  145. id: string
  146. provider: string
  147. is_bound: boolean
  148. source_info: DataSourceNotionWorkspace
  149. }
  150. export type GithubRepo = {
  151. stargazers_count: number
  152. }
  153. export type PluginProvider = {
  154. tool_name: string
  155. is_enabled: boolean
  156. credentials: {
  157. api_key: string
  158. } | null
  159. }
  160. export type FileUploadConfigResponse = {
  161. file_size_limit: number
  162. batch_count_limit: number
  163. image_file_size_limit?: number | string
  164. }
  165. export type InvitationResult = {
  166. status: 'success'
  167. email: string
  168. url: string
  169. } | {
  170. status: 'failed'
  171. email: string
  172. message: string
  173. }
  174. export type InvitationResponse = CommonResponse & {
  175. invitation_results: InvitationResult[]
  176. }
  177. export type ApiBasedExtension = {
  178. id?: string
  179. name?: string
  180. api_endpoint?: string
  181. api_key?: string
  182. }
  183. export type CodeBasedExtensionForm = {
  184. type: string
  185. label: I18nText
  186. variable: string
  187. required: boolean
  188. options: { label: I18nText; value: string }[]
  189. default: string
  190. placeholder: string
  191. max_length?: number
  192. }
  193. export type CodeBasedExtensionItem = {
  194. name: string
  195. label: any
  196. form_schema: CodeBasedExtensionForm[]
  197. }
  198. export type CodeBasedExtension = {
  199. module: string
  200. data: CodeBasedExtensionItem[]
  201. }
  202. export type ExternalDataTool = {
  203. type?: string
  204. label?: string
  205. icon?: string
  206. icon_background?: string
  207. variable?: string
  208. enabled?: boolean
  209. config?: {
  210. api_based_extension_id?: string
  211. } & Partial<Record<string, any>>
  212. }
  213. export type ModerateResponse = {
  214. flagged: boolean
  215. text: string
  216. }
  217. export type ModerationService = (
  218. url: string,
  219. body: {
  220. app_id: string
  221. text: string
  222. }
  223. ) => Promise<ModerateResponse>