-
-
Notifications
You must be signed in to change notification settings - Fork 373
Description
Is your feature request related to a problem? Please describe.
Very similar to #333
I'm using a proxy for requests to OpenAI and want to attach arbitrary dynamic metadata to each request as headers. This enables us to log extra information on who's sending the request through our services.
Basically - user sends request to internal service, service builds the prompt, adds their user id as header, and sends request to proxy using ruby-openai
.
Current implementation only allows us to set a proxy on Client creation, but we cache it for multiple requests.
Describe the solution you'd like
Extra headers should be passed in with the rest of the request and merge into the extra_headers set in the Client.
def intitialize
@client = OpenAI::Client.new(...)
end
def request
@client.chat(
parameters: {
...
},
extra_headers: {
'x-something-userid': '123'
}
)
end
Describe alternatives you've considered
Creating a client per request.