Skip to content

Commit

Permalink
fix: add logger to avoid exposing exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
phanhongan committed Oct 24, 2024
1 parent ef10db4 commit a663d98
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions examples/semiconductor/semiconductor-ui/api/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os
import time
from collections import defaultdict
Expand All @@ -11,6 +12,9 @@
from openssa import Agent, ProgramSpace, HTP, HTPlanner, OpenAILM
from semikong_lm import SemiKongLM

logging.basicConfig(level=logging.ERROR)
logger = logging.getLogger(__name__)


def get_or_create_agent(
use_semikong_lm: bool = True, max_depth=2, max_subtasks_per_decomp=4
Expand Down Expand Up @@ -130,11 +134,13 @@ async def post_data(data: dict):
parsed_answer = solve_semiconductor_question(question)
return parsed_answer
except ValueError as e:
return {"error": f"Value error: {str(e)}"}, 400
logger.error(f"Value error: {str(e)}")
return {"error": "A value error has occurred."}, 400
except RuntimeError as e:
return {"error": f"Runtime error: {str(e)}"}, 500
except Exception:
# logger.error(f"Error solving the question: {e}")
logger.error(f"Runtime error: {str(e)}")
return {"error": "A runtime error has occurred."}, 500
except Exception as e:
logger.error(f"Error solving the question: {e}")
# return {"error": str(e)}, 500
time.sleep(10)
return """
Expand Down

0 comments on commit a663d98

Please sign in to comment.