Skip to content

Commit

Permalink
Clear the chat history from local storage once the chat session is cl…
Browse files Browse the repository at this point in the history
…osed in UI (#54)

- Clears chat history from local storage when the chat session is closed
in the UI.
- Fixes CI lint errors.
- Updates the default max token response to 4000.
  • Loading branch information
blrchen authored May 5, 2024
1 parent ae64261 commit 5613aba
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 120 deletions.
4 changes: 2 additions & 2 deletions app/api/chat/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createParser, ParsedEvent, ReconnectInterval } from 'eventsource-parser'
import { NextRequest, NextResponse } from 'next/server'

export const runtime = 'edge';
export const runtime = 'edge'

export interface Message {
role: string
Expand Down Expand Up @@ -83,7 +83,7 @@ const getOpenAIStream = async (
body: JSON.stringify({
model: model,
frequency_penalty: 0,
max_tokens: 2000,
max_tokens: 4000,
messages: messages,
presence_penalty: 0,
stream: true,
Expand Down
1 change: 1 addition & 0 deletions components/Chat/useChatHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ const useChatHook = () => {
const index = chatList.findIndex((item) => item.id === chat.id)
chatList.splice(index, 1)
setChatList([...chatList])
localStorage.removeItem(`ms_${chat.id}`)
if (currentChatRef.current?.id === chat.id) {
currentChatRef.current = chatList[0]
}
Expand Down
Loading

0 comments on commit 5613aba

Please sign in to comment.