From f105c2182b2f339372f3bc5b4c0e986fb514bc64 Mon Sep 17 00:00:00 2001 From: Jack Tysoe Date: Tue, 18 Jun 2024 11:29:36 +0100 Subject: [PATCH] fix(ai-proxy): test-mode for streaming tests (cherry picked from commit 116f01754911ed80bbe1df20f1546077d908aed1) --- kong/llm/drivers/shared.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kong/llm/drivers/shared.lua b/kong/llm/drivers/shared.lua index 139c4ef6da5d..2e36a5221425 100644 --- a/kong/llm/drivers/shared.lua +++ b/kong/llm/drivers/shared.lua @@ -197,9 +197,9 @@ end function _M.frame_to_events(frame) local events = {} - -- todo check if it's raw json and + -- Cohere / Other flat-JSON format parser -- just return the split up data frame - if (not kong.ctx.plugin.truncated_frame) and string.sub(str_ltrim(frame), 1, 1) == "{" then + if (not kong or not kong.ctx.plugin.truncated_frame) and string.sub(str_ltrim(frame), 1, 1) == "{" then for event in frame:gmatch("[^\r\n]+") do events[#events + 1] = { data = event,