Description
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
open-webui/backend/open_webui/retrieval/models/external.py
Lines 39 to 46 in 5eca495
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:
and get_rf is called from here:
open-webui/backend/open_webui/routers/retrieval.py
Lines 617 to 618 in 5eca495
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
.