Skip to content

Commit

Permalink
fix(ai): fix Azure streaming with raw JSON transmission mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tysoekong committed Jan 14, 2025
1 parent 9c48b27 commit 6f19595
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kong/llm/drivers/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ function _M.frame_to_events(frame, content_type)
-- some new LLMs return the JSON object-by-object,
-- because that totally makes sense to parse?!
local frame_start = frame and frame:sub(1, 1)
if frame_start == "," or frame_start == "[" then
if (not kong or not kong.ctx.plugin.truncated_frame) and (frame_start == "," or frame_start == "[") then
local done = false

-- if this is the first frame, it will begin with array opener '['
Expand Down Expand Up @@ -416,7 +416,7 @@ function _M.frame_to_events(frame, content_type)
if #dat > 0 and #event_lines == i then
ngx.log(ngx.DEBUG, "[ai-proxy] truncated sse frame head")
if kong then
kong.ctx.plugin.truncated_frame = dat
kong.ctx.plugin.truncated_frame = fmt("%s%s", (kong.ctx.plugin.truncated_frame or ""), dat)
end

break -- stop parsing immediately, server has done something wrong
Expand Down

0 comments on commit 6f19595

Please sign in to comment.