common.ts 6.0 KB

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