Update URL type to avoid string-ifying and creating complexity

This commit is contained in:
Ashwin Bharambe 2024-12-17 22:48:47 -08:00
parent 75e72cf2fc
commit f1d6cb22d7
3 changed files with 18 additions and 12 deletions

View file

@ -2893,9 +2893,16 @@
] ]
}, },
"URL": { "URL": {
"type": "string", "type": "object",
"format": "uri", "properties": {
"pattern": "^(https?://|file://|data:)" "uri": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"uri"
]
}, },
"UserMessage": { "UserMessage": {
"type": "object", "type": "object",

View file

@ -3105,9 +3105,13 @@ components:
title: A single turn in an interaction with an Agentic System. title: A single turn in an interaction with an Agentic System.
type: object type: object
URL: URL:
format: uri additionalProperties: false
pattern: ^(https?://|file://|data:) properties:
uri:
type: string type: string
required:
- uri
type: object
UnregisterDatasetRequest: UnregisterDatasetRequest:
additionalProperties: false additionalProperties: false
properties: properties:

View file

@ -11,15 +11,10 @@ from llama_models.schema_utils import json_schema_type, register_schema
from pydantic import BaseModel, Field, model_validator from pydantic import BaseModel, Field, model_validator
@json_schema_type( @json_schema_type
schema={"type": "string", "format": "uri", "pattern": "^(https?://|file://|data:)"}
)
class URL(BaseModel): class URL(BaseModel):
uri: str uri: str
def __str__(self) -> str:
return self.uri
class _URLOrData(BaseModel): class _URLOrData(BaseModel):
url: Optional[URL] = None url: Optional[URL] = None