Skip to content

feat: ExternalReranker must honor ENABLE_FORWARD_USER_INFO_HEADERS parameter #15572

Open
@athoik

Description

@athoik

Check Existing Issues

  • I have searched the existing issues and discussions.

Problem Description

External reranker currently doesn't honor the variable ENABLE_FORWARD_USER_INFO_HEADERS

r = requests.post(
f"{self.url}",
headers={
"Content-Type": "application/json",
"Authorization": f"Bearer {self.api_key}",
},
json=payload,
)

Desired Solution you'd like

It would be great if we could add the handling of ENABLE_FORWARD_USER_INFO_HEADERS

We need more or less the following:

 r = requests.post( 
     f"{self.url}", 
     headers={ 
         "Content-Type": "application/json", 
         "Authorization": f"Bearer {self.api_key}",
          **(
              {
                  "X-OpenWebUI-User-Name": user.name,
                  "X-OpenWebUI-User-Id": user.id,
                  "X-OpenWebUI-User-Email": user.email,
                  "X-OpenWebUI-User-Role": user.role,
              }
              if ENABLE_FORWARD_USER_INFO_HEADERS and user
              else {}
     }, 
     json=payload, 
 ) 

Getting the ENABLE_FORWARD_USER_INFO_HEADERS is straight forward.

from open_webui.env import (
    ENABLE_FORWARD_USER_INFO_HEADERS,
)

But getting the user: UserModel = None is not very clear.

We are calling ExternaReranker from here:

request.app.state.rf = get_rf(

and get_rf is called from here:

async def update_rag_config(
request: Request, form_data: ConfigForm, user=Depends(get_admin_user)

Is it enough to use the user variable?

Can you please assist to add that missing feature? @tjbck

Alternatives Considered

None, there is no alternative.

Additional Context

Having that feature it's possible now to track spending on LiteLLM: https://docs.litellm.ai/docs/tutorials/openweb_ui#add-custom-headers-to-spend-tracking

Currently requests using external reranker do not contain information about user, because we do not honor the ENABLE_FORWARD_USER_INFO_HEADERS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions