fix: Gemini not reaching end state (#1027)
This commit is contained in:
		
							parent
							
								
									0536c6e552
								
							
						
					
					
						commit
						369410bdb1
					
				@ -69,8 +69,13 @@ M.parse_response = function(data_stream, _, opts)
 | 
				
			|||||||
  if not ok then opts.on_complete(json) end
 | 
					  if not ok then opts.on_complete(json) end
 | 
				
			||||||
  if json.candidates then
 | 
					  if json.candidates then
 | 
				
			||||||
    if #json.candidates > 0 then
 | 
					    if #json.candidates > 0 then
 | 
				
			||||||
 | 
					      if json.candidates[1].finishReason and json.candidates[1].finishReason == "STOP" then
 | 
				
			||||||
        opts.on_chunk(json.candidates[1].content.parts[1].text)
 | 
					        opts.on_chunk(json.candidates[1].content.parts[1].text)
 | 
				
			||||||
    elseif json.candidates.finishReason and json.candidates.finishReason == "STOP" then
 | 
					        opts.on_complete(nil)
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					        opts.on_chunk(json.candidates[1].content.parts[1].text)
 | 
				
			||||||
 | 
					      end
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
      opts.on_complete(nil)
 | 
					      opts.on_complete(nil)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user