common.ts 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. export type CommonResponse = {
  2. result: 'success' | 'fail'
  3. }
  4. export type OauthResponse = {
  5. redirect_url: string
  6. }
  7. export type SetupStatusResponse = {
  8. step: 'finished' | 'not_started'
  9. setup_at?: Date
  10. }
  11. export type UserProfileResponse = {
  12. id: string
  13. name: string
  14. email: string
  15. avatar: string
  16. is_password_set: boolean
  17. interface_language?: string
  18. interface_theme?: string
  19. timezone?: string
  20. last_login_at?: string
  21. last_login_ip?: string
  22. created_at?: string
  23. }
  24. export type UserProfileOriginResponse = {
  25. json: () => Promise<UserProfileResponse>
  26. bodyUsed: boolean
  27. headers: any
  28. }
  29. export type LangGeniusVersionResponse = {
  30. current_version: string
  31. latest_version: string
  32. version: string
  33. release_date: string
  34. release_notes: string
  35. can_auto_update: boolean
  36. current_env: string
  37. }
  38. export type TenantInfoResponse = {
  39. name: string
  40. created_at: string
  41. providers: Array<{
  42. provider: string
  43. provider_name: string
  44. token_is_set: boolean
  45. is_valid: boolean
  46. token_is_valid: boolean
  47. }>
  48. in_trail: boolean
  49. trial_end_reason: null | 'trial_exceeded' | 'using_custom'
  50. }
  51. export type Member = Pick<UserProfileResponse, 'id' | 'name' | 'email' | 'last_login_at' | 'created_at'> & {
  52. avatar: string
  53. status: 'pending' | 'active' | 'banned' | 'closed'
  54. role: 'owner' | 'admin' | 'normal'
  55. }
  56. export enum ProviderName {
  57. OPENAI = 'openai',
  58. AZURE_OPENAI = 'azure_openai',
  59. ANTHROPIC = 'anthropic',
  60. Replicate = 'replicate',
  61. HuggingfaceHub = 'huggingface_hub',
  62. MiniMax = 'minimax',
  63. Spark = 'spark',
  64. Tongyi = 'tongyi',
  65. ChatGLM = 'chatglm',
  66. }
  67. export type ProviderAzureToken = {
  68. openai_api_base?: string
  69. openai_api_key?: string
  70. }
  71. export type ProviderAnthropicToken = {
  72. anthropic_api_key?: string
  73. }
  74. export type ProviderTokenType = {
  75. [ProviderName.OPENAI]: string
  76. [ProviderName.AZURE_OPENAI]: ProviderAzureToken
  77. [ProviderName.ANTHROPIC]: ProviderAnthropicToken
  78. }
  79. export type Provider = {
  80. [Name in ProviderName]: {
  81. provider_name: Name
  82. } & {
  83. provider_type: 'custom' | 'system'
  84. is_valid: boolean
  85. is_enabled: boolean
  86. last_used: string
  87. token?: string | ProviderAzureToken | ProviderAnthropicToken
  88. }
  89. }[ProviderName]
  90. export type ProviderHosted = Provider & {
  91. quota_type: string
  92. quota_limit: number
  93. quota_used: number
  94. }
  95. export type AccountIntegrate = {
  96. provider: 'google' | 'github'
  97. created_at: number
  98. is_bound: boolean
  99. link: string
  100. }
  101. export type IWorkspace = {
  102. id: string
  103. name: string
  104. plan: string
  105. status: string
  106. created_at: number
  107. current: boolean
  108. }
  109. export type ICurrentWorkspace = Omit<IWorkspace, 'current'> & {
  110. role: 'normal' | 'admin' | 'owner'
  111. providers: Provider[]
  112. in_trail: boolean
  113. trial_end_reason?: string
  114. }
  115. export type DataSourceNotionPage = {
  116. page_icon: null | {
  117. type: string | null
  118. url: string | null
  119. emoji: string | null
  120. }
  121. page_id: string
  122. page_name: string
  123. parent_id: string
  124. type: string
  125. is_bound: boolean
  126. }
  127. export type NotionPage = DataSourceNotionPage & {
  128. workspace_id: string
  129. }
  130. export type DataSourceNotionPageMap = Record<string, DataSourceNotionPage & { workspace_id: string }>
  131. export type DataSourceNotionWorkspace = {
  132. workspace_name: string
  133. workspace_id: string
  134. workspace_icon: string | null
  135. total?: number
  136. pages: DataSourceNotionPage[]
  137. }
  138. export type DataSourceNotionWorkspaceMap = Record<string, DataSourceNotionWorkspace>
  139. export type DataSourceNotion = {
  140. id: string
  141. provider: string
  142. is_bound: boolean
  143. source_info: DataSourceNotionWorkspace
  144. }
  145. export type GithubRepo = {
  146. stargazers_count: number
  147. }
  148. export type PluginProvider = {
  149. tool_name: string
  150. is_enabled: boolean
  151. credentials: {
  152. api_key: string
  153. } | null
  154. }
  155. export type FileUploadConfigResponse = {
  156. file_size_limit: number
  157. batch_count_limit: number
  158. image_file_size_limit?: number | string
  159. }
  160. export type DocumentsLimitResponse = {
  161. documents_count: number
  162. documents_limit: number
  163. }
  164. export type InvitationResult = {
  165. status: 'success'
  166. email: string
  167. url: string
  168. } | {
  169. status: 'failed'
  170. email: string
  171. message: string
  172. }
  173. export type InvitationResponse = CommonResponse & {
  174. invitation_results: InvitationResult[]
  175. }
  176. export type ApiBasedExtension = {
  177. id?: string
  178. name?: string
  179. api_endpoint?: string
  180. api_key?: string
  181. }
  182. export type I18nText = {
  183. 'en-US': string
  184. 'zh-Hans': string
  185. }
  186. export type CodeBasedExtensionForm = {
  187. type: string
  188. label: I18nText
  189. variable: string
  190. required: boolean
  191. options: { label: I18nText; value: string }[]
  192. default: string
  193. placeholder: string
  194. max_length?: number
  195. }
  196. export type CodeBasedExtensionItem = {
  197. name: string
  198. label: I18nText
  199. form_schema: CodeBasedExtensionForm[]
  200. }
  201. export type CodeBasedExtension = {
  202. module: string
  203. data: CodeBasedExtensionItem[]
  204. }
  205. export type ExternalDataTool = {
  206. type?: string
  207. label?: string
  208. icon?: string
  209. icon_background?: string
  210. variable?: string
  211. enabled?: boolean
  212. config?: {
  213. api_based_extension_id?: string
  214. } & Partial<Record<string, any>>
  215. }
  216. export type ModerateResponse = {
  217. flagged: boolean
  218. text: string
  219. }
  220. export type ModerationService = (
  221. url: string,
  222. body: {
  223. app_id: string
  224. text: string
  225. }
  226. ) => Promise<ModerateResponse>