diff options
| author | Guillermo Serrahima <dev@vylion.com> | 2026-06-29 10:32:46 +0200 |
|---|---|---|
| committer | Guillermo Serrahima <dev@vylion.com> | 2026-06-29 10:32:46 +0200 |
| commit | 9d9151ba6e6c06fe213d20f5e4aaabbec6750946 (patch) | |
| tree | cdc7df03490695914ff5caf700b2bece21614a9f /agent/orchestrator/api.py | |
| parent | a8bd02b241a3d4beb40daf36262dedb2340d2251 (diff) | |
| download | senia-9d9151ba6e6c06fe213d20f5e4aaabbec6750946.tar.xz senia-9d9151ba6e6c06fe213d20f5e4aaabbec6750946.zip | |
Added current user to context
Diffstat (limited to 'agent/orchestrator/api.py')
| -rw-r--r-- | agent/orchestrator/api.py | 7 |
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)) |
