dvcrn / ex_openai

Auto-generated Elixir SDK for OpenAI APIs with full typespecs, docs and streaming support
MIT License
75 stars 29 forks source link

Invalid Request for `Files.create_file` #27

Open bdtky opened 1 month ago

bdtky commented 1 month ago

Hello :wave: 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 commented 1 month ago

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 commented 1 month ago

Sure! Giving it a try now

dvcrn commented 1 month ago

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