(origin)
| 1280 | // region 文心一言 |
| 1281 | |
| 1282 | function yiyan(origin) { |
| 1283 | return new Promise((resolve, reject) => { |
| 1284 | getYiyanToken().then(token => { |
| 1285 | let option = optionsManager.getOptionName(transModel.yiyan); |
| 1286 | |
| 1287 | // ERNIE-Bot 4.0 模型,模型定价页面:https://console.bce.baidu.com/qianfan/chargemanage/list |
| 1288 | // api 文档中心:https://cloud.baidu.com/doc/WENXINWORKSHOP/s/clntwmv7t |
| 1289 | GM_xmlhttpRequest({ |
| 1290 | method: POST, |
| 1291 | url: 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/' + option + '?access_token=' + token, |
| 1292 | headers: {"Content-Type": "application/json"}, |
| 1293 | system: chatMgs.getSystemMsg(), |
| 1294 | data: JSON.stringify({ |
| 1295 | 'temperature': 0.3, // 随机度 |
| 1296 | 'disable_search': true, // 禁用搜索 |
| 1297 | 'messages': [ |
| 1298 | {"role": "user", "content": chatMgs.getUserMsg("hello")}, |
| 1299 | {"role": "assistant", "content": "你好"}, |
| 1300 | {"role": "user", "content": origin} |
| 1301 | ], |
| 1302 | }), |
| 1303 | onload: resp => { |
| 1304 | try { |
| 1305 | let res = JSON.parse(resp.responseText); |
| 1306 | resolve(res.result); |
| 1307 | } catch (e) { |
| 1308 | reject(resp.responseText); |
| 1309 | } |
| 1310 | }, |
| 1311 | onerror: error => reject(error) |
| 1312 | }); |
| 1313 | }).catch(error => reject('Error getting Yiyan token: ' + error)); |
| 1314 | }); |
| 1315 | } |
| 1316 | |
| 1317 | |
| 1318 | // req: API Key、Secret Key |
nothing calls this directly
no test coverage detected