You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

common.ts 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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. waterCrawl = 'watercrawl',
  161. }
  162. export type FirecrawlConfig = {
  163. api_key: string
  164. base_url: string
  165. }
  166. export type WatercrawlConfig = {
  167. api_key: string
  168. base_url: string
  169. }
  170. export type DataSourceItem = {
  171. id: string
  172. category: DataSourceCategory
  173. provider: DataSourceProvider
  174. disabled: boolean
  175. created_at: number
  176. updated_at: number
  177. }
  178. export type DataSources = {
  179. sources: DataSourceItem[]
  180. }
  181. export type GithubRepo = {
  182. stargazers_count: number
  183. }
  184. export type PluginProvider = {
  185. tool_name: string
  186. is_enabled: boolean
  187. credentials: {
  188. api_key: string
  189. } | null
  190. }
  191. export type FileUploadConfigResponse = {
  192. batch_count_limit: number
  193. image_file_size_limit?: number | string // default is 10MB
  194. file_size_limit: number // default is 15MB
  195. audio_file_size_limit?: number // default is 50MB
  196. video_file_size_limit?: number // default is 100MB
  197. workflow_file_upload_limit?: number // default is 10
  198. }
  199. export type InvitationResult = {
  200. status: 'success'
  201. email: string
  202. url: string
  203. } | {
  204. status: 'failed'
  205. email: string
  206. message: string
  207. }
  208. export type InvitationResponse = CommonResponse & {
  209. invitation_results: InvitationResult[]
  210. }
  211. export type ApiBasedExtension = {
  212. id?: string
  213. name?: string
  214. api_endpoint?: string
  215. api_key?: string
  216. }
  217. export type CodeBasedExtensionForm = {
  218. type: string
  219. label: I18nText
  220. variable: string
  221. required: boolean
  222. options: { label: I18nText; value: string }[]
  223. default: string
  224. placeholder: string
  225. max_length?: number
  226. }
  227. export type CodeBasedExtensionItem = {
  228. name: string
  229. label: any
  230. form_schema: CodeBasedExtensionForm[]
  231. }
  232. export type CodeBasedExtension = {
  233. module: string
  234. data: CodeBasedExtensionItem[]
  235. }
  236. export type ExternalDataTool = {
  237. type?: string
  238. label?: string
  239. icon?: string
  240. icon_background?: string
  241. variable?: string
  242. enabled?: boolean
  243. config?: {
  244. api_based_extension_id?: string
  245. } & Partial<Record<string, any>>
  246. }
  247. export type ModerateResponse = {
  248. flagged: boolean
  249. text: string
  250. }
  251. export type ModerationService = (
  252. url: string,
  253. body: {
  254. app_id: string
  255. text: string
  256. }
  257. ) => Promise<ModerateResponse>