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

Function custom

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

Source from the content-addressed store, hash-verified

5import {contentPostHandler} from "@/entrypoints/utils/check";
6
7async 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
28export default custom;

Callers

nothing calls this directly

Calls 2

commonMsgTemplateFunction · 0.90
contentPostHandlerFunction · 0.90

Tested by

no test coverage detected