common.ts 5.7 KB

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