mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-05 19:11:52 +00:00
feat(core): Support higher-order operators (#1984)
Co-authored-by: 谨欣 <echo.cmy@antgroup.com>
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
# Define your Pydantic schemas here
|
||||
from typing import Any, Dict
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from dbgpt._private.pydantic import BaseModel, ConfigDict, Field, model_to_dict
|
||||
from dbgpt._private.pydantic import (
|
||||
BaseModel,
|
||||
ConfigDict,
|
||||
Field,
|
||||
model_to_dict,
|
||||
model_validator,
|
||||
)
|
||||
|
||||
from ..config import SERVE_APP_NAME_HUMP
|
||||
|
||||
@@ -41,3 +47,41 @@ class UploadFileResponse(BaseModel):
|
||||
def to_dict(self, **kwargs) -> Dict[str, Any]:
|
||||
"""Convert the model to a dictionary"""
|
||||
return model_to_dict(self, **kwargs)
|
||||
|
||||
|
||||
class _BucketFilePair(BaseModel):
|
||||
"""Bucket file pair model"""
|
||||
|
||||
bucket: str = Field(..., title="The bucket of the file")
|
||||
file_id: str = Field(..., title="The ID of the file")
|
||||
|
||||
|
||||
class FileMetadataBatchRequest(BaseModel):
|
||||
"""File metadata batch request model"""
|
||||
|
||||
uris: Optional[List[str]] = Field(None, title="The URIs of the files")
|
||||
bucket_file_pairs: Optional[List[_BucketFilePair]] = Field(
|
||||
None, title="The bucket file pairs"
|
||||
)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def check_uris_or_bucket_file_pairs(self):
|
||||
# Check if either uris or bucket_file_pairs is provided
|
||||
if not (self.uris or self.bucket_file_pairs):
|
||||
raise ValueError("Either uris or bucket_file_pairs must be provided")
|
||||
# Check only one of uris or bucket_file_pairs is provided
|
||||
if self.uris and self.bucket_file_pairs:
|
||||
raise ValueError("Only one of uris or bucket_file_pairs can be provided")
|
||||
return self
|
||||
|
||||
|
||||
class FileMetadataResponse(BaseModel):
|
||||
"""File metadata model"""
|
||||
|
||||
file_name: str = Field(..., title="The name of the file")
|
||||
file_id: str = Field(..., title="The ID of the file")
|
||||
bucket: str = Field(..., title="The bucket of the file")
|
||||
uri: str = Field(..., title="The URI of the file")
|
||||
file_size: int = Field(..., title="The size of the file")
|
||||
user_name: Optional[str] = Field(None, title="The user name")
|
||||
sys_code: Optional[str] = Field(None, title="The system code")
|
||||
|
Reference in New Issue
Block a user