78 lines
1.5 KiB
JavaScript
78 lines
1.5 KiB
JavaScript
// src/api/ai_index.js
|
||
// import request from '@/utils/ai_request.js'
|
||
import request from "@/utils/ai_request.js";
|
||
|
||
// 获取历史
|
||
export const getHistory = ({
|
||
conversationId,
|
||
user,
|
||
limit = 20,
|
||
beforeId
|
||
}) => {
|
||
const params = {
|
||
conversationId,
|
||
user,
|
||
limit
|
||
};
|
||
|
||
// 如果有beforeId参数,添加到请求中
|
||
if (beforeId) {
|
||
params.beforeId = beforeId;
|
||
}
|
||
|
||
return request({
|
||
url: '/aitutor/aichat/getMessagesToUser',
|
||
method: 'get',
|
||
params
|
||
});
|
||
};
|
||
|
||
|
||
// export const getHistory = ({
|
||
// conversationId,
|
||
// user,
|
||
// limit = 20
|
||
// }) => {
|
||
// return request({
|
||
// url: '/aitutor/aichat/getMessagesToUser',
|
||
// method: 'get',
|
||
// params: {
|
||
// conversationId,
|
||
// user,
|
||
// limit
|
||
// }
|
||
// // headers: {
|
||
// // Authorization: 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjBmMTY3NmY2LTgwOGMtNGUwMC04NDJjLWIwNmY1ZTM5NzJlNCJ9.VVc6OwQ-Xn9pxzYbPhlCpvDp6TwESS00gJi9IXUEIbFw4RFACZDmYCYjQ7voTM4fppy9SAMJCWT-L7Uy-K1eqw'
|
||
// // }
|
||
// });
|
||
// };
|
||
|
||
// 点赞/点踩 action: 1 点赞 0 点踩
|
||
export const sendFeedback = ({
|
||
messageId,
|
||
action,
|
||
user
|
||
}) => {
|
||
return request({
|
||
url: '/aitutor/aichat/feedback',
|
||
method: 'post',
|
||
data: {
|
||
message_id: messageId,
|
||
rating: action === 1 ? 'like' : 'dislike', // 添加rating参数
|
||
user
|
||
}
|
||
});
|
||
};
|
||
// export const sendFeedback = ({
|
||
// messageId,
|
||
// action
|
||
// }) => {
|
||
// return request({
|
||
// url: '/api/chat/feedback',
|
||
// method: 'post',
|
||
// data: {
|
||
// messageId,
|
||
// action
|
||
// }
|
||
// });
|
||
// };
|