MCPcopy
hub / github.com/Bistutu/FluentRead / infini

Function infini

entrypoints/service/infini.ts:7–29  ·  view source on GitHub ↗
(message: any)

Source from the content-addressed store, hash-verified

5import {config} from "@/entrypoints/utils/config";
6
7async 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
31export default infini;

Callers

nothing calls this directly

Calls 1

commonMsgTemplateFunction · 0.90

Tested by

no test coverage detected