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

Add Support for Custom Headers in LLM Requests #169

Open
k1ng opened this issue Aug 24, 2023 · 3 comments
Open

Add Support for Custom Headers in LLM Requests #169

k1ng opened this issue Aug 24, 2023 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@k1ng
Copy link

k1ng commented Aug 24, 2023

Feature Description

To integrate and proxy requests from Zep through Portkey.ai, we need the ability to add custom headers to our requests to the LLM. Please note that Portkey.ai already has an integration with Langchain.

Portkey.ai requires certain specific headers to be passed in every API call, which can be found in their documentation: https://docs.portkey.ai/how-portkey-works/portkey-headers

Value of Feature

This feature will allow logging Zep's requests to LLM and calculating the cost of LLM calls as a part of Zep-Portkey.ai integration. Custom headers support could also be useful for other potential integrations and use-cases.

Possible Implementation

We could provide the ability to set custom headers through environment variables, a .env file, or the config.yaml file. This provides flexibility in choosing how to supply custom headers, depending on user preferences or security requirements.

Thank You.

@danielchalef
Copy link
Member

danielchalef commented Aug 26, 2023

Hey @k1ng , cool idea. Would you be open to contributing this functionality to the project? If so, I suggest the following approach:

Config

  1. Add the custom header option to ServerConfig:
    type ServerConfig struct {
  2. Add an example and comment to the config.yaml file. Comment out the config option as a default.
    server:
  3. OR if the header will include a secret, it should not be in the config file. Remove (2) above, and add the option to
    var EnvVars = map[string]string{

You may want to add two config options: One the header name and the other a secret, with the first being added in two above, but the secret kept to an environment variable only.

Add the header middleware

Create a new middleware function that pulls the header from appState.Config and adds it to the HTTP Header. See this example:

func SendVersion(next http.Handler) http.Handler {

Add the middleware to the Router

See here:

func setupRouter(appState *models.AppState) *chi.Mux {

Happy to answer any questions. Also, happy to review a rough PR and work with you to finalize it.

@k1ng
Copy link
Author

k1ng commented Aug 26, 2023

Hi @danielchalef,

Thank you very much for your detailed explanation, it is appreciated. I'd like to contribute, but unfortunately, I lack the necessary experience with Go to make a pull request at this time. I will definitely keep your guidance in mind and hopefully, in the future, I will be able to make more substantial contributions to the project.

@danielchalef danielchalef added the good first issue Good for newcomers label Sep 8, 2023
@danielchalef danielchalef added the enhancement New feature or request label Nov 2, 2023
@SpencerWightman
Copy link

I'd like to work on this issue. Could you please assign it to me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants