Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files
app.py
CHANGED
|
@@ -51,7 +51,7 @@ class GrammarCheckResponse(BaseModel):
|
|
| 51 |
|
| 52 |
|
| 53 |
@app.post("/check-grammar-quiz/", response_model=GrammarCheckResponse)
|
| 54 |
-
|
| 55 |
background_tasks: BackgroundTasks,
|
| 56 |
file: UploadFile = File(...),
|
| 57 |
limit: Optional[int] = None,
|
|
@@ -165,7 +165,7 @@ class TextRequest(BaseModel):
|
|
| 165 |
|
| 166 |
|
| 167 |
@app.post("/check-text")
|
| 168 |
-
|
| 169 |
"""Process text input and check grammar."""
|
| 170 |
try:
|
| 171 |
if not body.text:
|
|
@@ -175,7 +175,7 @@ async def check_text(body: TextRequest):
|
|
| 175 |
result = check_grammar(body.text, body.proper_nouns)
|
| 176 |
|
| 177 |
# Convert Pydantic model to dict for JSON response
|
| 178 |
-
return result.
|
| 179 |
|
| 180 |
except Exception as e:
|
| 181 |
logging.error(f"Error processing text: {str(e)}")
|
|
@@ -204,7 +204,7 @@ async def check_file(
|
|
| 204 |
result = check_grammar_from_file(file_content, file.filename, proper_nouns)
|
| 205 |
|
| 206 |
# Convert Pydantic model to dict for JSON response
|
| 207 |
-
return result.
|
| 208 |
|
| 209 |
except Exception as e:
|
| 210 |
logging.error(f"Error processing file: {str(e)}")
|
|
|
|
| 51 |
|
| 52 |
|
| 53 |
@app.post("/check-grammar-quiz/", response_model=GrammarCheckResponse)
|
| 54 |
+
def check_grammar_quiz(
|
| 55 |
background_tasks: BackgroundTasks,
|
| 56 |
file: UploadFile = File(...),
|
| 57 |
limit: Optional[int] = None,
|
|
|
|
| 165 |
|
| 166 |
|
| 167 |
@app.post("/check-text")
|
| 168 |
+
def check_text(body: TextRequest):
|
| 169 |
"""Process text input and check grammar."""
|
| 170 |
try:
|
| 171 |
if not body.text:
|
|
|
|
| 175 |
result = check_grammar(body.text, body.proper_nouns)
|
| 176 |
|
| 177 |
# Convert Pydantic model to dict for JSON response
|
| 178 |
+
return result.model_dump()
|
| 179 |
|
| 180 |
except Exception as e:
|
| 181 |
logging.error(f"Error processing text: {str(e)}")
|
|
|
|
| 204 |
result = check_grammar_from_file(file_content, file.filename, proper_nouns)
|
| 205 |
|
| 206 |
# Convert Pydantic model to dict for JSON response
|
| 207 |
+
return result.model_dump()
|
| 208 |
|
| 209 |
except Exception as e:
|
| 210 |
logging.error(f"Error processing file: {str(e)}")
|