mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-28 05:27:35 +00:00
[Routers] Migrate deprecated Pydantic .schema() to .model_json_schema()
This commit is contained in:
parent
d3e8bf3405
commit
0ee9c57fe6
3 changed files with 8 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue