Skip to content

Commit

Permalink
add OTHERS error code
Browse files Browse the repository at this point in the history
  • Loading branch information
cyyeh committed Jul 15, 2024
1 parent f8f16c1 commit f80327e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
11 changes: 9 additions & 2 deletions wren-ai-service/src/web/v1/services/ask.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ class SemanticsPreparationStatusRequest(BaseModel):


class SemanticsPreparationStatusResponse(BaseModel):
class SemanticsPreparationError(BaseModel):
code: Literal["OTHERS"]
message: str

status: Literal["indexing", "finished", "failed"]
error: Optional[str] = None
error: Optional[SemanticsPreparationError] = None


class SQLExplanation(BaseModel):
Expand Down Expand Up @@ -151,7 +155,10 @@ def get_prepare_semantics_status(
)
return SemanticsPreparationStatusResponse(
status="failed",
error=f"{prepare_semantics_status_request.id} is not found",
error=SemanticsPreparationStatusResponse.SemanticsPreparationError(
code="OTHERS",
message="{prepare_semantics_status_request.id} is not found",
),
)

return result
Expand Down
11 changes: 9 additions & 2 deletions wren-ai-service/src/web/v1/services/sql_explanation.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ class SQLExplanationResultRequest(BaseModel):


class SQLExplanationResultResponse(BaseModel):
class SQLExplanationResultError(BaseModel):
code: Literal["OTHERS"]
message: str

status: Literal["understanding", "generating", "finished", "failed"]
response: Optional[List[List[Dict]]] = None
error: Optional[str] = None
error: Optional[SQLExplanationResultError] = None


class SQLExplanationService:
Expand Down Expand Up @@ -100,7 +104,10 @@ async def _task(
sql_explanation_request.query_id
] = SQLExplanationResultResponse(
status="failed",
error=str(e),
error=SQLExplanationResultResponse.SQLExplanationResultError(
code="OTHERS",
message=str(e),
),
)

def get_sql_explanation_result(
Expand Down

0 comments on commit f80327e

Please sign in to comment.