Skip to content

Commit

Permalink
fix bedrock lints
Browse files Browse the repository at this point in the history
  • Loading branch information
tysoekong committed Jul 25, 2024
1 parent c7275f9 commit fa52c16
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 27 deletions.
5 changes: 1 addition & 4 deletions kong/llm/drivers/bedrock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ local fmt = string.format
local ai_shared = require("kong.llm.drivers.shared")
local socket_url = require("socket.url")
local string_gsub = string.gsub
local buffer = require("string.buffer")
local table_insert = table.insert
local string_lower = string.lower
local string_sub = string.sub
local signer = require("resty.aws.request.sign")
--

Expand Down Expand Up @@ -122,8 +120,7 @@ local function handle_stream_event(event_t, model_info, route_type)

new_event = "[DONE]"

elseif event_type == "contentBlockStop" then
-- placeholder - I don't think this does anything yet
-- "contentBlockStop" is absent because it is not used for anything here
end

if new_event then
Expand Down
7 changes: 0 additions & 7 deletions kong/llm/drivers/gemini.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ local function is_response_content(content)
and content.candidates[1].content.parts[1].text
end

local function is_response_finished(content)
return content
and content.candidates
and #content.candidates > 0
and content.candidates[1].finishReason
end

local function handle_stream_event(event_t, model_info, route_type)
-- discard empty frames, it should either be a random new line, or comment
if (not event_t.data) or (#event_t.data < 1) then
Expand Down
1 change: 0 additions & 1 deletion kong/plugins/ai-proxy/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ local kong_utils = require("kong.tools.gzip")
local kong_meta = require("kong.meta")
local buffer = require "string.buffer"
local strip = require("kong.tools.utils").strip
local to_hex = require("resty.string").to_hex

-- cloud auth/sdk providers
local GCP_SERVICE_ACCOUNT do
Expand Down
25 changes: 10 additions & 15 deletions kong/tools/aws_stream.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,20 @@ function Stream:next_message()
-- this is a chicken and egg problem, because we need to
-- read the message to get the length, to then re-read the
-- whole message at correct offset
local msg_len, orig_len, err = self:next_int(32)
local msg_len, _, err = self:next_int(32)
if err then
return err
end

-- get the headers length
local headers_len, orig_headers_len, err = self:next_int(32)
local headers_len, _, err = self:next_int(32)
if err then
return err
end

-- get the preamble checksum
local preamble_checksum, orig_preamble_checksum, err = self:next_int(32)

-- TODO: calculate checksum
-- local result = crc32(orig_len .. origin_headers_len, preamble_checksum)
-- if not result then
-- return nil, "preamble checksum failed - message is corrupted"
-- end
-- skip it because we're not using UDP
self:next_int(32)

-- pull the headers from the buf
local headers = {}
Expand Down Expand Up @@ -167,12 +165,9 @@ function Stream:next_message()
local body = self:next_utf_8(msg_len - self.read_count - 4)

-- last 4 bytes is a body checksum
local msg_checksum = self:next_int(32)
-- TODO CHECK FULL MESSAGE CHECKSUM
-- local result = crc32(original_full_msg, msg_checksum)
-- if not result then
-- return nil, "preamble checksum failed - message is corrupted"
-- end
-- skip it because we're not using UDP
self:next_int(32)


-- rewind the tape
self.read_count = 0
Expand Down

0 comments on commit fa52c16

Please sign in to comment.