(message: any)
| 4 | import { contentPostHandler } from "@/entrypoints/utils/check"; |
| 5 | |
| 6 | async function deepseek(message: any) { |
| 7 | try { |
| 8 | const headers = new Headers({ |
| 9 | 'Content-Type': 'application/json', |
| 10 | 'Authorization': `Bearer ${config.token[config.service]}` |
| 11 | }); |
| 12 | |
| 13 | const url = config.proxy[config.service] || urls[config.service]; |
| 14 | |
| 15 | const resp = await fetch(url, { |
| 16 | method: method.POST, |
| 17 | headers, |
| 18 | body: deepseekMsgTemplate(message.origin) |
| 19 | }); |
| 20 | |
| 21 | if (!resp.ok) { |
| 22 | throw new Error(`翻译失败: ${resp.status} ${resp.statusText} body: ${await resp.text()}`); |
| 23 | } |
| 24 | |
| 25 | const result = await resp.json(); |
| 26 | return contentPostHandler(result.choices[0].message.content); |
| 27 | } catch (error) { |
| 28 | console.error('API调用失败:', error); |
| 29 | throw error; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | export default deepseek; |
nothing calls this directly
no test coverage detected