aiModel.ts 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. // @ts-ignore
  2. /* eslint-disable */
  3. import request from '@repo/api-client'
  4. /** 检查模型 POST /api/ai/model/check */
  5. export async function postModelCheck(
  6. body: {
  7. name: string
  8. type: string
  9. source: string
  10. provider: string
  11. api_key: string
  12. },
  13. options?: { [key: string]: any }
  14. ) {
  15. return request<{
  16. isSuccess: boolean
  17. code: number
  18. isAuthorized: boolean
  19. result?: Record<string, any>
  20. }>('/api/ai/model/check', {
  21. method: 'POST',
  22. headers: {
  23. 'Content-Type': 'application/json'
  24. },
  25. data: body,
  26. ...(options || {})
  27. })
  28. }
  29. /** 创建模型 POST /api/ai/model/create */
  30. export async function postModelCreate(
  31. body: {
  32. name: string
  33. title: string
  34. description: string
  35. type: string
  36. source: string
  37. provider: string
  38. base_url: string
  39. api_key: string
  40. custom_headers: Record<string, any>
  41. },
  42. options?: { [key: string]: any }
  43. ) {
  44. return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
  45. '/api/ai/model/create',
  46. {
  47. method: 'POST',
  48. headers: {
  49. 'Content-Type': 'application/json'
  50. },
  51. data: body,
  52. ...(options || {})
  53. }
  54. )
  55. }
  56. /** 更新凭证 POST /api/ai/model/credentials */
  57. export async function postModelCredentials(
  58. body: {
  59. id: string
  60. api_key: string
  61. },
  62. options?: { [key: string]: any }
  63. ) {
  64. return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
  65. '/api/ai/model/credentials',
  66. {
  67. method: 'POST',
  68. headers: {
  69. 'Content-Type': 'application/json'
  70. },
  71. data: body,
  72. ...(options || {})
  73. }
  74. )
  75. }
  76. /** 删除模型 POST /api/ai/model/delete */
  77. export async function postModelOpenApiDelete(
  78. body: {
  79. id: string
  80. },
  81. options?: { [key: string]: any }
  82. ) {
  83. return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
  84. '/api/ai/model/delete',
  85. {
  86. method: 'POST',
  87. headers: {
  88. 'Content-Type': 'application/json'
  89. },
  90. data: body,
  91. ...(options || {})
  92. }
  93. )
  94. }
  95. /** 删除凭证 POST /api/ai/model/delete_credentials */
  96. export async function postModelDeleteCredentials(
  97. body: {
  98. id: string
  99. },
  100. options?: { [key: string]: any }
  101. ) {
  102. return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
  103. '/api/ai/model/delete_credentials',
  104. {
  105. method: 'POST',
  106. headers: {
  107. 'Content-Type': 'application/json'
  108. },
  109. data: body,
  110. ...(options || {})
  111. }
  112. )
  113. }
  114. /** 模型详情 POST /api/ai/model/info */
  115. export async function postModelInfo(
  116. body: {
  117. id: string
  118. },
  119. options?: { [key: string]: any }
  120. ) {
  121. return request<{
  122. isSuccess: boolean
  123. code: number
  124. result: {
  125. creationTime: string
  126. creatorUserId: string
  127. description: string
  128. id: string
  129. isDeleted: boolean
  130. is_default: boolean
  131. name: string
  132. parameters: {
  133. api_key: string
  134. base_url: string
  135. embedding_parameters: { dimension: number; truncate_prompt_tokens: number }
  136. provider: string
  137. }
  138. provider: string
  139. source: string
  140. status: string
  141. title: string
  142. type: string
  143. updateTime: string
  144. }
  145. isAuthorized: boolean
  146. }>('/api/ai/model/info', {
  147. method: 'POST',
  148. headers: {
  149. 'Content-Type': 'application/json'
  150. },
  151. data: body,
  152. ...(options || {})
  153. })
  154. }
  155. /** 获取模型分页列表 POST /api/ai/model/pageList */
  156. export async function postModelPageList(
  157. body: {
  158. keyword: string
  159. type: string
  160. source: string
  161. pageIndex: number
  162. pageSize: number
  163. },
  164. options?: { [key: string]: any }
  165. ) {
  166. return request<{
  167. isSuccess: boolean
  168. code: number
  169. result: {
  170. currentPage: number
  171. hasNextPage: boolean
  172. hasPreviousPage: boolean
  173. model: {
  174. creationTime?: string
  175. creatorUserId?: string
  176. description?: string
  177. id?: string
  178. isDeleted?: boolean
  179. is_default?: boolean
  180. name?: string
  181. parameters: {
  182. api_key: string
  183. base_url: string
  184. embedding_parameters: { dimension: number; truncate_prompt_tokens: number }
  185. provider: string
  186. }
  187. provider?: string
  188. source?: string
  189. status?: string
  190. title?: string
  191. type?: string
  192. updateTime?: string
  193. }[]
  194. pageSize: number
  195. totalCount: number
  196. totalPages: number
  197. }
  198. isAuthorized: boolean
  199. }>('/api/ai/model/pageList', {
  200. method: 'POST',
  201. headers: {
  202. 'Content-Type': 'application/json'
  203. },
  204. data: body,
  205. ...(options || {})
  206. })
  207. }
  208. /** 根据模型类型获取支持的服务商列表及配置信息 POST /api/ai/model/providers */
  209. export async function postModelProviders(
  210. body: {
  211. model_type: string
  212. },
  213. options?: { [key: string]: any }
  214. ) {
  215. return request<{
  216. isSuccess: boolean
  217. code: number
  218. result: {
  219. defaultUrls: { chat: string; embedding: string; rerank: string; vllm: string }
  220. description: string
  221. label: string
  222. modelTypes: string[]
  223. value: string
  224. }[]
  225. isAuthorized: boolean
  226. }>('/api/ai/model/providers', {
  227. method: 'POST',
  228. headers: {
  229. 'Content-Type': 'application/json'
  230. },
  231. data: body,
  232. ...(options || {})
  233. })
  234. }
  235. /** 获取模型选择列表 POST /api/ai/model/selectList */
  236. export async function postModelSelectList(
  237. body: {
  238. keyword?: string
  239. type?: string
  240. },
  241. options?: { [key: string]: any }
  242. ) {
  243. return request<{
  244. isSuccess: boolean
  245. code: number
  246. result: {
  247. creationTime?: string
  248. creatorUserId?: string
  249. description?: string
  250. id?: string
  251. isDeleted?: boolean
  252. is_default?: boolean
  253. name?: string
  254. parameters: {
  255. api_key: string
  256. base_url: string
  257. embedding_parameters: { dimension: number; truncate_prompt_tokens: number }
  258. provider: string
  259. }
  260. provider?: string
  261. source?: string
  262. status?: string
  263. title?: string
  264. type?: string
  265. updateTime?: string
  266. }[]
  267. isAuthorized: boolean
  268. }>('/api/ai/model/selectList', {
  269. method: 'POST',
  270. headers: {
  271. 'Content-Type': 'application/json'
  272. },
  273. data: body,
  274. ...(options || {})
  275. })
  276. }
  277. /** 更新模型 POST /api/ai/model/update */
  278. export async function postModelUpdate(
  279. body: {
  280. id: string
  281. name: string
  282. title: string
  283. description: string
  284. base_url: string
  285. api_key: string
  286. custom_headers: Record<string, any>
  287. },
  288. options?: { [key: string]: any }
  289. ) {
  290. return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
  291. '/api/ai/model/update',
  292. {
  293. method: 'POST',
  294. headers: {
  295. 'Content-Type': 'application/json'
  296. },
  297. data: body,
  298. ...(options || {})
  299. }
  300. )
  301. }