FIX: Update bedrock endpoint (#272)

* FIX: Update bedrock endpoint

AWS updated their endpoints per https://docs.aws.amazon.com/general/latest/gr/bedrock.html

* lint
This commit is contained in:
Rafael dos Santos Silva 2023-10-30 19:27:50 -03:00 committed by GitHub
parent 0c9e18799c
commit cbfd8507b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 8 deletions

View File

@ -27,13 +27,6 @@ module ::DiscourseAi
raise CompletionFailed if !SiteSetting.ai_bedrock_secret_access_key.present?
raise CompletionFailed if !SiteSetting.ai_bedrock_region.present?
url =
URI(
"https://bedrock.#{SiteSetting.ai_bedrock_region}.amazonaws.com/model/#{model}/invoke",
)
url.path = url.path + "-with-response-stream" if block_given?
headers = { "Content-Type" => "application/json" }
signer =
Aws::Sigv4::Signer.new(
access_key_id: SiteSetting.ai_bedrock_access_key_id,
@ -46,7 +39,8 @@ module ::DiscourseAi
response_data = +""
response_raw = +""
url_api = "https://bedrock.us-east-1.amazonaws.com/model/#{model}/"
url_api =
"https://bedrock-runtime.#{SiteSetting.ai_bedrock_region}.amazonaws.com/model/#{model}/"
if block_given?
url_api = url_api + "invoke-with-response-stream"
else