增加文本长度
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 54s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 54s
				
			This commit is contained in:
		
							parent
							
								
									1534a0228e
								
							
						
					
					
						commit
						99d6cb9f9f
					
				| @ -258,17 +258,32 @@ func (s *LLMService) handleStreamingResponse(req *http.Request, data map[string] | |||||||
| 				initialSessage += answer | 				initialSessage += answer | ||||||
| 				if containsPunctuation(initialSessage) { | 				if containsPunctuation(initialSessage) { | ||||||
| 					segments := splitByPunctuation(initialSessage) | 					segments := splitByPunctuation(initialSessage) | ||||||
| 					// fmt.Printf("原始文本: %s\n", initialSessage) | 					fmt.Printf("原始文本: %s\n", initialSessage) | ||||||
| 					// fmt.Printf("分割后的片段数量: %d\n", len(segments)) | 					fmt.Printf("分割后的片段数量: %d\n", len(segments)) | ||||||
| 					// for i, segment := range segments { | 					for i, segment := range segments { | ||||||
| 					// 	fmt.Printf("片段 %d: %s\n", i+1, segment) | 						fmt.Printf("片段 %d: %s\n", i+1, segment) | ||||||
| 					// } | 					} | ||||||
| 					if len(segments) > 1 { | 					if len(segments) > 1 { | ||||||
| 						initialSessage = segments[len(segments)-1] | 
 | ||||||
| 						new_message = strings.Join(segments[:len(segments)-1], "") | 						format_message := strings.Join(segments[:len(segments)-1], "") | ||||||
|  | 						// 检查initialSessage的字符长度是否超过10个 | ||||||
|  | 						if utf8.RuneCountInString(format_message) > 10 { | ||||||
|  | 							initialSessage = segments[len(segments)-1] | ||||||
|  | 							// 如果超过10个字符,将其添加到new_message中并清空initialSessage | ||||||
|  | 							new_message = strings.Join(segments[:len(segments)-1], "") | ||||||
|  | 							// initialSessage = "" | ||||||
|  | 						} else { | ||||||
|  | 							continue | ||||||
|  | 						} | ||||||
| 					} else { | 					} else { | ||||||
| 						new_message = initialSessage | 
 | ||||||
| 						initialSessage = "" | 						if utf8.RuneCountInString(initialSessage) > 10 { | ||||||
|  | 							new_message = initialSessage | ||||||
|  | 							initialSessage = "" | ||||||
|  | 						} else { | ||||||
|  | 							continue | ||||||
|  | 						} | ||||||
|  | 
 | ||||||
| 					} | 					} | ||||||
| 					// fmt.Printf("新消息: %s\n", new_message) | 					// fmt.Printf("新消息: %s\n", new_message) | ||||||
| 					// fmt.Printf("剩余文本: %s\n", initialSessage) | 					// fmt.Printf("剩余文本: %s\n", initialSessage) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Song367
						Song367