aiModel.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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(options?: { [key: string]: any }) {
  118. return request<{
  119. isSuccess: boolean
  120. code: number
  121. result: {
  122. currentPage: number
  123. hasNextPage: boolean
  124. hasPreviousPage: boolean
  125. model: {
  126. creationTime?: string
  127. creatorUserId?: string
  128. description?: string
  129. id?: string
  130. isDeleted?: boolean
  131. is_default?: boolean
  132. name?: string
  133. parameters: {
  134. api_key: string
  135. base_url: string
  136. embedding_parameters: { dimension: number; truncate_prompt_tokens: number }
  137. provider: string
  138. }
  139. provider?: string
  140. source?: string
  141. status?: string
  142. title?: string
  143. type?: string
  144. updateTime?: string
  145. }[]
  146. pageSize: number
  147. totalCount: number
  148. totalPages: number
  149. }
  150. isAuthorized: boolean
  151. }>('/api/ai/model/pageList', {
  152. method: 'POST',
  153. ...(options || {})
  154. })
  155. }
  156. /** 根据模型类型获取支持的服务商列表及配置信息 POST /api/ai/model/providers */
  157. export async function postAiModelProviders(options?: { [key: string]: any }) {
  158. return request<{
  159. isSuccess: boolean
  160. code: number
  161. result: {
  162. defaultUrls: { chat: string; embedding: string; rerank: string; vllm: string }
  163. description: string
  164. label: string
  165. modelTypes: string[]
  166. value: string
  167. }[]
  168. isAuthorized: boolean
  169. }>('/api/ai/model/providers', {
  170. method: 'POST',
  171. ...(options || {})
  172. })
  173. }
  174. /** 更新模型 POST /api/ai/model/update */
  175. export async function postAiModelUpdate(
  176. body: {
  177. id: string
  178. name: string
  179. title: string
  180. description: string
  181. base_url: string
  182. api_key: string
  183. custom_headers: Record<string, any>
  184. },
  185. options?: { [key: string]: any }
  186. ) {
  187. return request<{ isSuccess: boolean; code: number; isAuthorized: boolean }>(
  188. '/api/ai/model/update',
  189. {
  190. method: 'POST',
  191. headers: {
  192. 'Content-Type': 'application/json'
  193. },
  194. data: body,
  195. ...(options || {})
  196. }
  197. )
  198. }