MCPcopy Create free account
hub / github.com/Bistutu/FluentRead / moonshot

Function moonshot

userscripts.js:1251–1276  ·  view source on GitHub ↗
(origin)

Source from the content-addressed store, hash-verified

1249
1250// region moonshot
1251function moonshot(origin) {
1252 return new Promise((resolve, reject) => {
1253 let token = tokenManager.getToken(transModel.moonshot);
1254 let option = optionsManager.getOptionName(transModel.moonshot);
1255 if (!token) {
1256 reject('No token available');
1257 return;
1258 }
1259
1260 GM_xmlhttpRequest({
1261 method: POST,
1262 url: 'https://api.moonshot.cn/v1/chat/completions',
1263 headers: LLMFormat.getStdHeader(token),
1264 data: LLMFormat.getStdData(origin, option),
1265 onload: resp => {
1266 try {
1267 let result = JSON.parse(resp.responseText);
1268 resolve(result.choices[0].message.content);
1269 } catch (e) {
1270 reject(resp.responseText);
1271 }
1272 },
1273 onerror: error => reject(error)
1274 });
1275 });
1276}
1277
1278// endregion
1279

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected