AI聊天更新历史记录

This commit is contained in:
14651
2025-08-14 00:36:04 +08:00
parent 3743c72a54
commit 362f286759
7 changed files with 1181 additions and 702 deletions

View File

@@ -1,38 +1,78 @@
// src/api/index.js
// src/api/ai_index.js
// import request from '@/utils/ai_request.js'
import request from "../../utils/ai_request";
import request from "@/utils/ai_request.js";
// 获取历史
export const getHistory = ({
conversationId,
user,
limit = 20
limit = 20,
beforeId
}) => {
const params = {
conversationId,
user,
limit
};
// 如果有beforeId参数添加到请求中
if (beforeId) {
params.beforeId = beforeId;
}
return request({
url: '/aitutor/aichat/getMessagesToUser',
method: 'get',
params: {
conversationId,
user,
limit
}
// headers: {
// Authorization: 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjBmMTY3NmY2LTgwOGMtNGUwMC04NDJjLWIwNmY1ZTM5NzJlNCJ9.VVc6OwQ-Xn9pxzYbPhlCpvDp6TwESS00gJi9IXUEIbFw4RFACZDmYCYjQ7voTM4fppy9SAMJCWT-L7Uy-K1eqw'
// }
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
action,
user
}) => {
return request({
url: '/api/chat/feedback',
url: '/aitutor/aichat/feedback',
method: 'post',
data: {
messageId,
action
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
// }
// });
// };