🚀 Add feature: Separate conversion functions
This commit is contained in:
parent
0f1a07da49
commit
afdfe1dbac
19 changed files with 318 additions and 17 deletions
|
@ -1,6 +1,7 @@
|
|||
from typing import Dict, List
|
||||
from typing import Annotated, Dict, List
|
||||
|
||||
from pydantic import BaseModel
|
||||
from fastapi import Form, UploadFile
|
||||
from pydantic import BaseModel, model_validator
|
||||
|
||||
|
||||
class AnalysisRequest(BaseModel):
|
||||
|
@ -12,9 +13,36 @@ class AnalysisResponse(BaseModel):
|
|||
result: str
|
||||
|
||||
|
||||
class AvailableSource(BaseModel):
|
||||
display_name: str
|
||||
name: str
|
||||
format: str
|
||||
|
||||
|
||||
class AvailableSourcesResponse(BaseModel):
|
||||
sources: List[AvailableSource]
|
||||
|
||||
|
||||
class ConversionRequest(BaseModel):
|
||||
source_type: str
|
||||
source_data: str
|
||||
source_name: Annotated[str, Form()]
|
||||
source_format: Annotated[str, Form()]
|
||||
file: UploadFile
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
source_name: Annotated[str, Form()],
|
||||
source_format: Annotated[str, Form()],
|
||||
file: UploadFile,
|
||||
):
|
||||
super().__init__(
|
||||
source_name=source_name, source_format=source_format, file=file
|
||||
)
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate(self):
|
||||
if not self.source_format:
|
||||
self.source_format = "txt"
|
||||
return self
|
||||
|
||||
|
||||
class ConversionResponse(BaseModel):
|
||||
|
@ -48,13 +76,3 @@ class ImportRequest(BaseModel):
|
|||
|
||||
class ImportResponse(BaseModel):
|
||||
status: str
|
||||
|
||||
|
||||
class AvailableSource(BaseModel):
|
||||
display_name: str
|
||||
name: str
|
||||
format: str
|
||||
|
||||
|
||||
class AvailableSourcesResponse(BaseModel):
|
||||
sources: List[AvailableSource]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue