File tree Expand file tree Collapse file tree 11 files changed +174
-17
lines changed
public/locales/translation Expand file tree Collapse file tree 11 files changed +174
-17
lines changed Original file line number Diff line number Diff line change @@ -461,22 +461,28 @@ export const deleteChat = async (
461461
462462 // Delete Messages
463463 const messageItems = await listMessages ( _chatId ) ;
464- await dynamoDbDocument . send (
465- new BatchWriteCommand ( {
466- RequestItems : {
467- [ TABLE_NAME ] : messageItems . map ( ( m ) => {
468- return {
469- DeleteRequest : {
470- Key : {
471- id : m . id ,
472- createdDate : m . createdDate ,
464+
465+ // Split into chunks of 25 (DynamoDB BatchWrite limit)
466+ const chunkSize = 25 ;
467+ for ( let i = 0 ; i < messageItems . length ; i += chunkSize ) {
468+ const chunk = messageItems . slice ( i , i + chunkSize ) ;
469+ await dynamoDbDocument . send (
470+ new BatchWriteCommand ( {
471+ RequestItems : {
472+ [ TABLE_NAME ] : chunk . map ( ( m ) => {
473+ return {
474+ DeleteRequest : {
475+ Key : {
476+ id : m . id ,
477+ createdDate : m . createdDate ,
478+ } ,
473479 } ,
474- } ,
475- } ;
476- } ) ,
477- } ,
478- } )
479- ) ;
480+ } ;
481+ } ) ,
482+ } ,
483+ } )
484+ ) ;
485+ }
480486} ;
481487
482488export const updateSystemContextTitle = async (
Original file line number Diff line number Diff line change @@ -955,6 +955,12 @@ setting:
955955 please refer to <1>generative-ai-use-cases</1>.
956956 items :
957957 agent_enabled : Agent Enabled
958+ delete_all_chats : Delete All Conversation History
959+ delete_all_chats_button : Delete All History
960+ delete_all_chats_confirmation : Are you sure you want to delete all conversation history? This action cannot be undone.
961+ delete_all_chats_deleting : Deleting...
962+ delete_all_chats_failed : Failed to delete
963+ delete_all_chats_success : All conversation history has been deleted
958964 language : Language
959965 language_help : Change display language
960966 line_break_enter : Press Enter to create new line
Original file line number Diff line number Diff line change @@ -781,6 +781,12 @@ setting:
781781 <1>generative-ai-use-cases</1> をご参照ください。
782782 items :
783783 agent_enabled : Agent 有効
784+ delete_all_chats : すべての会話履歴を削除
785+ delete_all_chats_button : 全会話履歴削除
786+ delete_all_chats_confirmation : すべての会話履歴を削除しますか?この操作は取り消すことができません。
787+ delete_all_chats_deleting : 削除中...
788+ delete_all_chats_failed : 削除に失敗しました
789+ delete_all_chats_success : すべての会話履歴を削除しました
784790 language : 言語設定
785791 language_help : 表示言語を変更できます
786792 line_break_enter : Enter で改行
Original file line number Diff line number Diff line change @@ -544,6 +544,12 @@ setting:
544544 <1>generative-ai-use-cases</1>를 참조하세요.
545545 items :
546546 agent_enabled : 에이전트 활성화
547+ delete_all_chats : 모든 대화 기록 삭제
548+ delete_all_chats_button : 전체 대화 기록 삭제
549+ delete_all_chats_confirmation : 모든 대화 기록을 삭제하시겠습니까? 이 작업은 취소할 수 없습니다.
550+ delete_all_chats_deleting : 삭제 중...
551+ delete_all_chats_failed : 삭제에 실패했습니다
552+ delete_all_chats_success : 모든 대화 기록이 삭제되었습니다
547553 language : 언어
548554 language_help : 표시 언어 변경
549555 line_break_enter : Enter로 줄바꿈
Original file line number Diff line number Diff line change @@ -689,6 +689,12 @@ setting:
689689 การตั้งค่าสามารถเปลี่ยนแปลงได้โดยใช้ <0>AWS CDK</0> ไม่ใช่บนหน้าจอนี้ หากคุณพบข้อผิดพลาดเมื่อใช้ use cases โปรดตรวจสอบว่าคุณได้เปิดใช้งานโมเดลที่ระบุใน {{region}} สำหรับรายละเอียดเกี่ยวกับวิธีการทำเช่นนี้ โปรดดูที่ <1>generative-ai-use-cases</1>
690690 items :
691691 agent_enabled : เปิดใช้งานตัวแทน
692+ delete_all_chats : ลบประวัติการสนทนาทั้งหมด
693+ delete_all_chats_button : ลบประวัติทั้งหมด
694+ delete_all_chats_confirmation : คุณแน่ใจหรือไม่ว่าต้องการลบประวัติการสนทนาทั้งหมด? การกระทำนี้ไม่สามารถยกเลิกได้
695+ delete_all_chats_deleting : กำลังลบ...
696+ delete_all_chats_failed : การลบล้มเหลว
697+ delete_all_chats_success : ลบประวัติการสนทนาทั้งหมดแล้ว
692698 language : ภาษา
693699 language_help : เปลี่ยนภาษาที่แสดง
694700 line_break_enter : กด Enter เพื่อขึ้นบรรทัดใหม่
Original file line number Diff line number Diff line change @@ -667,6 +667,12 @@ setting:
667667 <1>generative-ai-use-cases</1>.
668668 items :
669669 agent_enabled : Agent được bật
670+ delete_all_chats : Xóa tất cả lịch sử hội thoại
671+ delete_all_chats_button : Xóa tất cả lịch sử
672+ delete_all_chats_confirmation : Bạn có chắc chắn muốn xóa tất cả lịch sử hội thoại không? Hành động này không thể hoàn tác.
673+ delete_all_chats_deleting : Đang xóa...
674+ delete_all_chats_failed : Xóa thất bại
675+ delete_all_chats_success : Đã xóa tất cả lịch sử hội thoại
670676 language : Cài đặt ngôn ngữ
671677 language_help : Có thể thay đổi ngôn ngữ hiển thị
672678 line_break_enter : Nhấn Enter để xuống dòng
Original file line number Diff line number Diff line change @@ -563,6 +563,12 @@ setting:
563563 请务必确认您是否在{{region}}中启用了指定的模型。有关各种方法, 请参考<1>generative-ai-use-cases</1>。
564564 items :
565565 agent_enabled : Agent已启用
566+ delete_all_chats : 删除所有对话历史
567+ delete_all_chats_button : 删除全部历史
568+ delete_all_chats_confirmation : 您确定要删除所有对话历史吗?此操作无法撤消。
569+ delete_all_chats_deleting : 删除中...
570+ delete_all_chats_failed : 删除失败
571+ delete_all_chats_success : 已删除所有对话历史
566572 language : 语言设置
567573 language_help : 可以更改显示语言
568574 rag_enabled : RAG (Amazon Kendra)已启用
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { BaseProps } from '../@types/common' ;
3+ import Button from './Button' ;
4+ import ModalDialog from './ModalDialog' ;
5+ import { useTranslation } from 'react-i18next' ;
6+
7+ type Props = BaseProps & {
8+ isOpen : boolean ;
9+ onDelete : ( ) => void ;
10+ onClose : ( ) => void ;
11+ } ;
12+
13+ const DialogConfirmDeleteAllChats : React . FC < Props > = ( props ) => {
14+ const { t } = useTranslation ( ) ;
15+
16+ return (
17+ < ModalDialog { ...props } title = { t ( 'chat.delete_confirmation' ) } >
18+ < div > { t ( 'setting.items.delete_all_chats_confirmation' ) } </ div >
19+
20+ < div className = "mt-4 flex justify-end gap-2" >
21+ < Button outlined onClick = { props . onClose } className = "p-2" >
22+ { t ( 'common.cancel' ) }
23+ </ Button >
24+ < Button
25+ onClick = { ( ) => {
26+ props . onDelete ( ) ;
27+ } }
28+ className = "bg-red-500 p-2 text-white" >
29+ { t ( 'common.delete' ) }
30+ </ Button >
31+ </ div >
32+ </ ModalDialog >
33+ ) ;
34+ } ;
35+
36+ export default DialogConfirmDeleteAllChats ;
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import {
1818 CreateShareIdResponse ,
1919 FindShareIdResponse ,
2020 GetSharedChatResponse ,
21+ Chat ,
2122} from 'generative-ai-use-cases' ;
2223import {
2324 LambdaClient ,
@@ -49,6 +50,29 @@ const useChatApi = () => {
4950 deleteChat : async ( chatId : string ) => {
5051 return http . delete < void > ( `chats/${ chatId } ` ) ;
5152 } ,
53+ deleteAllChats : async ( ) : Promise < void > => {
54+ let exclusiveStartKey : string | undefined = undefined ;
55+ let hasMore = true ;
56+
57+ while ( hasMore ) {
58+ const url : string = exclusiveStartKey
59+ ? `chats?exclusiveStartKey=${ exclusiveStartKey } `
60+ : 'chats' ;
61+ const res : AxiosResponse < ListChatsResponse > =
62+ await http . api . get < ListChatsResponse > ( url ) ;
63+ const chats = res . data . data ;
64+
65+ // Delete all chats in this page
66+ await Promise . all (
67+ chats . map ( ( chat : Chat ) =>
68+ http . delete < void > ( `chats/${ decomposeId ( chat . chatId ) } ` )
69+ )
70+ ) ;
71+
72+ exclusiveStartKey = res . data . lastEvaluatedKey ;
73+ hasMore = ! ! exclusiveStartKey ;
74+ }
75+ } ,
5276 listChats : ( ) => {
5377 const getKey = (
5478 pageIndex : number ,
Original file line number Diff line number Diff line change @@ -4,7 +4,12 @@ import { Chat } from 'generative-ai-use-cases';
44import usePagination from './usePagination' ;
55
66const useChatList = ( ) => {
7- const { listChats, deleteChat : deleteChatApi , updateTitle } = useChatApi ( ) ;
7+ const {
8+ listChats,
9+ deleteChat : deleteChatApi ,
10+ deleteAllChats : deleteAllChatsApi ,
11+ updateTitle,
12+ } = useChatApi ( ) ;
813 const {
914 data,
1015 flattenData : chats ,
@@ -40,6 +45,26 @@ const useChatList = () => {
4045 } ) ;
4146 } ;
4247
48+ const deleteAllChats = async ( ) => {
49+ // Clear all chats from cache optimistically
50+ mutate (
51+ produce ( data , ( draft ) => {
52+ if ( data && draft ) {
53+ for ( const d in data ) {
54+ draft [ d ] . data = [ ] ;
55+ }
56+ }
57+ } ) ,
58+ {
59+ revalidate : false ,
60+ }
61+ ) ;
62+
63+ return deleteAllChatsApi ( ) . finally ( ( ) => {
64+ mutate ( ) ;
65+ } ) ;
66+ } ;
67+
4368 const updateChatTitle = async ( chatId : string , title : string ) => {
4469 mutate (
4570 produce ( data , ( draft ) => {
@@ -83,6 +108,7 @@ const useChatList = () => {
83108 mutate,
84109 updateChatTitle,
85110 deleteChat,
111+ deleteAllChats,
86112 getChatTitle,
87113 canLoadMore,
88114 loadMore,
You can’t perform that action at this time.
0 commit comments