2025-08-14 00:36:04 +08:00
|
|
|
|
// src/api/ai_index.js
|
2025-08-13 09:19:28 +08:00
|
|
|
|
// import request from '@/utils/ai_request.js'
|
2025-08-14 00:36:04 +08:00
|
|
|
|
import request from "@/utils/ai_request.js";
|
2025-08-13 09:19:28 +08:00
|
|
|
|
|
|
|
|
|
// 获取历史
|
|
|
|
|
export const getHistory = ({
|
|
|
|
|
conversationId,
|
|
|
|
|
user,
|
2025-08-14 00:36:04 +08:00
|
|
|
|
limit = 20,
|
|
|
|
|
beforeId
|
2025-08-13 09:19:28 +08:00
|
|
|
|
}) => {
|
2025-08-14 00:36:04 +08:00
|
|
|
|
const params = {
|
|
|
|
|
conversationId,
|
|
|
|
|
user,
|
|
|
|
|
limit
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 如果有beforeId参数,添加到请求中
|
|
|
|
|
if (beforeId) {
|
|
|
|
|
params.beforeId = beforeId;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-13 09:19:28 +08:00
|
|
|
|
return request({
|
|
|
|
|
url: '/aitutor/aichat/getMessagesToUser',
|
|
|
|
|
method: 'get',
|
2025-08-14 00:36:04 +08:00
|
|
|
|
params
|
2025-08-13 09:19:28 +08:00
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2025-08-14 00:36:04 +08:00
|
|
|
|
|
|
|
|
|
// 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'
|
|
|
|
|
// // }
|
|
|
|
|
// });
|
|
|
|
|
// };
|
|
|
|
|
|
2025-08-13 09:19:28 +08:00
|
|
|
|
// 点赞/点踩 action: 1 点赞 0 点踩
|
|
|
|
|
export const sendFeedback = ({
|
|
|
|
|
messageId,
|
2025-08-14 00:36:04 +08:00
|
|
|
|
action,
|
|
|
|
|
user
|
2025-08-13 09:19:28 +08:00
|
|
|
|
}) => {
|
|
|
|
|
return request({
|
2025-08-14 00:36:04 +08:00
|
|
|
|
url: '/aitutor/aichat/feedback',
|
2025-08-13 09:19:28 +08:00
|
|
|
|
method: 'post',
|
|
|
|
|
data: {
|
2025-08-14 00:36:04 +08:00
|
|
|
|
message_id: messageId,
|
|
|
|
|
rating: action === 1 ? 'like' : 'dislike', // 添加rating参数
|
|
|
|
|
user
|
2025-08-13 09:19:28 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
2025-08-14 00:36:04 +08:00
|
|
|
|
};
|
|
|
|
|
// export const sendFeedback = ({
|
|
|
|
|
// messageId,
|
|
|
|
|
// action
|
|
|
|
|
// }) => {
|
|
|
|
|
// return request({
|
|
|
|
|
// url: '/api/chat/feedback',
|
|
|
|
|
// method: 'post',
|
|
|
|
|
// data: {
|
|
|
|
|
// messageId,
|
|
|
|
|
// action
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// };
|