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 14KB

2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
2 vuotta sitten
Introduce Plugins (#13836) Signed-off-by: yihong0618 <zouzou0208@gmail.com> Signed-off-by: -LAN- <laipz8200@outlook.com> Signed-off-by: xhe <xw897002528@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: takatost <takatost@gmail.com> Co-authored-by: kurokobo <kuro664@gmail.com> Co-authored-by: Novice Lee <novicelee@NoviPro.local> Co-authored-by: zxhlyh <jasonapring2015@outlook.com> Co-authored-by: AkaraChen <akarachen@outlook.com> Co-authored-by: Yi <yxiaoisme@gmail.com> Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: JzoNg <jzongcode@gmail.com> Co-authored-by: twwu <twwu@dify.ai> Co-authored-by: Hiroshi Fujita <fujita-h@users.noreply.github.com> Co-authored-by: AkaraChen <85140972+AkaraChen@users.noreply.github.com> Co-authored-by: NFish <douxc512@gmail.com> Co-authored-by: Wu Tianwei <30284043+WTW0313@users.noreply.github.com> Co-authored-by: 非法操作 <hjlarry@163.com> Co-authored-by: Novice <857526207@qq.com> Co-authored-by: Hiroki Nagai <82458324+nagaihiroki-git@users.noreply.github.com> Co-authored-by: Gen Sato <52241300+halogen22@users.noreply.github.com> Co-authored-by: eux <euxuuu@gmail.com> Co-authored-by: huangzhuo1949 <167434202+huangzhuo1949@users.noreply.github.com> Co-authored-by: huangzhuo <huangzhuo1@xiaomi.com> Co-authored-by: lotsik <lotsik@mail.ru> Co-authored-by: crazywoola <100913391+crazywoola@users.noreply.github.com> Co-authored-by: nite-knite <nkCoding@gmail.com> Co-authored-by: Jyong <76649700+JohnJyong@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: gakkiyomi <gakkiyomi@aliyun.com> Co-authored-by: CN-P5 <heibai2006@gmail.com> Co-authored-by: CN-P5 <heibai2006@qq.com> Co-authored-by: Chuehnone <1897025+chuehnone@users.noreply.github.com> Co-authored-by: yihong <zouzou0208@gmail.com> Co-authored-by: Kevin9703 <51311316+Kevin9703@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com> Co-authored-by: Boris Feld <lothiraldan@gmail.com> Co-authored-by: mbo <himabo@gmail.com> Co-authored-by: mabo <mabo@aeyes.ai> Co-authored-by: Warren Chen <warren.chen830@gmail.com> Co-authored-by: JzoNgKVO <27049666+JzoNgKVO@users.noreply.github.com> Co-authored-by: jiandanfeng <chenjh3@wangsu.com> Co-authored-by: zhu-an <70234959+xhdd123321@users.noreply.github.com> Co-authored-by: zhaoqingyu.1075 <zhaoqingyu.1075@bytedance.com> Co-authored-by: 海狸大師 <86974027+yenslife@users.noreply.github.com> Co-authored-by: Xu Song <xusong.vip@gmail.com> Co-authored-by: rayshaw001 <396301947@163.com> Co-authored-by: Ding Jiatong <dingjiatong@gmail.com> Co-authored-by: Bowen Liang <liangbowen@gf.com.cn> Co-authored-by: JasonVV <jasonwangiii@outlook.com> Co-authored-by: le0zh <newlight@qq.com> Co-authored-by: zhuxinliang <zhuxinliang@didiglobal.com> Co-authored-by: k-zaku <zaku99@outlook.jp> Co-authored-by: luckylhb90 <luckylhb90@gmail.com> Co-authored-by: hobo.l <hobo.l@binance.com> Co-authored-by: jiangbo721 <365065261@qq.com> Co-authored-by: 刘江波 <jiangbo721@163.com> Co-authored-by: Shun Miyazawa <34241526+miya@users.noreply.github.com> Co-authored-by: EricPan <30651140+Egfly@users.noreply.github.com> Co-authored-by: crazywoola <427733928@qq.com> Co-authored-by: sino <sino2322@gmail.com> Co-authored-by: Jhvcc <37662342+Jhvcc@users.noreply.github.com> Co-authored-by: lowell <lowell.hu@zkteco.in> Co-authored-by: Boris Polonsky <BorisPolonsky@users.noreply.github.com> Co-authored-by: Ademílson Tonato <ademilsonft@outlook.com> Co-authored-by: Ademílson Tonato <ademilson.tonato@refurbed.com> Co-authored-by: IWAI, Masaharu <iwaim.sub@gmail.com> Co-authored-by: Yueh-Po Peng (Yabi) <94939112+y10ab1@users.noreply.github.com> Co-authored-by: Jason <ggbbddjm@gmail.com> Co-authored-by: Xin Zhang <sjhpzx@gmail.com> Co-authored-by: yjc980121 <3898524+yjc980121@users.noreply.github.com> Co-authored-by: heyszt <36215648+hieheihei@users.noreply.github.com> Co-authored-by: Abdullah AlOsaimi <osaimiacc@gmail.com> Co-authored-by: Abdullah AlOsaimi <189027247+osaimi@users.noreply.github.com> Co-authored-by: Yingchun Lai <laiyingchun@apache.org> Co-authored-by: Hash Brown <hi@xzd.me> Co-authored-by: zuodongxu <192560071+zuodongxu@users.noreply.github.com> Co-authored-by: Masashi Tomooka <tmokmss@users.noreply.github.com> Co-authored-by: aplio <ryo.091219@gmail.com> Co-authored-by: Obada Khalili <54270856+obadakhalili@users.noreply.github.com> Co-authored-by: Nam Vu <zuzoovn@gmail.com> Co-authored-by: Kei YAMAZAKI <1715090+kei-yamazaki@users.noreply.github.com> Co-authored-by: TechnoHouse <13776377+deephbz@users.noreply.github.com> Co-authored-by: Riddhimaan-Senapati <114703025+Riddhimaan-Senapati@users.noreply.github.com> Co-authored-by: MaFee921 <31881301+2284730142@users.noreply.github.com> Co-authored-by: te-chan <t-nakanome@sakura-is.co.jp> Co-authored-by: HQidea <HQidea@users.noreply.github.com> Co-authored-by: Joshbly <36315710+Joshbly@users.noreply.github.com> Co-authored-by: xhe <xw897002528@gmail.com> Co-authored-by: weiwenyan-dev <154779315+weiwenyan-dev@users.noreply.github.com> Co-authored-by: ex_wenyan.wei <ex_wenyan.wei@tcl.com> Co-authored-by: engchina <12236799+engchina@users.noreply.github.com> Co-authored-by: engchina <atjapan2015@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: 呆萌闷油瓶 <253605712@qq.com> Co-authored-by: Kemal <kemalmeler@outlook.com> Co-authored-by: Lazy_Frog <4590648+lazyFrogLOL@users.noreply.github.com> Co-authored-by: Yi Xiao <54782454+YIXIAO0@users.noreply.github.com> Co-authored-by: Steven sun <98230804+Tuyohai@users.noreply.github.com> Co-authored-by: steven <sunzwj@digitalchina.com> Co-authored-by: Kalo Chin <91766386+fdb02983rhy@users.noreply.github.com> Co-authored-by: Katy Tao <34019945+KatyTao@users.noreply.github.com> Co-authored-by: depy <42985524+h4ckdepy@users.noreply.github.com> Co-authored-by: 胡春东 <gycm520@gmail.com> Co-authored-by: Junjie.M <118170653@qq.com> Co-authored-by: MuYu <mr.muzea@gmail.com> Co-authored-by: Naoki Takashima <39912547+takatea@users.noreply.github.com> Co-authored-by: Summer-Gu <37869445+gubinjie@users.noreply.github.com> Co-authored-by: Fei He <droxer.he@gmail.com> Co-authored-by: ybalbert001 <120714773+ybalbert001@users.noreply.github.com> Co-authored-by: Yuanbo Li <ybalbert@amazon.com> Co-authored-by: douxc <7553076+douxc@users.noreply.github.com> Co-authored-by: liuzhenghua <1090179900@qq.com> Co-authored-by: Wu Jiayang <62842862+Wu-Jiayang@users.noreply.github.com> Co-authored-by: Your Name <you@example.com> Co-authored-by: kimjion <45935338+kimjion@users.noreply.github.com> Co-authored-by: AugNSo <song.tiankai@icloud.com> Co-authored-by: llinvokerl <38915183+llinvokerl@users.noreply.github.com> Co-authored-by: liusurong.lsr <liusurong.lsr@alibaba-inc.com> Co-authored-by: Vasu Negi <vasu-negi@users.noreply.github.com> Co-authored-by: Hundredwz <1808096180@qq.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com>
8 kuukautta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. import type { Fetcher } from 'swr'
  2. import { del, get, patch, post, put } from './base'
  3. import type {
  4. AccountIntegrate,
  5. ApiBasedExtension,
  6. CodeBasedExtension,
  7. CommonResponse,
  8. DataSourceNotion,
  9. FileUploadConfigResponse,
  10. ICurrentWorkspace,
  11. IWorkspace,
  12. InitValidateStatusResponse,
  13. InvitationResponse,
  14. LangGeniusVersionResponse,
  15. Member,
  16. ModerateResponse,
  17. OauthResponse,
  18. PluginProvider,
  19. Provider,
  20. ProviderAnthropicToken,
  21. ProviderAzureToken,
  22. SetupStatusResponse,
  23. UserProfileOriginResponse,
  24. } from '@/models/common'
  25. import type {
  26. UpdateOpenAIKeyResponse,
  27. ValidateOpenAIKeyResponse,
  28. } from '@/models/app'
  29. import type {
  30. DefaultModelResponse,
  31. Model,
  32. ModelItem,
  33. ModelLoadBalancingConfig,
  34. ModelParameterRule,
  35. ModelProvider,
  36. ModelTypeEnum,
  37. } from '@/app/components/header/account-setting/model-provider-page/declarations'
  38. import type { RETRIEVE_METHOD } from '@/types/app'
  39. import type { SystemFeatures } from '@/types/feature'
  40. type LoginSuccess = {
  41. result: 'success'
  42. data: { access_token: string; refresh_token: string }
  43. }
  44. type LoginFail = {
  45. result: 'fail'
  46. data: string
  47. code: string
  48. message: string
  49. }
  50. type LoginResponse = LoginSuccess | LoginFail
  51. export const login: Fetcher<LoginResponse, { url: string; body: Record<string, any> }> = ({ url, body }) => {
  52. return post(url, { body }) as Promise<LoginResponse>
  53. }
  54. export const fetchNewToken: Fetcher<CommonResponse & { data: { access_token: string; refresh_token: string } }, { body: Record<string, any> }> = ({ body }) => {
  55. return post('/refresh-token', { body }) as Promise<CommonResponse & { data: { access_token: string; refresh_token: string } }>
  56. }
  57. export const setup: Fetcher<CommonResponse, { body: Record<string, any> }> = ({ body }) => {
  58. return post<CommonResponse>('/setup', { body })
  59. }
  60. export const initValidate: Fetcher<CommonResponse, { body: Record<string, any> }> = ({ body }) => {
  61. return post<CommonResponse>('/init', { body })
  62. }
  63. export const fetchInitValidateStatus = () => {
  64. return get<InitValidateStatusResponse>('/init')
  65. }
  66. export const fetchSetupStatus = () => {
  67. return get<SetupStatusResponse>('/setup')
  68. }
  69. export const fetchUserProfile: Fetcher<UserProfileOriginResponse, { url: string; params: Record<string, any> }> = ({ url, params }) => {
  70. return get<UserProfileOriginResponse>(url, params, { needAllResponseContent: true })
  71. }
  72. export const updateUserProfile: Fetcher<CommonResponse, { url: string; body: Record<string, any> }> = ({ url, body }) => {
  73. return post<CommonResponse>(url, { body })
  74. }
  75. export const logout: Fetcher<CommonResponse, { url: string; params: Record<string, any> }> = ({ url, params }) => {
  76. return get<CommonResponse>(url, params)
  77. }
  78. export const fetchLanggeniusVersion: Fetcher<LangGeniusVersionResponse, { url: string; params: Record<string, any> }> = ({ url, params }) => {
  79. return get<LangGeniusVersionResponse>(url, { params })
  80. }
  81. export const oauth: Fetcher<OauthResponse, { url: string; params: Record<string, any> }> = ({ url, params }) => {
  82. return get<OauthResponse>(url, { params })
  83. }
  84. export const oneMoreStep: Fetcher<CommonResponse, { url: string; body: Record<string, any> }> = ({ url, body }) => {
  85. return post<CommonResponse>(url, { body })
  86. }
  87. export const fetchMembers: Fetcher<{ accounts: Member[] | null }, { url: string; params: Record<string, any> }> = ({ url, params }) => {
  88. return get<{ accounts: Member[] | null }>(url, { params })
  89. }
  90. export const fetchProviders: Fetcher<Provider[] | null, { url: string; params: Record<string, any> }> = ({ url, params }) => {
  91. return get<Provider[] | null>(url, { params })
  92. }
  93. export const validateProviderKey: Fetcher<ValidateOpenAIKeyResponse, { url: string; body: { token: string } }> = ({ url, body }) => {
  94. return post<ValidateOpenAIKeyResponse>(url, { body })
  95. }
  96. export const updateProviderAIKey: Fetcher<UpdateOpenAIKeyResponse, { url: string; body: { token: string | ProviderAzureToken | ProviderAnthropicToken } }> = ({ url, body }) => {
  97. return post<UpdateOpenAIKeyResponse>(url, { body })
  98. }
  99. export const fetchAccountIntegrates: Fetcher<{ data: AccountIntegrate[] | null }, { url: string; params: Record<string, any> }> = ({ url, params }) => {
  100. return get<{ data: AccountIntegrate[] | null }>(url, { params })
  101. }
  102. export const inviteMember: Fetcher<InvitationResponse, { url: string; body: Record<string, any> }> = ({ url, body }) => {
  103. return post<InvitationResponse>(url, { body })
  104. }
  105. export const updateMemberRole: Fetcher<CommonResponse, { url: string; body: Record<string, any> }> = ({ url, body }) => {
  106. return put<CommonResponse>(url, { body })
  107. }
  108. export const deleteMemberOrCancelInvitation: Fetcher<CommonResponse, { url: string }> = ({ url }) => {
  109. return del<CommonResponse>(url)
  110. }
  111. export const fetchFilePreview: Fetcher<{ content: string }, { fileID: string }> = ({ fileID }) => {
  112. return get<{ content: string }>(`/files/${fileID}/preview`)
  113. }
  114. export const fetchCurrentWorkspace: Fetcher<ICurrentWorkspace, { url: string; params: Record<string, any> }> = ({ url, params }) => {
  115. return get<ICurrentWorkspace>(url, { params })
  116. }
  117. export const updateCurrentWorkspace: Fetcher<ICurrentWorkspace, { url: string; body: Record<string, any> }> = ({ url, body }) => {
  118. return post<ICurrentWorkspace>(url, { body })
  119. }
  120. export const fetchWorkspaces: Fetcher<{ workspaces: IWorkspace[] }, { url: string; params: Record<string, any> }> = ({ url, params }) => {
  121. return get<{ workspaces: IWorkspace[] }>(url, { params })
  122. }
  123. export const switchWorkspace: Fetcher<CommonResponse & { new_tenant: IWorkspace }, { url: string; body: Record<string, any> }> = ({ url, body }) => {
  124. return post<CommonResponse & { new_tenant: IWorkspace }>(url, { body })
  125. }
  126. export const updateWorkspaceInfo: Fetcher<ICurrentWorkspace, { url: string; body: Record<string, any> }> = ({ url, body }) => {
  127. return post<ICurrentWorkspace>(url, { body })
  128. }
  129. export const fetchDataSource: Fetcher<{ data: DataSourceNotion[] }, { url: string }> = ({ url }) => {
  130. return get<{ data: DataSourceNotion[] }>(url)
  131. }
  132. export const syncDataSourceNotion: Fetcher<CommonResponse, { url: string }> = ({ url }) => {
  133. return get<CommonResponse>(url)
  134. }
  135. export const updateDataSourceNotionAction: Fetcher<CommonResponse, { url: string }> = ({ url }) => {
  136. return patch<CommonResponse>(url)
  137. }
  138. export const fetchPluginProviders: Fetcher<PluginProvider[] | null, string> = (url) => {
  139. return get<PluginProvider[] | null>(url)
  140. }
  141. export const validatePluginProviderKey: Fetcher<ValidateOpenAIKeyResponse, { url: string; body: { credentials: any } }> = ({ url, body }) => {
  142. return post<ValidateOpenAIKeyResponse>(url, { body })
  143. }
  144. export const updatePluginProviderAIKey: Fetcher<UpdateOpenAIKeyResponse, { url: string; body: { credentials: any } }> = ({ url, body }) => {
  145. return post<UpdateOpenAIKeyResponse>(url, { body })
  146. }
  147. export const invitationCheck: Fetcher<CommonResponse & { is_valid: boolean; data: { workspace_name: string; email: string; workspace_id: string } }, { url: string; params: { workspace_id?: string; email?: string; token: string } }> = ({ url, params }) => {
  148. return get<CommonResponse & { is_valid: boolean; data: { workspace_name: string; email: string; workspace_id: string } }>(url, { params })
  149. }
  150. export const activateMember: Fetcher<LoginResponse, { url: string; body: any }> = ({ url, body }) => {
  151. return post<LoginResponse>(url, { body })
  152. }
  153. export const fetchModelProviders: Fetcher<{ data: ModelProvider[] }, string> = (url) => {
  154. return get<{ data: ModelProvider[] }>(url)
  155. }
  156. export type ModelProviderCredentials = {
  157. credentials?: Record<string, string | undefined | boolean>
  158. load_balancing: ModelLoadBalancingConfig
  159. }
  160. export const fetchModelProviderCredentials: Fetcher<ModelProviderCredentials, string> = (url) => {
  161. return get<ModelProviderCredentials>(url)
  162. }
  163. export const fetchModelLoadBalancingConfig: Fetcher<{
  164. credentials?: Record<string, string | undefined | boolean>
  165. load_balancing: ModelLoadBalancingConfig
  166. }, string> = (url) => {
  167. return get<{
  168. credentials?: Record<string, string | undefined | boolean>
  169. load_balancing: ModelLoadBalancingConfig
  170. }>(url)
  171. }
  172. export const fetchModelProviderModelList: Fetcher<{ data: ModelItem[] }, string> = (url) => {
  173. return get<{ data: ModelItem[] }>(url)
  174. }
  175. export const fetchModelList: Fetcher<{ data: Model[] }, string> = (url) => {
  176. return get<{ data: Model[] }>(url)
  177. }
  178. export const validateModelProvider: Fetcher<ValidateOpenAIKeyResponse, { url: string; body: any }> = ({ url, body }) => {
  179. return post<ValidateOpenAIKeyResponse>(url, { body })
  180. }
  181. export const validateModelLoadBalancingCredentials: Fetcher<ValidateOpenAIKeyResponse, { url: string; body: any }> = ({ url, body }) => {
  182. return post<ValidateOpenAIKeyResponse>(url, { body })
  183. }
  184. export const setModelProvider: Fetcher<CommonResponse, { url: string; body: any }> = ({ url, body }) => {
  185. return post<CommonResponse>(url, { body })
  186. }
  187. export const deleteModelProvider: Fetcher<CommonResponse, { url: string; body?: any }> = ({ url, body }) => {
  188. return del<CommonResponse>(url, { body })
  189. }
  190. export const changeModelProviderPriority: Fetcher<CommonResponse, { url: string; body: any }> = ({ url, body }) => {
  191. return post<CommonResponse>(url, { body })
  192. }
  193. export const setModelProviderModel: Fetcher<CommonResponse, { url: string; body: any }> = ({ url, body }) => {
  194. return post<CommonResponse>(url, { body })
  195. }
  196. export const deleteModelProviderModel: Fetcher<CommonResponse, { url: string }> = ({ url }) => {
  197. return del<CommonResponse>(url)
  198. }
  199. export const getPayUrl: Fetcher<{ url: string }, string> = (url) => {
  200. return get<{ url: string }>(url)
  201. }
  202. export const fetchDefaultModal: Fetcher<{ data: DefaultModelResponse }, string> = (url) => {
  203. return get<{ data: DefaultModelResponse }>(url)
  204. }
  205. export const updateDefaultModel: Fetcher<CommonResponse, { url: string; body: any }> = ({ url, body }) => {
  206. return post<CommonResponse>(url, { body })
  207. }
  208. export const fetchModelParameterRules: Fetcher<{ data: ModelParameterRule[] }, string> = (url) => {
  209. return get<{ data: ModelParameterRule[] }>(url)
  210. }
  211. export const fetchFileUploadConfig: Fetcher<FileUploadConfigResponse, { url: string }> = ({ url }) => {
  212. return get<FileUploadConfigResponse>(url)
  213. }
  214. export const fetchNotionConnection: Fetcher<{ data: string }, string> = (url) => {
  215. return get(url) as Promise<{ data: string }>
  216. }
  217. export const fetchDataSourceNotionBinding: Fetcher<{ result: string }, string> = (url) => {
  218. return get(url) as Promise<{ result: string }>
  219. }
  220. export const fetchApiBasedExtensionList: Fetcher<ApiBasedExtension[], string> = (url) => {
  221. return get(url) as Promise<ApiBasedExtension[]>
  222. }
  223. export const fetchApiBasedExtensionDetail: Fetcher<ApiBasedExtension, string> = (url) => {
  224. return get(url) as Promise<ApiBasedExtension>
  225. }
  226. export const addApiBasedExtension: Fetcher<ApiBasedExtension, { url: string; body: ApiBasedExtension }> = ({ url, body }) => {
  227. return post(url, { body }) as Promise<ApiBasedExtension>
  228. }
  229. export const updateApiBasedExtension: Fetcher<ApiBasedExtension, { url: string; body: ApiBasedExtension }> = ({ url, body }) => {
  230. return post(url, { body }) as Promise<ApiBasedExtension>
  231. }
  232. export const deleteApiBasedExtension: Fetcher<{ result: string }, string> = (url) => {
  233. return del(url) as Promise<{ result: string }>
  234. }
  235. export const fetchCodeBasedExtensionList: Fetcher<CodeBasedExtension, string> = (url) => {
  236. return get(url) as Promise<CodeBasedExtension>
  237. }
  238. export const moderate = (url: string, body: { app_id: string; text: string }) => {
  239. return post(url, { body }) as Promise<ModerateResponse>
  240. }
  241. type RetrievalMethodsRes = {
  242. retrieval_method: RETRIEVE_METHOD[]
  243. }
  244. export const fetchSupportRetrievalMethods: Fetcher<RetrievalMethodsRes, string> = (url) => {
  245. return get<RetrievalMethodsRes>(url)
  246. }
  247. export const getSystemFeatures = () => {
  248. return get<SystemFeatures>('/system-features')
  249. }
  250. export const enableModel = (url: string, body: { model: string; model_type: ModelTypeEnum }) =>
  251. patch<CommonResponse>(url, { body })
  252. export const disableModel = (url: string, body: { model: string; model_type: ModelTypeEnum }) =>
  253. patch<CommonResponse>(url, { body })
  254. export const sendForgotPasswordEmail: Fetcher<CommonResponse & { data: string }, { url: string; body: { email: string } }> = ({ url, body }) =>
  255. post<CommonResponse & { data: string }>(url, { body })
  256. export const verifyForgotPasswordToken: Fetcher<CommonResponse & { is_valid: boolean; email: string }, { url: string; body: { token: string } }> = ({ url, body }) => {
  257. return post(url, { body }) as Promise<CommonResponse & { is_valid: boolean; email: string }>
  258. }
  259. export const changePasswordWithToken: Fetcher<CommonResponse, { url: string; body: { token: string; new_password: string; password_confirm: string } }> = ({ url, body }) =>
  260. post<CommonResponse>(url, { body })
  261. export const uploadRemoteFileInfo = (url: string, isPublic?: boolean) => {
  262. return post<{ id: string; name: string; size: number; mime_type: string; url: string }>('/remote-files/upload', { body: { url } }, { isPublicAPI: isPublic })
  263. }
  264. export const sendEMailLoginCode = (email: string, language = 'en-US') =>
  265. post<CommonResponse & { data: string }>('/email-code-login', { body: { email, language } })
  266. export const emailLoginWithCode = (data: { email: string; code: string; token: string }) =>
  267. post<LoginResponse>('/email-code-login/validity', { body: data })
  268. export const sendResetPasswordCode = (email: string, language = 'en-US') =>
  269. post<CommonResponse & { data: string; message?: string; code?: string }>('/forgot-password', { body: { email, language } })
  270. export const verifyResetPasswordCode = (body: { email: string; code: string; token: string }) =>
  271. post<CommonResponse & { is_valid: boolean; token: string }>('/forgot-password/validity', { body })
  272. export const sendDeleteAccountCode = () =>
  273. get<CommonResponse & { data: string }>('/account/delete/verify')
  274. export const verifyDeleteAccountCode = (body: { code: string; token: string }) =>
  275. post<CommonResponse & { is_valid: boolean }>('/account/delete', { body })
  276. export const submitDeleteAccountFeedback = (body: { feedback: string; email: string }) =>
  277. post<CommonResponse>('/account/delete/feedback', { body })
  278. export const getDocDownloadUrl = (doc_name: string) =>
  279. get<{ url: string }>('/compliance/download', { params: { doc_name } }, { silent: true })