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.5KB

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