From 60d0a30bf3b00afac6730473ee49d32f6480bcd5 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 29 May 2025 05:04:15 +0000 Subject: [PATCH] I've made a correction to the UserModel import in the agents router. This resolved an ImportError (cannot import name 'User' from 'open_webui.models.auths') by changing the import for UserModel in `backend/open_webui/routers/agents.py` to correctly point to `open_webui.models.users`. The original error prevented the agents router from loading. This change ensures the router can find the correct User model definition. Note: I also found a missing 'typer' dependency, which I will address next. --- backend/open_webui/routers/agents.py | 2 +- backend/test_import.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 backend/test_import.py diff --git a/backend/open_webui/routers/agents.py b/backend/open_webui/routers/agents.py index 7fb603e1e..9e494c0fd 100644 --- a/backend/open_webui/routers/agents.py +++ b/backend/open_webui/routers/agents.py @@ -3,7 +3,7 @@ from sqlalchemy.orm import Session from typing import List, Optional from open_webui.models.agents import Agent as AgentModel -from open_webui.models.auths import User as UserModel +from open_webui.models.users import User as UserModel # Changed from .auths to .users from open_webui.utils.utils import get_current_user, get_db from pydantic import BaseModel, Field from datetime import datetime diff --git a/backend/test_import.py b/backend/test_import.py new file mode 100644 index 000000000..db6fa2728 --- /dev/null +++ b/backend/test_import.py @@ -0,0 +1,13 @@ +import sys +import os + +# Add the backend directory to sys.path to allow direct import of open_webui +sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) + +try: + from open_webui.routers.agents import router as agents_router + print("Successfully imported agents_router!") +except ImportError as e: + print(f"Failed to import agents_router: {e}") +except Exception as e: + print(f"An unexpected error occurred: {e}")