(message: any)
| 5 | import {config} from "@/entrypoints/utils/config"; |
| 6 | |
| 7 | async function infini(message: any) { |
| 8 | // 构建请求头 |
| 9 | let headers = new Headers(); |
| 10 | headers.append('Content-Type', 'application/json'); |
| 11 | headers.append('Authorization', `Bearer ${config.token[services.infini]}`); |
| 12 | |
| 13 | let model = config.model[services.infini] === customModelString ? config.customModel[services.infini] : config.model[services.infini] |
| 14 | |
| 15 | // 发起 fetch 请求 |
| 16 | const resp = await fetch(`https://cloud.infini-ai.com/maas/${model}/nvidia/chat/completions`, { |
| 17 | method: method.POST, |
| 18 | headers: headers, |
| 19 | body: commonMsgTemplate(message.origin) |
| 20 | }); |
| 21 | |
| 22 | if (resp.ok) { |
| 23 | let result = await resp.json(); |
| 24 | return result.choices[0].message.content |
| 25 | } else { |
| 26 | console.error(resp); |
| 27 | throw new Error(`请求失败: ${resp.status} ${resp.statusText} body: ${await resp.text()}`); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | export default infini; |
nothing calls this directly
no test coverage detected