Spaces:
				
			
			
	
			
			
					
		Running
		
			on 
			
			CPU Upgrade
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
			on 
			
			CPU Upgrade
	Fix streaming extra new lines
Browse files
    	
        src/lib/components/InferencePlayground/InferencePlayground.svelte
    CHANGED
    
    | @@ -132,8 +132,8 @@ | |
| 132 | 
             
            		const hf = createHfInference(hfToken);
         | 
| 133 |  | 
| 134 | 
             
            		if (conversation.streaming) {
         | 
|  | |
| 135 | 
             
            			const streamingMessage = { role: "assistant", content: "" };
         | 
| 136 | 
            -
            			conversation.messages = [...conversation.messages, streamingMessage];
         | 
| 137 | 
             
            			const abortController = new AbortController();
         | 
| 138 | 
             
            			abortControllers.push(abortController);
         | 
| 139 |  | 
| @@ -143,6 +143,10 @@ | |
| 143 | 
             
            				content => {
         | 
| 144 | 
             
            					if (streamingMessage) {
         | 
| 145 | 
             
            						streamingMessage.content = content;
         | 
|  | |
|  | |
|  | |
|  | |
| 146 | 
             
            						session = session;
         | 
| 147 | 
             
            						generationStats[conversationIdx].generatedTokensCount += 1;
         | 
| 148 | 
             
            					}
         | 
|  | |
| 132 | 
             
            		const hf = createHfInference(hfToken);
         | 
| 133 |  | 
| 134 | 
             
            		if (conversation.streaming) {
         | 
| 135 | 
            +
            			let addStreamingMessage = true;
         | 
| 136 | 
             
            			const streamingMessage = { role: "assistant", content: "" };
         | 
|  | |
| 137 | 
             
            			const abortController = new AbortController();
         | 
| 138 | 
             
            			abortControllers.push(abortController);
         | 
| 139 |  | 
|  | |
| 143 | 
             
            				content => {
         | 
| 144 | 
             
            					if (streamingMessage) {
         | 
| 145 | 
             
            						streamingMessage.content = content;
         | 
| 146 | 
            +
            						if (addStreamingMessage) {
         | 
| 147 | 
            +
            							conversation.messages = [...conversation.messages, streamingMessage];
         | 
| 148 | 
            +
            							addStreamingMessage = false;
         | 
| 149 | 
            +
            						}
         | 
| 150 | 
             
            						session = session;
         | 
| 151 | 
             
            						generationStats[conversationIdx].generatedTokensCount += 1;
         | 
| 152 | 
             
            					}
         | 

