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. is_password_set: boolean
  21. interface_language?: string
  22. interface_theme?: string
  23. timezone?: string
  24. last_login_at?: string
  25. last_active_at?: string
  26. last_login_ip?: string
  27. created_at?: string
  28. }
  29. export type UserProfileOriginResponse = {
  30. json: () => Promise<UserProfileResponse>
  31. bodyUsed: boolean
  32. headers: any
  33. }
  34. export type LangGeniusVersionResponse = {
  35. current_version: string
  36. latest_version: string
  37. version: string
  38. release_date: string
  39. release_notes: string
  40. can_auto_update: boolean
  41. current_env: string
  42. }
  43. export type TenantInfoResponse = {
  44. name: string
  45. created_at: string
  46. providers: Array<{
  47. provider: string
  48. provider_name: string
  49. token_is_set: boolean
  50. is_valid: boolean
  51. token_is_valid: boolean
  52. }>
  53. in_trail: boolean
  54. trial_end_reason: null | 'trial_exceeded' | 'using_custom'
  55. }
  56. export type Member = Pick<UserProfileResponse, 'id' | 'name' | 'email' | 'last_login_at' | 'last_active_at' | 'created_at'> & {
  57. avatar: string
  58. status: 'pending' | 'active' | 'banned' | 'closed'
  59. role: 'owner' | 'admin' | 'editor' | 'normal' | 'dataset_operator'
  60. }
  61. export enum ProviderName {
  62. OPENAI = 'openai',
  63. AZURE_OPENAI = 'azure_openai',
  64. ANTHROPIC = 'anthropic',
  65. Replicate = 'replicate',
  66. HuggingfaceHub = 'huggingface_hub',
  67. MiniMax = 'minimax',
  68. Spark = 'spark',
  69. Tongyi = 'tongyi',
  70. ChatGLM = 'chatglm',
  71. }
  72. export type ProviderAzureToken = {
  73. openai_api_base?: string
  74. openai_api_key?: string
  75. }
  76. export type ProviderAnthropicToken = {
  77. anthropic_api_key?: string
  78. }
  79. export type ProviderTokenType = {
  80. [ProviderName.OPENAI]: string
  81. [ProviderName.AZURE_OPENAI]: ProviderAzureToken
  82. [ProviderName.ANTHROPIC]: ProviderAnthropicToken
  83. }
  84. export type Provider = {
  85. [Name in ProviderName]: {
  86. provider_name: Name
  87. } & {
  88. provider_type: 'custom' | 'system'
  89. is_valid: boolean
  90. is_enabled: boolean
  91. last_used: string
  92. token?: string | ProviderAzureToken | ProviderAnthropicToken
  93. }
  94. }[ProviderName]
  95. export type ProviderHosted = Provider & {
  96. quota_type: string
  97. quota_limit: number
  98. quota_used: number
  99. }
  100. export type AccountIntegrate = {
  101. provider: 'google' | 'github'
  102. created_at: number
  103. is_bound: boolean
  104. link: string
  105. }
  106. export type IWorkspace = {
  107. id: string
  108. name: string
  109. plan: string
  110. status: string
  111. created_at: number
  112. current: boolean
  113. }
  114. export type ICurrentWorkspace = Omit<IWorkspace, 'current'> & {
  115. role: 'owner' | 'admin' | 'editor' | 'dataset_operator' | 'normal'
  116. providers: Provider[]
  117. in_trail: boolean
  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>