Skip to content

Commit bf6da00

Browse files
committed
Update llm.py
1 parent 68d914a commit bf6da00

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

app/services/llm/llm.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import os
22
import json
33
from openai import OpenAI
4+
import logging
5+
6+
# Initialize logging
7+
logger = logging.getLogger(__name__)
48

59
# Initialize the OpenAI client with an API key from environment variables
610
client = OpenAI(
@@ -75,7 +79,9 @@ def get_assistant_response(messages):
7579
return response
7680

7781
except Exception as e:
78-
print(f"An error occurred: {e}")
82+
# Log the specific error type and message
83+
logger.error(f"OpenAI API call failed in get_assistant_response.")
84+
logger.exception(e)
7985
return "Sorry, I can't process your request right now."
8086

8187
def get_response(prompt: str):

0 commit comments

Comments
 (0)