From 0fcf357575972a1942f57f80da53b6f9c16e5773 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 21 Dec 2024 18:10:57 +0800 Subject: [PATCH] Update README.md --- README.md | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index e18aaf30..4ab774ba 100644 --- a/README.md +++ b/README.md @@ -87,10 +87,10 @@ const messages = [ ]; const App = () => ( -
+ <> -
+ ); export default App; @@ -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; - onUpdate(content); }, }, @@ -157,7 +154,7 @@ const Component: React.FC = () => { }, }); - function onRequest(message: string) { + const onSubmit = (message: string) => { agent.request( { message }, { @@ -166,9 +163,9 @@ const Component: React.FC = () => { onError: () => {}, }, ); - } + }; - return ; + return ; }; ``` @@ -214,7 +211,6 @@ const Demo: React.FC = () => { for await (const chunk of stream) { content += chunk.choices[0]?.delta?.content || ''; - onUpdate(content); } @@ -240,10 +236,10 @@ const Demo: React.FC = () => { })); return ( -
+ <> -
+ ); };