Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update text2image model #731

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions python/core/components/text_to_image/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ class Text2ImageSubmitRequest(BaseModel):


class Text2ImageSubmitErrorDetail(BaseModel):
msg: Optional[str]
word: Optional[object]
msg: Optional[str] = Field(default=None)
word: Optional[object] = Field(default=None)
words: Optional[list] = Field(default=None)


class Text2ImageSubmitResponseData(BaseModel):
Expand All @@ -51,7 +52,7 @@ class Text2ImageSubmitResponse(BaseModel):
log_id: Optional[int] = None
data: Optional[Text2ImageSubmitResponseData] = Text2ImageSubmitResponseData()
error_msg: Optional[str] = None
error_detail: Optional[Text2ImageSubmitErrorDetail] = None
error_detail: Union[list[Text2ImageSubmitErrorDetail], Text2ImageSubmitErrorDetail, None] = None
error_code: Optional[int] = None


Expand Down Expand Up @@ -103,3 +104,12 @@ class Text2ImageOutMessage(BaseModel):
图片所在 BOS http 地址,默认 1 小时失效。
"""
img_urls: List[str]

if __name__ == '__main__':
msg = {
'log_id': 1882788580231261430,
'error_msg': '文本敏感信息拦截',
'error_detail': [
{'msg': '存在自定义文本黑名单不合规', 'words': ['特朗普', '特朗普']}, {'msg': '存在政治敏感不合规', 'words': []}], 'error_code': 282004}
resp = Text2ImageSubmitResponse(**msg)
print(resp)
Loading