(message: any)
| 5 | import {contentPostHandler} from "@/entrypoints/utils/check"; |
| 6 | |
| 7 | async function custom(message: any) { |
| 8 | |
| 9 | let headers = new Headers(); |
| 10 | headers.append('Content-Type', 'application/json'); |
| 11 | headers.append('Authorization', `Bearer ${config.token[services.custom]}`); |
| 12 | |
| 13 | const resp = await fetch(config.custom, { |
| 14 | method: method.POST, |
| 15 | headers: headers, |
| 16 | body: commonMsgTemplate(message.origin) |
| 17 | }); |
| 18 | |
| 19 | if (resp.ok) { |
| 20 | let result = await resp.json(); |
| 21 | return contentPostHandler(result.choices[0].message.content); |
| 22 | } else { |
| 23 | console.log("翻译失败:", resp); |
| 24 | throw new Error(`翻译失败: ${resp.status} ${resp.statusText} body: ${await resp.text()}`); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | export default custom; |
nothing calls this directly
no test coverage detected