Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 Error from Azure API from version 7.3.0 #531

Closed
ymtdzzz opened this issue Oct 15, 2024 · 4 comments
Closed

404 Error from Azure API from version 7.3.0 #531

ymtdzzz opened this issue Oct 15, 2024 · 4 comments

Comments

@ymtdzzz
Copy link

ymtdzzz commented Oct 15, 2024

Describe the bug
From the version 7.3.0, Faraday::ResourceNotFound: the server responded with status 404 occurs when calling #embeddings method to send a request to Azure.

To Reproduce
Steps to reproduce the behavior:

  1. Configure to use Azure OpenAI
OpenAI.configure do |config|
  config.access_token = ENV.fetch("AZURE_OPENAI_API_ACCESS_TOKEN", "")
  config.uri_base = ENV.fetch("AZURE_OPENAI_API_URI_BASE", "")
  config.api_type = :azure
  config.api_version = ENV.fetch("AZURE_OPENAI_API_VERSION", "")
  config.request_timeout = 60
end
  1. Call #embeddings
> client = OpenAI::Client.new
> client.embeddings(parameters: {model: "text-embedding-3-small", input: "test-input"})
  1. See error
Faraday::ResourceNotFound: the server responded with status 404
from /Users/your-name/.asdf/installs/ruby/3.2.5/lib/ruby/gems/3.2.0/gems/faraday-1.10.4/lib/faraday/response/raise_error.rb:22:in `on_complete'

I have confirmed that it works on the version 7.2.0

Expected behavior
No errors occurred

Screenshots
N/A

Desktop :

  • OS: macOS (Sonoma 14.6.1)
  • Browser: N/A
  • Version: N/A

Possible solution
Maybe the following change might be the cause:

#527

def json_post(path:, parameters:, query_parameters: {})
conn.post(uri(path: path)) do |req|
configure_json_post_request(req, parameters)
req.params = query_parameters
end&.body
end

def uri(path:)
if azure?
base = File.join(@uri_base, path)
"#{base}?api-version=#{@api_version}"

If we use Azure, req.params already has the api_key param. So should we merge query_params instead of overwriting ?

@ymtdzzz ymtdzzz changed the title 404 Error on Azure from version 7.3.0 404 Error from Azure API from version 7.3.0 Oct 15, 2024
@alexrudall
Copy link
Owner

Hi @ymtdzzz, thank you for the clearly specified issue and apologies for any inconvenience. Would you be able to test if #532 does indeed fix the issue? Thank you.

@ymtdzzz
Copy link
Author

ymtdzzz commented Oct 15, 2024

@alexrudall , thanks for your rapid response!
#532 seems to fix this issue 👍

[3] pry(main)> OpenAI::VERSION
=> "7.3.1"
[4] pry(main)> response = client.embeddings(parameters: {model: "text-embedding-3-small", input: "test-input"})
[5] pry(main)> response.dig("data", 0, "embedding").length
=> 1536

@alexrudall
Copy link
Owner

@alexrudall , thanks for your rapid response! #532 seems to fix this issue 👍

[3] pry(main)> OpenAI::VERSION
=> "7.3.1"
[4] pry(main)> response = client.embeddings(parameters: {model: "text-embedding-3-small", input: "test-input"})
[5] pry(main)> response.dig("data", 0, "embedding").length
=> 1536

Thank you @ymtdzzz, v7.3.1 is now released and contains the fix.

@ymtdzzz
Copy link
Author

ymtdzzz commented Oct 15, 2024

Thanks! This issue is fixed so I close it.

@ymtdzzz ymtdzzz closed this as completed Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants