[GH-ISSUE #15572] feat: ExternalReranker must honor ENABLE_FORWARD_USER_INFO_HEADERS parameter #56272

Closed
opened 2026-05-05 19:04:16 -05:00 by GiteaMirror · 9 comments
Owner

Originally created by @athoik on GitHub (Jul 7, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/15572

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

5eca495d3e/backend/open_webui/retrieval/models/external.py (L39-L46)

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: 5eca495d3e/backend/open_webui/routers/retrieval.py (L819)

and get_rf is called from here: 5eca495d3e/backend/open_webui/routers/retrieval.py (L617-L618)

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.

Originally created by @athoik on GitHub (Jul 7, 2025). Original GitHub issue: https://github.com/open-webui/open-webui/issues/15572 ### Check Existing Issues - [x] I have searched the existing issues and discussions. ### Problem Description External reranker currently doesn't honor the variable `ENABLE_FORWARD_USER_INFO_HEADERS` https://github.com/open-webui/open-webui/blob/5eca495d3e3b3066e7831141ed2adffbd6d179b4/backend/open_webui/retrieval/models/external.py#L39-L46 ### 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: https://github.com/open-webui/open-webui/blob/5eca495d3e3b3066e7831141ed2adffbd6d179b4/backend/open_webui/routers/retrieval.py#L819 and get_rf is called from here: https://github.com/open-webui/open-webui/blob/5eca495d3e3b3066e7831141ed2adffbd6d179b4/backend/open_webui/routers/retrieval.py#L617-L618 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`.
Author
Owner

@tjbck commented on GitHub (Jul 8, 2025):

PR Welcome!

<!-- gh-comment-id:3048584786 --> @tjbck commented on GitHub (Jul 8, 2025): PR Welcome!
Author
Owner

@rgaricano commented on GitHub (Jul 8, 2025):

PR: https://github.com/open-webui/open-webui/pull/15586

(sorry for the two wrong closed pulls)

<!-- gh-comment-id:3048922366 --> @rgaricano commented on GitHub (Jul 8, 2025): PR: https://github.com/open-webui/open-webui/pull/15586 (sorry for the two wrong closed pulls)
Author
Owner

@athoik commented on GitHub (Jul 8, 2025):

I think now i've got it how we are getting user variable :)

user=Depends(get_verified_user),

I was missing that part in my original qustion. @rgaricano thanks for taking over the PR.

<!-- gh-comment-id:3049989952 --> @athoik commented on GitHub (Jul 8, 2025): I think now i've got it how we are getting user variable :) ``` user=Depends(get_verified_user), ``` I was missing that part in my original qustion. @rgaricano thanks for taking over the PR.
Author
Owner

@rgaricano commented on GitHub (Jul 8, 2025):

I just assignate it directly in function def, but as it's now probably is more clear.

But I having problems to test it, when I switch on hybrid mode & save it allways switch off again!

<!-- gh-comment-id:3050379103 --> @rgaricano commented on GitHub (Jul 8, 2025): I just assignate it directly in function def, but as it's now probably is more clear. But I having problems to test it, when I switch on hybrid mode & save it allways switch off again!
Author
Owner

@athoik commented on GitHub (Jul 9, 2025):

@rgaricano it was tricky to fix it, but figure out how to do it... thanks for your efford. I added you as co-author on the commit.

A new PR created https://github.com/open-webui/open-webui/pull/15615

<!-- gh-comment-id:3054078878 --> @athoik commented on GitHub (Jul 9, 2025): @rgaricano it was tricky to fix it, but figure out how to do it... thanks for your efford. I added you as co-author on the commit. A new PR created https://github.com/open-webui/open-webui/pull/15615
Author
Owner

@rgaricano commented on GitHub (Jul 9, 2025):

Yes, similar solution as I did, but I used Users instead UserModel. By the way I found some other functions that might also need to add user.

<!-- gh-comment-id:3054412653 --> @rgaricano commented on GitHub (Jul 9, 2025): Yes, similar solution as I did, but I used Users instead UserModel. By the way I found some other functions that might also need to add user.
Author
Owner

@athoik commented on GitHub (Jul 11, 2025):

PR Welcome!

@tjbck PR created in collaboration with @rgaricano

https://github.com/open-webui/open-webui/pull/15615

<!-- gh-comment-id:3063102937 --> @athoik commented on GitHub (Jul 11, 2025): > PR Welcome! @tjbck PR created in collaboration with @rgaricano https://github.com/open-webui/open-webui/pull/15615
Author
Owner

@tjbck commented on GitHub (Jul 14, 2025):

Thanks everyone!

<!-- gh-comment-id:3068874750 --> @tjbck commented on GitHub (Jul 14, 2025): Thanks everyone!
Author
Owner

@athoik commented on GitHub (Jul 14, 2025):

You did it much beter @tjbck ! Thank you! You Rock! 🥇

<!-- gh-comment-id:3070063248 --> @athoik commented on GitHub (Jul 14, 2025): You did it much beter @tjbck ! Thank you! You Rock! 🥇
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#56272