Skip to content

Commit

Permalink
Merge pull request #491 from aws-samples/avoid-content-of-undefined
Browse files Browse the repository at this point in the history
エラーの回避 Cannot read properties of undefined (reading 'content')
  • Loading branch information
wadabee committed May 8, 2024
2 parents a768997 + 777639b commit ad37882
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/web/src/hooks/useChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,13 @@ const useChatState = create<{
const chat = get().chats[id];

if (chat) {
return chat.messages.filter((message) => message.role === 'system')[0]
.content;
const systemMessage = chat.messages.filter(
(message) => message.role === 'system'
)[0];

if (systemMessage) {
return systemMessage.content;
}
}

return '';
Expand Down

0 comments on commit ad37882

Please sign in to comment.