Skip to content

Commit de0376c

Browse files
CarltonXiangharvey_xiangCaralHsi
authored
Feat: add OpenAI log (#785)
* feat: timer false * feat: add openai request body log * feat: add openai request body log * feat: add openai request body log * feat: update openapi.json * feat: add timer status error log --------- Co-authored-by: harvey_xiang <[email protected]> Co-authored-by: CaralHsi <[email protected]>
1 parent b11c768 commit de0376c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/memos/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import functools
22
import time
3+
import traceback
34

45
from memos.log import get_logger
56

@@ -35,6 +36,7 @@ def decorator(fn):
3536
def wrapper(*args, **kwargs):
3637
start = time.perf_counter()
3738
exc_type = None
39+
exc_message = None
3840
result = None
3941
success_flag = False
4042

@@ -44,6 +46,7 @@ def wrapper(*args, **kwargs):
4446
return result
4547
except Exception as e:
4648
exc_type = type(e)
49+
exc_message = traceback.format_exc()
4750
success_flag = False
4851

4952
if fallback is not None and callable(fallback):
@@ -78,7 +81,9 @@ def wrapper(*args, **kwargs):
7881
status_info = f", status: {status}"
7982

8083
if not success_flag and exc_type is not None:
81-
status_info += f", error: {exc_type.__name__}"
84+
status_info += (
85+
f", error_type: {exc_type.__name__}, error_message: {exc_message}"
86+
)
8287

8388
msg = (
8489
f"[TIMER_WITH_STATUS] {log_prefix or fn.__name__} "

0 commit comments

Comments
 (0)