-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from meedan/cv2-2875-schema-fixes
CV2-2875 tweak response structure
- Loading branch information
Showing
23 changed files
with
72 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,4 +206,4 @@ If no callback_url is provided: | |
{ | ||
"message": "No Message Callback, Passing" | ||
} | ||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,30 @@ | ||
from typing import Any, List, Optional, Union | ||
from pydantic import BaseModel | ||
from pydantic import BaseModel, root_validator | ||
|
||
# Output hash values can be of different types. | ||
HashValue = Union[List[float], str, int] | ||
class TextInput(BaseModel): | ||
class GenericItem(BaseModel): | ||
id: str | ||
callback_url: str | ||
text: str | ||
|
||
class TextOutput(BaseModel): | ||
id: str | ||
callback_url: str | ||
text: str | ||
|
||
class VideoInput(BaseModel): | ||
id: str | ||
callback_url: str | ||
url: str | ||
|
||
class VideoOutput(BaseModel): | ||
id: str | ||
callback_url: str | ||
url: str | ||
bucket: str | ||
outfile: str | ||
hash_value: HashValue | ||
|
||
class AudioInput(BaseModel): | ||
id: str | ||
callback_url: str | ||
url: str | ||
|
||
class AudioOutput(BaseModel): | ||
id: str | ||
callback_url: str | ||
url: str | ||
hash_value: HashValue | ||
|
||
class ImageInput(BaseModel): | ||
id: str | ||
callback_url: str | ||
url: str | ||
|
||
class ImageOutput(BaseModel): | ||
id: str | ||
callback_url: str | ||
url: str | ||
hash_value: HashValue | ||
|
||
class GenericInput(BaseModel): | ||
id: str | ||
callback_url: str | ||
callback_url: Optional[str] = None | ||
url: Optional[str] = None | ||
text: Optional[str] = None | ||
raw: Optional[dict] = {} | ||
|
||
class MediaItem(GenericItem): | ||
hash_value: Optional[Any] = None | ||
|
||
class VideoItem(MediaItem): | ||
bucket: Optional[str] = None | ||
outfile: Optional[str] = None | ||
|
||
class Message(BaseModel): | ||
body: GenericInput | ||
response: Any | ||
body: Union[MediaItem, VideoItem] | ||
model_name: str | ||
@root_validator(pre=True) | ||
def set_body(cls, values): | ||
body = values.get("body") | ||
model_name = values.get("model_name") | ||
if model_name == "video__Model": | ||
values["body"] = VideoItem(**values["body"]).dict() | ||
if model_name in ["audio__Model", "image__Model", "fptg__Model", "indian_sbert__Model", "mean_tokens__Model", "fasttext__Model"]: | ||
values["body"] = MediaItem(**values["body"]).dict() | ||
return values |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.