Skip to content

Commit

Permalink
only do with_indifferent_access on hash response
Browse files Browse the repository at this point in the history
  • Loading branch information
obie committed May 30, 2024
1 parent b9f5422 commit 86fcf13
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
open_router (0.3.1)
open_router (0.3.2)
activesupport (>= 6.0)
dotenv (>= 2)
faraday (>= 1)
Expand Down
4 changes: 3 additions & 1 deletion lib/open_router/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def complete(messages, model: "openrouter/auto", providers: [], transforms: [],
post(path: "/chat/completions", parameters:).tap do |response|
raise ServerError, response.dig("error", "message") if response.presence&.dig("error", "message").present?
raise ServerError, "Empty response from OpenRouter. Might be worth retrying once or twice." if stream.blank? && response.blank?
end.with_indifferent_access

return response.with_indifferent_access if response.is_a?(Hash)
end
end

# Fetches the list of available models from the OpenRouter API.
Expand Down
2 changes: 1 addition & 1 deletion lib/open_router/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module OpenRouter
VERSION = "0.3.1"
VERSION = "0.3.2"
end

0 comments on commit 86fcf13

Please sign in to comment.