Skip to content

Commit

Permalink
fix(AG-178): properly support all streaming content types
Browse files Browse the repository at this point in the history
  • Loading branch information
tysoekong authored and fffonion committed Nov 29, 2024
1 parent 08bf1a2 commit 34cd042
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions kong/llm/drivers/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ _M._CONST = {
["AWS_STREAM_CONTENT_TYPE"] = "application/vnd.amazon.eventstream",
}

_M._SUPPORTED_STREAMING_CONTENT_TYPES = {
["text/event-stream"] = true,
["application/vnd.amazon.eventstream"] = true,
["application/json"] = true,
}

_M.streaming_has_token_counts = {
["cohere"] = true,
["llama2"] = true,
Expand Down
2 changes: 1 addition & 1 deletion kong/llm/plugin/shared-filters/parse-sse-chunk.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ local function handle_streaming_frame(conf, chunk, finished)

local content_type = kong.service.response.get_header("Content-Type")
local normalized_content_type = content_type and content_type:sub(1, (content_type:find(";") or 0) - 1)
if normalized_content_type and normalized_content_type ~= "text/event-stream" and normalized_content_type ~= ai_shared._CONST.AWS_STREAM_CONTENT_TYPE then
if normalized_content_type and (not ai_shared._SUPPORTED_STREAMING_CONTENT_TYPES[normalized_content_type]) then
return true
end

Expand Down

0 comments on commit 34cd042

Please sign in to comment.