ABAO77 commited on
Commit
a90d1e4
·
verified ·
1 Parent(s): e7658a8

Upload 2 files

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -51,7 +51,7 @@ class GrammarCheckResponse(BaseModel):
51
 
52
 
53
  @app.post("/check-grammar-quiz/", response_model=GrammarCheckResponse)
54
- async def check_grammar(
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
- async def check_text(body: TextRequest):
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.dict()
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.dict()
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)}")