common.ts 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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. trial_end_reason?: string
  119. custom_config?: {
  120. remove_webapp_brand?: boolean
  121. replace_webapp_logo?: string
  122. }
  123. }
  124. export type DataSourceNotionPage = {
  125. page_icon: null | {
  126. type: string | null
  127. url: string | null
  128. emoji: string | null
  129. }
  130. page_id: string
  131. page_name: string
  132. parent_id: string
  133. type: string
  134. is_bound: boolean
  135. }
  136. export type NotionPage = DataSourceNotionPage & {
  137. workspace_id: string
  138. }
  139. export type DataSourceNotionPageMap = Record<string, DataSourceNotionPage & { workspace_id: string }>
  140. export type DataSourceNotionWorkspace = {
  141. workspace_name: string
  142. workspace_id: string
  143. workspace_icon: string | null
  144. total?: number
  145. pages: DataSourceNotionPage[]
  146. }
  147. export type DataSourceNotionWorkspaceMap = Record<string, DataSourceNotionWorkspace>
  148. export type DataSourceNotion = {
  149. id: string
  150. provider: string
  151. is_bound: boolean
  152. source_info: DataSourceNotionWorkspace
  153. }
  154. export enum DataSourceCategory {
  155. website = 'website',
  156. }
  157. export enum DataSourceProvider {
  158. fireCrawl = 'firecrawl',
  159. jinaReader = 'jinareader',
  160. }
  161. export type FirecrawlConfig = {
  162. api_key: string
  163. base_url: string
  164. }
  165. export type DataSourceItem = {
  166. id: string
  167. category: DataSourceCategory
  168. provider: DataSourceProvider
  169. disabled: boolean
  170. created_at: number
  171. updated_at: number
  172. }
  173. export type DataSources = {
  174. sources: DataSourceItem[]
  175. }
  176. export type GithubRepo = {
  177. stargazers_count: number
  178. }
  179. export type PluginProvider = {
  180. tool_name: string
  181. is_enabled: boolean
  182. credentials: {
  183. api_key: string
  184. } | null
  185. }
  186. export type FileUploadConfigResponse = {
  187. batch_count_limit: number
  188. image_file_size_limit?: number | string // default is 10MB
  189. file_size_limit: number // default is 15MB
  190. audio_file_size_limit?: number // default is 50MB
  191. video_file_size_limit?: number // default is 100MB
  192. workflow_file_upload_limit?: number // default is 10
  193. }
  194. export type InvitationResult = {
  195. status: 'success'
  196. email: string
  197. url: string
  198. } | {
  199. status: 'failed'
  200. email: string
  201. message: string
  202. }
  203. export type InvitationResponse = CommonResponse & {
  204. invitation_results: InvitationResult[]
  205. }
  206. export type ApiBasedExtension = {
  207. id?: string
  208. name?: string
  209. api_endpoint?: string
  210. api_key?: string
  211. }
  212. export type CodeBasedExtensionForm = {
  213. type: string
  214. label: I18nText
  215. variable: string
  216. required: boolean
  217. options: { label: I18nText; value: string }[]
  218. default: string
  219. placeholder: string
  220. max_length?: number
  221. }
  222. export type CodeBasedExtensionItem = {
  223. name: string
  224. label: any
  225. form_schema: CodeBasedExtensionForm[]
  226. }
  227. export type CodeBasedExtension = {
  228. module: string
  229. data: CodeBasedExtensionItem[]
  230. }
  231. export type ExternalDataTool = {
  232. type?: string
  233. label?: string
  234. icon?: string
  235. icon_background?: string
  236. variable?: string
  237. enabled?: boolean
  238. config?: {
  239. api_based_extension_id?: string
  240. } & Partial<Record<string, any>>
  241. }
  242. export type ModerateResponse = {
  243. flagged: boolean
  244. text: string
  245. }
  246. export type ModerationService = (
  247. url: string,
  248. body: {
  249. app_id: string
  250. text: string
  251. }
  252. ) => Promise<ModerateResponse>