Spaces:
Paused
Paused
File size: 1,041 Bytes
90dbc1a 9e6aa30 90dbc1a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import logging
from fastapi import HTTPException
from helpers import session_logger
def divide(a: int, b: int) -> float:
logging.info(f"a:{a}, b:{b}.")
result = a / b
logging.info(f"result:{result}.")
return result
@session_logger.set_uuid_logging
def request_formatter(text: str) -> dict:
logging.info("start request...")
try:
logging.info(f"input text we need to treat as an integer: {text}.")
b = int(text)
transformed_text = f"input after integer cast: {b}."
try:
result_division = divide(100, b)
logging.info(f"some_function, result_division:{result_division}.")
return {"text": transformed_text, "result": result_division}
except ZeroDivisionError as zde:
logging.info(f"exception:{zde}.")
raise HTTPException(status_code=500, detail="Internal server error")
except ValueError as ve:
logging.info(f"exception:{ve}.")
raise HTTPException(status_code=500, detail="Internal server error")
|