Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Update README.md #389

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ const messages = [
];

const App = () => (
<div>
<>
<Bubble.List items={messages} />
<Sender />
</div>
</>
);

export default App;
Expand Down Expand Up @@ -142,11 +142,8 @@ const Component: React.FC = () => {
},
onUpdate: (chunk) => {
console.log('sse object', chunk);

const data = JSON.parse(chunk.data);

content += data?.choices[0].delta.content;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that chunk.data is always a valid JSON string to avoid runtime errors with JSON.parse. Consider adding error handling for JSON.parse to catch any potential exceptions.


onUpdate(content);
},
},
Expand All @@ -157,7 +154,7 @@ const Component: React.FC = () => {
},
});

function onRequest(message: string) {
const onSubmit = (message: string) => {
agent.request(
{ message },
{
Expand All @@ -166,9 +163,9 @@ const Component: React.FC = () => {
onError: () => {},
},
);
}
};

return <Sender onSubmit={onRequest} />;
return <Sender onSubmit={onSubmit} />;
};
```

Expand Down Expand Up @@ -214,7 +211,6 @@ const Demo: React.FC = () => {

for await (const chunk of stream) {
content += chunk.choices[0]?.delta?.content || '';

onUpdate(content);
}

Expand All @@ -240,10 +236,10 @@ const Demo: React.FC = () => {
}));

return (
<div>
<>
<Bubble.List items={items} />
<Sender onSubmit={onRequest} />
</div>
</>
);
};

Expand Down
Loading