We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 68d914a commit bf6da00Copy full SHA for bf6da00
app/services/llm/llm.py
@@ -1,6 +1,10 @@
1
import os
2
import json
3
from openai import OpenAI
4
+import logging
5
+
6
+# Initialize logging
7
+logger = logging.getLogger(__name__)
8
9
# Initialize the OpenAI client with an API key from environment variables
10
client = OpenAI(
@@ -75,7 +79,9 @@ def get_assistant_response(messages):
75
79
return response
76
80
77
81
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)
85
return "Sorry, I can't process your request right now."
86
87
def get_response(prompt: str):
0 commit comments