diff --git a/backend/open_webui/routers/functions.py b/backend/open_webui/routers/functions.py index be3fe3edf1..50efd8fb20 100644 --- a/backend/open_webui/routers/functions.py +++ b/backend/open_webui/routers/functions.py @@ -494,7 +494,7 @@ async def get_function_valves_spec_by_id( if hasattr(function_module, 'Valves'): Valves = function_module.Valves - schema = Valves.schema() + schema = Valves.model_json_schema() # Resolve dynamic options for select dropdowns schema = resolve_valves_schema_options(Valves, schema, user) return schema @@ -570,7 +570,7 @@ async def get_function_user_valves_by_id( function = await Functions.get_function_by_id(id, db=db) if function: try: - user_valves = await Functions.get_user_valves_by_id_and_user_id(id, user.id, db=db) + user_valves = await Functions.get_function_user_valves_by_id_and_user_id(id, user.id, db=db) return user_valves except Exception as e: raise HTTPException( @@ -600,7 +600,7 @@ async def get_function_user_valves_spec_by_id( if hasattr(function_module, 'UserValves'): UserValves = function_module.UserValves - schema = UserValves.schema() + schema = UserValves.model_json_schema() # Resolve dynamic options for select dropdowns schema = resolve_valves_schema_options(UserValves, schema, user) return schema diff --git a/backend/open_webui/routers/ollama.py b/backend/open_webui/routers/ollama.py index 00f41c01b3..7b6ceb2817 100644 --- a/backend/open_webui/routers/ollama.py +++ b/backend/open_webui/routers/ollama.py @@ -45,7 +45,7 @@ from open_webui.utils.payload import ( apply_system_prompt_to_body, ) from open_webui.utils.session_pool import cleanup_response, get_client_timeout, get_session, stream_wrapper -from pydantic import BaseModel, ConfigDict, validator +from pydantic import BaseModel, ConfigDict, field_validator from sqlalchemy.ext.asyncio import AsyncSession log = logging.getLogger(__name__) @@ -1030,10 +1030,10 @@ class ChatMessage(BaseModel): images: list[str | None] = None model_config = ConfigDict(extra='allow') - @validator('content', pre=True) + @field_validator('content', mode='before') @classmethod - def check_at_least_one_field(cls, field_value, values, **kwargs): - if field_value is None and ('tool_calls' not in values or values['tool_calls'] is None): + def check_at_least_one_field(cls, field_value, info): + if field_value is None and ('tool_calls' not in info.data or info.data['tool_calls'] is None): raise ValueError("At least one of 'content' or 'tool_calls' must be provided") return field_value diff --git a/pyproject.toml b/pyproject.toml index 5b6b3e0749..eb4d21bfb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ license = { file = "LICENSE" } dependencies = [ "fastapi==0.136.3", "uvicorn[standard]==0.51.0", - "pydantic==2.13.4", + "pydantic>=2.0.0", "python-multipart==0.0.32", "itsdangerous==2.2.0",