fix:修正不额外添加\0。
This commit is contained in:
		
							parent
							
								
									2847a88525
								
							
						
					
					
						commit
						9127d48548
					
				@ -127,7 +127,7 @@ void Server::th_client(const std::shared_ptr<asio::ip::tcp::socket>& socket, con
 | 
			
		||||
                    auto parse = json_->parse(out);
 | 
			
		||||
                    FrameData req;
 | 
			
		||||
                    req.type = FrameType::TYPE_RESPONSE_SUCCESS;
 | 
			
		||||
                    req.len = parse.message_content.size() + 1;
 | 
			
		||||
                    req.len = parse.message_content.size();
 | 
			
		||||
                    req.data = new char[req.len];
 | 
			
		||||
                    req.protk = parse.prompt_tokens;
 | 
			
		||||
                    req.coptk = parse.completion_tokens;
 | 
			
		||||
@ -135,7 +135,6 @@ void Server::th_client(const std::shared_ptr<asio::ip::tcp::socket>& socket, con
 | 
			
		||||
                    use_tokens_ += req.coptk;
 | 
			
		||||
                    std::cout << "Already use " << use_tokens_ << " tokens.\n";
 | 
			
		||||
                    memcpy(req.data, parse.message_content.c_str(), parse.message_content.size());
 | 
			
		||||
                    req.data[req.len - 1] = '\0';
 | 
			
		||||
                    send_frame(socket, req);
 | 
			
		||||
                }
 | 
			
		||||
                ask_mutex_.unlock();
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user