aiModel.ts 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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/delete */
  57. export async function postModelOpenApiDelete(
  58. body: {
  59. id: string
  60. },
  61. options?: { [key: string]: any }
  62. ) {
  63. return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
  64. '/api/ai/model/delete',
  65. {
  66. method: 'POST',
  67. headers: {
  68. 'Content-Type': 'application/json'
  69. },
  70. data: body,
  71. ...(options || {})
  72. }
  73. )
  74. }
  75. /** 模型详情 POST /api/ai/model/info */
  76. export async function postModelInfo(
  77. body: {
  78. id: string
  79. },
  80. options?: { [key: string]: any }
  81. ) {
  82. return request<{
  83. isSuccess: boolean
  84. code: number
  85. result: {
  86. creationTime: string
  87. creatorUserId: string
  88. description: string
  89. id: string
  90. isDeleted: boolean
  91. is_default: boolean
  92. name: string
  93. parameters: {
  94. api_key: string
  95. base_url: string
  96. embedding_parameters: { dimension: number; truncate_prompt_tokens: number }
  97. provider: string
  98. }
  99. provider: string
  100. source: string
  101. status: string
  102. title: string
  103. type: string
  104. updateTime: string
  105. }
  106. isAuthorized: boolean
  107. }>('/api/ai/model/info', {
  108. method: 'POST',
  109. headers: {
  110. 'Content-Type': 'application/json'
  111. },
  112. data: body,
  113. ...(options || {})
  114. })
  115. }
  116. /** 获取模型分页列表 POST /api/ai/model/pageList */
  117. export async function postModelPageList(
  118. body: {
  119. keyword: string
  120. type: string
  121. source: string
  122. pageIndex: number
  123. pageSize: number
  124. },
  125. options?: { [key: string]: any }
  126. ) {
  127. return request<{
  128. isSuccess: boolean
  129. code: number
  130. result: {
  131. currentPage: number
  132. hasNextPage: boolean
  133. hasPreviousPage: boolean
  134. model: {
  135. creationTime?: string
  136. creatorUserId?: string
  137. description?: string
  138. id?: string
  139. isDeleted?: boolean
  140. is_default?: boolean
  141. name?: string
  142. parameters: {
  143. api_key: string
  144. base_url: string
  145. embedding_parameters: { dimension: number; truncate_prompt_tokens: number }
  146. provider: string
  147. }
  148. provider?: string
  149. source?: string
  150. status?: string
  151. title?: string
  152. type?: string
  153. updateTime?: string
  154. }[]
  155. pageSize: number
  156. totalCount: number
  157. totalPages: number
  158. }
  159. isAuthorized: boolean
  160. }>('/api/ai/model/pageList', {
  161. method: 'POST',
  162. headers: {
  163. 'Content-Type': 'application/json'
  164. },
  165. data: body,
  166. ...(options || {})
  167. })
  168. }
  169. /** 根据模型类型获取支持的服务商列表及配置信息 POST /api/ai/model/providers */
  170. export async function postModelProviders(
  171. body: {
  172. model_type: string
  173. },
  174. options?: { [key: string]: any }
  175. ) {
  176. return request<{
  177. isSuccess: boolean
  178. code: number
  179. result: {
  180. defaultUrls: { chat: string; embedding: string; rerank: string; vllm: string }
  181. description: string
  182. label: string
  183. modelTypes: string[]
  184. value: string
  185. }[]
  186. isAuthorized: boolean
  187. }>('/api/ai/model/providers', {
  188. method: 'POST',
  189. headers: {
  190. 'Content-Type': 'application/json'
  191. },
  192. data: body,
  193. ...(options || {})
  194. })
  195. }
  196. /** 获取模型选择列表 POST /api/ai/model/selectList */
  197. export async function postModelSelectList(
  198. body: {
  199. keyword?: string
  200. type?: string
  201. },
  202. options?: { [key: string]: any }
  203. ) {
  204. return request<{
  205. isSuccess: boolean
  206. code: number
  207. result: {
  208. creationTime?: string
  209. creatorUserId?: string
  210. description?: string
  211. id?: string
  212. isDeleted?: boolean
  213. is_default?: boolean
  214. name?: string
  215. parameters: {
  216. api_key: string
  217. base_url: string
  218. embedding_parameters: { dimension: number; truncate_prompt_tokens: number }
  219. provider: string
  220. }
  221. provider?: string
  222. source?: string
  223. status?: string
  224. title?: string
  225. type?: string
  226. updateTime?: string
  227. }[]
  228. isAuthorized: boolean
  229. }>('/api/ai/model/selectList', {
  230. method: 'POST',
  231. headers: {
  232. 'Content-Type': 'application/json'
  233. },
  234. data: body,
  235. ...(options || {})
  236. })
  237. }
  238. /** 更新模型 POST /api/ai/model/update */
  239. export async function postModelUpdate(
  240. body: {
  241. id: string
  242. name: string
  243. title: string
  244. description: string
  245. base_url: string
  246. api_key: string
  247. custom_headers: Record<string, any>
  248. },
  249. options?: { [key: string]: any }
  250. ) {
  251. return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
  252. '/api/ai/model/update',
  253. {
  254. method: 'POST',
  255. headers: {
  256. 'Content-Type': 'application/json'
  257. },
  258. data: body,
  259. ...(options || {})
  260. }
  261. )
  262. }