traversaal-ai commited on
Commit
46fb1dc
1 Parent(s): a45abf6

Update services/openai_service.py

Browse files
Files changed (1) hide show
  1. services/openai_service.py +10 -5
services/openai_service.py CHANGED
@@ -14,11 +14,16 @@ AZURE_OPENAI_ENDPOINT = os.getenv('AZURE_OPENAI_ENDPOINT')
14
  AZURE_API_VERSION = "2023-03-15-preview" # API version for Azure OpenAI
15
  AZURE_OPENAI_KEY = os.getenv('AZURE_OPENAI_API_KEY')
16
  # Initialize the Azure OpenAI client with the endpoint and API key
17
- client = AzureOpenAI(
18
- azure_endpoint=AZURE_OPENAI_ENDPOINT,
19
- api_key=AZURE_OPENAI_KEY,
20
- api_version=AZURE_API_VERSION
21
- )
 
 
 
 
 
22
 
23
  def generate_rag_response(json_output, user_query):
24
  logging.info("Generating RAG response")
 
14
  AZURE_API_VERSION = "2023-03-15-preview" # API version for Azure OpenAI
15
  AZURE_OPENAI_KEY = os.getenv('AZURE_OPENAI_API_KEY')
16
  # Initialize the Azure OpenAI client with the endpoint and API key
17
+ try:
18
+ client = AzureOpenAI(
19
+ azure_endpoint=AZURE_OPENAI_ENDPOINT,
20
+ api_key=AZURE_OPENAI_KEY,
21
+ api_version=AZURE_API_VERSION
22
+ )
23
+ except Exception as e:
24
+ logging.error(f"Azure OpenAI API error: {e}")
25
+
26
+
27
 
28
  def generate_rag_response(json_output, user_query):
29
  logging.info("Generating RAG response")