Skip to content

Commit

Permalink
fix: usage clear issue and response status issue for done
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu-xiaowei committed Nov 20, 2024
1 parent 50a9125 commit c525c46
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions react-native/src/api/bedrock-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ export const invokeBedrockWithCallBack = async (
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) {
break;
}
const chunk = decoder.decode(value, { stream: true });
if (
chunk[chunk.length - 1] === '}' &&
Expand All @@ -95,7 +92,10 @@ export const invokeBedrockWithCallBack = async (
callback(completeMessage, true, false, usage);
} else {
completeMessage += chunk;
callback(completeMessage, false, false);
callback(completeMessage, done, false);
}
if (done) {
break;
}
}
})
Expand Down
1 change: 1 addition & 0 deletions react-native/src/chat/ChatScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ function ChatScreen(): React.JSX.Element {
modeRef.current = mode;
setChatStatus(ChatStatus.Init);
sendEventRef.current('');
setUsage(undefined);
if (initialSessionId === 0 || initialSessionId === -1) {
startNewChat.current();
return;
Expand Down

0 comments on commit c525c46

Please sign in to comment.