fix: bedrock exception could be found at end of a stream (#2654)
This commit is contained in:
BIN
tests/data/bedrock_response_stream.bin
Normal file
BIN
tests/data/bedrock_response_stream.bin
Normal file
Binary file not shown.
BIN
tests/data/bedrock_response_stream_with_exception.bin
Normal file
BIN
tests/data/bedrock_response_stream_with_exception.bin
Normal file
Binary file not shown.
@@ -1,6 +1,37 @@
|
||||
local bedrock_provider = require("avante.providers.bedrock")
|
||||
|
||||
local test_util = require("avante.utils.test")
|
||||
local Config = require("avante.config")
|
||||
Config.setup({})
|
||||
|
||||
describe("bedrock_provider", function()
|
||||
describe("parse_stream_data", function()
|
||||
it("should parse response in a stream.", function()
|
||||
local data = test_util.read_file("tests/data/bedrock_response_stream.bin")
|
||||
local message = ""
|
||||
bedrock_provider:parse_stream_data({}, data, {
|
||||
on_chunk = function(msg) message = message .. msg end,
|
||||
on_stop = function() end,
|
||||
})
|
||||
assert.equals(
|
||||
"I'll help you fix errors in the HelloLog4j.java file. Let me first understand what errors might be present by examining the code and related files.",
|
||||
message
|
||||
)
|
||||
end)
|
||||
|
||||
it("should parse exception inside a stream.", function()
|
||||
local data = test_util.read_file("tests/data/bedrock_response_stream_with_exception.bin")
|
||||
local message = ""
|
||||
bedrock_provider:parse_stream_data({}, data, {
|
||||
on_chunk = function(msg) message = msg end,
|
||||
})
|
||||
assert.equals(
|
||||
"- Too many requests, please wait before trying again. You have sent too many requests. Wait before trying again.",
|
||||
message
|
||||
)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("check_curl_version_supports_aws_sig", function()
|
||||
it(
|
||||
"should return true for curl version 8.10.0",
|
||||
|
||||
Reference in New Issue
Block a user