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

Allow arbitrary HTTP headers to be added to requests #109

Merged
merged 4 commits into from
Oct 18, 2024

Conversation

kofron
Copy link

@kofron kofron commented Oct 13, 2024

Adds a single function, with_additional_headers/1 that adds whatever heads the caller wants to the base request.

This is useful for e.g. using portkey's LLM gateway.

@restlessronin
Copy link
Member

@kofron Have you tested this against portkey?

It might be a little more expressive for the additional headers to be a key-value map, rather than a header string.

I think we should also have an example in the user guide showing the exact call for the portkey sample.

You'll also have to run 'mix format' for the CI tests to pass.

@kofron
Copy link
Author

kofron commented Oct 15, 2024

@kofron Have you tested this against portkey?

Sure have! Works a charm.

It might be a little more expressive for the additional headers to be a key-value map, rather than a header string.

I like this suggestion, done.

I think we should also have an example in the user guide showing the exact call for the portkey sample.

Sounds good, happy to do that - how does one update the user guide. FWIW, it looks like this:

OpenaiEx.new(open_ai_api_key) 
|> OpenaiEx.with_base_url("https://api.portkey.ai/v1") 
|> OpenaiEx.with_additional_headers(%{"x-portkey-api-key"=>portkey_api_key, "x-portkey-provider"=>"openai"})

You'll also have to run 'mix format' for the CI tests to pass.

Done.

@restlessronin
Copy link
Member

restlessronin commented Oct 15, 2024

@kofron Looks good. The user guide is a livebook, so all the examples are executable. This probably belongs as a new subsection in the "Configuration" section between subsections "Base Url" and "Azure OpenAI".

If you could delete the @spec line (since we're not using those ATM), and add the doc to the user guide, we're good to go.

@kofron
Copy link
Author

kofron commented Oct 17, 2024

@restlessronin should be all set

@restlessronin restlessronin merged commit 10e8d7e into cyberchitta:main Oct 18, 2024
1 check passed
@restlessronin
Copy link
Member

@kofron Merged. Thanks much 🙏🏾🙏🏾 for the PR.

@kofron
Copy link
Author

kofron commented Oct 18, 2024

@restlessronin awesome, thanks for the library!

What's the release cycle like for this hitting hex.pm?

@restlessronin
Copy link
Member

@kofron I just published v0.8.4 on hex.pm with the latest changes.

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

Successfully merging this pull request may close these issues.

2 participants