Skip to content

Commit eed364e

Browse files
committed
improve file class
1 parent 25ade1c commit eed364e

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/inferencesh/models/file.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from typing import Optional, Union, Any, Type
2-
from pydantic import BaseModel, Field, PrivateAttr, model_validator, GetCoreSchemaHandler, GetJsonSchemaHandler
3-
from pydantic_core import CoreSchema, core_schema
1+
from typing import Optional, Union, Any
2+
from pydantic import BaseModel, Field, PrivateAttr, model_validator, GetJsonSchemaHandler
3+
from pydantic_core import CoreSchema
44
import mimetypes
55
import os
66
import urllib.request
@@ -264,15 +264,14 @@ def refresh_metadata(self) -> None:
264264
def __get_pydantic_json_schema__(
265265
cls, schema: CoreSchema, handler: GetJsonSchemaHandler
266266
) -> dict[str, Any]:
267-
"""Customizes the JSON schema generation for this File class"""
267+
"""Generate a simple JSON schema that accepts either a string or an object"""
268268
json_schema = handler(schema)
269-
json_schema = handler.resolve_ref_schema(json_schema)
270-
json_schema.update({
269+
# Don't resolve refs here - that's what was causing the recursion
270+
return {
271271
"$id": "/schemas/File",
272272
"oneOf": [
273273
{"type": "string"},
274274
json_schema
275275
]
276-
})
277-
return json_schema
276+
}
278277

0 commit comments

Comments
 (0)