DEV: Log error responses on Gemini / Cloudflare embeddings requests (#736)
This commit is contained in:
parent
9d887ad4ac
commit
7dc0a2a20a
|
@ -19,7 +19,17 @@ module ::DiscourseAi
|
|||
|
||||
raise Net::HTTPBadResponse if ![200].include?(response.status)
|
||||
|
||||
case response.status
|
||||
when 200
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
when 429
|
||||
# TODO add a AdminDashboard Problem?
|
||||
else
|
||||
Rails.logger.warn(
|
||||
"Cloudflare Workers AI Embeddings failed with status: #{response.status} body: #{response.body}",
|
||||
)
|
||||
raise Net::HTTPBadResponse
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,9 +14,17 @@ module ::DiscourseAi
|
|||
conn = Faraday.new { |f| f.adapter FinalDestination::FaradayAdapter }
|
||||
response = conn.post(url, body.to_json, headers)
|
||||
|
||||
raise Net::HTTPBadResponse if ![200].include?(response.status)
|
||||
|
||||
case response.status
|
||||
when 200
|
||||
JSON.parse(response.body, symbolize_names: true)
|
||||
when 429
|
||||
# TODO add a AdminDashboard Problem?
|
||||
else
|
||||
Rails.logger.warn(
|
||||
"Google Gemini Embeddings failed with status: #{response.status} body: #{response.body}",
|
||||
)
|
||||
raise Net::HTTPBadResponse
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue