alexrudall / ruby-openai

OpenAI API + Ruby! 🤖❤️ NEW: Assistant Vector Stores
MIT License
2.73k stars 321 forks source link

Merge extra headers into request headers for more flexibility #354

Closed deikka closed 10 months ago

deikka commented 11 months ago

The http.rb file now merges extra headers into the request headers, allowing for more flexibility in the headers that can be sent with each request. This change is particularly useful when there are headers specific to a certain request that are not included in the default headers.

OpenAI::Client.new.chat(
      parameters: {
        model: 'gpt-3.5-turbo',
        messages: Message.for_openai(trip.messages),
        temperature: 0.1,
        stream: stream_proc(message:),
        extra_headers: {
          'Helicone-Property-Conversation': 'conversation-123'
        }
      }
    )
  end

The http_spec.rb file now includes a test to ensure that these extra headers are correctly included in the chat request.

Related issue

All Submissions:

alexrudall commented 10 months ago

Thanks for your work on this @deikka! It ended up getting resolved in a slightly different way: See here

deikka commented 10 months ago

Thank you, @alexrudall I couldn't give it the care it deserved ;) I like how you did it.

alexrudall commented 10 months ago

Thank you, @alexrudall I couldn't give it the care it deserved ;) I like how you did it.

No worries! That would be @Haegin, I just merge things ;)