Files
meida_front/sheep/api/doubao/index.js
T
2025-10-13 19:35:32 +08:00

45 lines
1.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import Request from 'luch-request';
const init = () => {
const http = new Request({
baseURL: 'https://ark.cn-beijing.volces.com/api/v3/chat/completions',
timeout: 100 * 1000,
method: 'GET',
header: {
Accept: 'text/json',
'Content-Type': 'application/json;charset=UTF-8',
Authorization: 'Bearer 14fc0280-fc65-462d-ac2d-50178c0212e3',
},
// #ifdef H5
// 跨域请求时是否携带凭证(cookies)仅H5支持(HBuilderX 2.6.15+
withCredentials: false,
// #endif
});
return http;
};
export const praiseTextApi = (data) => {
const http = init();
return http.request({
method: 'POST',
data: {
model: 'doubao-1-5-thinking-pro-m-250428',
messages: [
data.system_prompt ?{
role: 'system',
content: data.system_prompt,
}: null,
{
role: 'user',
content: data.text,
},
].filter(i => i),
},
}).then(res => {
return { data: JSON.stringify(res.data) };
});
};