aiModel.ts 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. // @ts-ignore
  2. /* eslint-disable */
  3. import request from '@repo/api-client'
  4. /** 检查模型 POST /api/ai/model/check */
  5. export async function postAiModelCheck(
  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 postAiModelCreate(
  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 postAiModelOpenApiDelete(
  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 postAiModelInfo(
  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 postAiModelPageList(
  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 postAiModelProviders(options?: { [key: string]: any }) {
  171. return request<{
  172. isSuccess: boolean
  173. code: number
  174. result: {
  175. defaultUrls: { chat: string; embedding: string; rerank: string; vllm: string }
  176. description: string
  177. label: string
  178. modelTypes: string[]
  179. value: string
  180. }[]
  181. isAuthorized: boolean
  182. }>('/api/ai/model/providers', {
  183. method: 'POST',
  184. ...(options || {})
  185. })
  186. }
  187. /** 更新模型 POST /api/ai/model/update */
  188. export async function postAiModelUpdate(
  189. body: {
  190. id: string
  191. name: string
  192. title: string
  193. description: string
  194. base_url: string
  195. api_key: string
  196. custom_headers: Record<string, any>
  197. },
  198. options?: { [key: string]: any }
  199. ) {
  200. return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
  201. '/api/ai/model/update',
  202. {
  203. method: 'POST',
  204. headers: {
  205. 'Content-Type': 'application/json'
  206. },
  207. data: body,
  208. ...(options || {})
  209. }
  210. )
  211. }