aboutsummaryrefslogtreecommitdiff
path: root/agent/orchestrator/api.py
diff options
context:
space:
mode:
Diffstat (limited to 'agent/orchestrator/api.py')
-rw-r--r--agent/orchestrator/api.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/agent/orchestrator/api.py b/agent/orchestrator/api.py
index c3582d4..956f7b5 100644
--- a/agent/orchestrator/api.py
+++ b/agent/orchestrator/api.py
@@ -24,6 +24,7 @@ class ChatCompletionRequest(BaseModel):
model_config = ConfigDict(extra="allow")
model: str
messages: list[ChatMessage]
+ user: str | None = None
@app.get("/v1/models")
@@ -36,9 +37,15 @@ def list_models():
@app.post("/v1/chat/completions")
def chat_completions(req: ChatCompletionRequest):
+ # Open WebUI sends user info via custom headers when ENABLE_FORWARD_USER_INFO_HEADERS=true
+ user_name = request.headers.get("x-openwebui-user-name")
+ user_email = request.headers.get("x-openwebui-user-email")
+ # prefer name (friendlier), fall back to email, fall back to None
+ user = user_name or user_email
try:
response_text = handle_turn(
messages=[Message(role=m.role, content=m.content) for m in req.messages],
+ user=user,
)
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))