File tree Expand file tree Collapse file tree
apps/app/src/components/general/app_settings/editor/lm_config/local Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<script lang =" ts" >
22 import { invoke } from ' @tauri-apps/api/core' ;
33 import { LLMStreamListener } from ' tauri-plugin-llm-api' ;
4+ import { onMount } from ' svelte' ;
5+
46 const listener = new LLMStreamListener ();
5- let text = $state <string >();
6- listener .setup ({
7- onData : (id , data , timestamp ) => {
8- text = new TextDecoder ().decode (data );
9- console .log (text );
10- },
11- onError : (msg ) => console .error (' Error:' , msg ),
12- onEnd : (usage ) => {
13- if (usage ) {
14- console .log (` Done. ${usage .total_tokens } tokens used. ` );
15- }
16- },
7+ let text = $state <string >(' hi' );
8+
9+ onMount (async () => {
10+ await listener .setup ({
11+ onData : (id , data , timestamp ) => {
12+ const chunk = new TextDecoder ().decode (data );
13+ text += chunk ;
14+ console .log (' Incoming chunk:' , chunk );
15+ },
16+ onError : (msg ) => console .error (' Error:' , msg ),
17+ onEnd : (usage ) => {
18+ if (usage ) {
19+ console .log (` Done. ${usage .total_tokens } tokens used. ` );
20+ }
21+ },
22+ });
1723 });
1824 </script >
1925
You can’t perform that action at this time.
0 commit comments