mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 08:46:22 +02:00
feat: perf optimizations
- improved search_knowledgebase_tool - Added new endpoint to batch-fetch comments for multiple messages, reducing the number of API calls. - Introduced CommentBatchRequest and CommentBatchResponse schemas for handling batch requests and responses. - Updated chat_comments_service to validate message existence and permissions before fetching comments. - Enhanced frontend with useBatchCommentsPreload hook to optimize comment loading for assistant messages.
This commit is contained in:
parent
a43956bdce
commit
0e723a5b8b
13 changed files with 424 additions and 67 deletions
|
|
@ -8,8 +8,11 @@ import {
|
|||
type DeleteCommentRequest,
|
||||
deleteCommentRequest,
|
||||
deleteCommentResponse,
|
||||
type GetBatchCommentsRequest,
|
||||
type GetCommentsRequest,
|
||||
type GetMentionsRequest,
|
||||
getBatchCommentsRequest,
|
||||
getBatchCommentsResponse,
|
||||
getCommentsRequest,
|
||||
getCommentsResponse,
|
||||
getMentionsRequest,
|
||||
|
|
@ -22,6 +25,22 @@ import { ValidationError } from "@/lib/error";
|
|||
import { baseApiService } from "./base-api.service";
|
||||
|
||||
class ChatCommentsApiService {
|
||||
/**
|
||||
* Batch-fetch comments for multiple messages in one request
|
||||
*/
|
||||
getBatchComments = async (request: GetBatchCommentsRequest) => {
|
||||
const parsed = getBatchCommentsRequest.safeParse(request);
|
||||
|
||||
if (!parsed.success) {
|
||||
const errorMessage = parsed.error.issues.map((issue) => issue.message).join(", ");
|
||||
throw new ValidationError(`Invalid request: ${errorMessage}`);
|
||||
}
|
||||
|
||||
return baseApiService.post("/api/v1/messages/comments/batch", getBatchCommentsResponse, {
|
||||
body: { message_ids: parsed.data.message_ids },
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Get comments for a message
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue