common.ts 5.2 KB

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