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

Invalid Request for Files.create_file #27

Open
bdtky opened this issue Jul 17, 2024 · 3 comments
Open

Invalid Request for Files.create_file #27

bdtky opened this issue Jul 17, 2024 · 3 comments

Comments

@bdtky
Copy link
Contributor

bdtky commented Jul 17, 2024

Hello 👋 and thank you for this neat library.

I ran into the issue below:

ExOpenAI.Files.create_file({"Test Document.pdf", testfile}, "assistants", openai_api_key: api_key)

{:error,
 %{
   "error" => %{
     "code" => nil,
     "message" => "Additional properties are not allowed ('openai_api_key' was unexpected)",
     "param" => nil,
     "type" => "invalid_request_error"
   }
 }}

I was able to fix locally with a modification to client.ex:

    multipart_body =
      {:multipart,
       params
+      |> Enum.into(%{})
+      |> Map.delete(:openai_organization_key)
+      |> Map.delete(:openai_api_key)
+      |> Map.to_list()
       |> Enum.map(&multipart_param/1)}

I'm happy to test further and contribute if appropriate.

@dvcrn
Copy link
Owner

dvcrn commented Jul 17, 2024

Thanks for spotting this. Can you create a PR to fix this issue?

The behaviour of stripping the args should probably be aligned with the other methods so we can just re-use the same thing

@bdtky
Copy link
Contributor Author

bdtky commented Jul 18, 2024

Sure! Giving it a try now

@dvcrn
Copy link
Owner

dvcrn commented Jul 18, 2024

Released in https://github.com/dvcrn/ex_openai/releases/tag/1.6.0

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