Spaces:
Sleeping
Sleeping
Update api.py
Browse files
api.py
CHANGED
@@ -123,6 +123,13 @@ class SummaryError(BaseModel):
|
|
123 |
summaries: str = Field("", description="Empty string as summarizer encountered an error")
|
124 |
summarizer_error: str = Field("Error: Summarizer Error with a message describing the error")
|
125 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
class NewsSummarizerAPIAuthenticationError(Exception):
|
128 |
pass
|
@@ -154,7 +161,8 @@ async def validation_exception_handler(request: Request, exc: RequestValidationE
|
|
154 |
@app.post("/generate_summary/", tags=["Generate Summary"], response_model=List[SuccessfulResponse],
|
155 |
responses={
|
156 |
401: {"model": AuthenticationError, "description": "Authentication Error"},
|
157 |
-
500: {"model": SummaryError, "description": "Summarizer Error"}
|
|
|
158 |
})
|
159 |
async def generate_summary(q: URLList):
|
160 |
"""
|
|
|
123 |
summaries: str = Field("", description="Empty string as summarizer encountered an error")
|
124 |
summarizer_error: str = Field("Error: Summarizer Error with a message describing the error")
|
125 |
|
126 |
+
class InputValidationError(BaseModel):
|
127 |
+
urls: List[str] = Field(..., description="List of URLs of news articles inputted by the user")
|
128 |
+
scraped_texts: str = Field("", description="Empty string as validation failed")
|
129 |
+
scrape_errors: str = Field("", description="Empty string as validation failed")
|
130 |
+
summaries: str = Field("", description="Empty string as validation failed")
|
131 |
+
summarizer_error: str = Field("Validation Error with a message describing the error")
|
132 |
+
|
133 |
|
134 |
class NewsSummarizerAPIAuthenticationError(Exception):
|
135 |
pass
|
|
|
161 |
@app.post("/generate_summary/", tags=["Generate Summary"], response_model=List[SuccessfulResponse],
|
162 |
responses={
|
163 |
401: {"model": AuthenticationError, "description": "Authentication Error"},
|
164 |
+
500: {"model": SummaryError, "description": "Summarizer Error occurs when the API couldn't generate summary of even a single article"},
|
165 |
+
422: {"model": InputValidationError, "description": "Validation Error"}
|
166 |
})
|
167 |
async def generate_summary(q: URLList):
|
168 |
"""
|