From 6573d49f01024dd7924e4084bd49ddf059d23c30 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 23 Dec 2024 10:31:38 +0800 Subject: [PATCH] docs: Update README.md (#389) --- 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 ( -
+ <> -
+ ); };