Skip to content

Commit fdf9c72

Browse files
committed
Clear the chat history from local storage once the chat session is closed in UI
1 parent ae64261 commit fdf9c72

File tree

3 files changed

+122
-120
lines changed

3 files changed

+122
-120
lines changed

app/api/chat/route.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createParser, ParsedEvent, ReconnectInterval } from 'eventsource-parser'
22
import { NextRequest, NextResponse } from 'next/server'
33

4-
export const runtime = 'edge';
4+
export const runtime = 'edge'
55

66
export interface Message {
77
role: string
@@ -83,7 +83,7 @@ const getOpenAIStream = async (
8383
body: JSON.stringify({
8484
model: model,
8585
frequency_penalty: 0,
86-
max_tokens: 2000,
86+
max_tokens: 4000,
8787
messages: messages,
8888
presence_penalty: 0,
8989
stream: true,

components/Chat/useChatHook.ts

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ const useChatHook = () => {
131131
const index = chatList.findIndex((item) => item.id === chat.id)
132132
chatList.splice(index, 1)
133133
setChatList([...chatList])
134+
localStorage.removeItem(`ms_${chat.id}`)
134135
if (currentChatRef.current?.id === chat.id) {
135136
currentChatRef.current = chatList[0]
136137
}

0 commit comments

Comments
 (0)