prernajeet01 commited on
Commit
405dcde
·
verified ·
1 Parent(s): bdefa87

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -12,14 +12,14 @@ import io
12
  import base64
13
  from PIL import Image
14
  import os
15
- import openai
16
 
17
  # Path to the CSV file in the environment
18
  CSV_PATH = 'FI_Transactions.csv'
19
 
20
  # Get OpenAI API key from environment variables
21
  OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
22
- openai.api_key = OPENAI_API_KEY
23
 
24
  def detect_anomalies(nu_value, n_clusters):
25
  # Read the CSV file from the environment
@@ -134,8 +134,8 @@ def get_ai_insights(df, anomalies_df):
134
  Keep your analysis concise and focused on financial fraud detection.
135
  """
136
 
137
- # Call the OpenAI API
138
- response = openai.ChatCompletion.create(
139
  model="gpt-3.5-turbo",
140
  messages=[
141
  {"role": "system", "content": "You are a financial fraud detection expert."},
 
12
  import base64
13
  from PIL import Image
14
  import os
15
+ from openai import OpenAI
16
 
17
  # Path to the CSV file in the environment
18
  CSV_PATH = 'FI_Transactions.csv'
19
 
20
  # Get OpenAI API key from environment variables
21
  OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY")
22
+ client = OpenAI(api_key=OPENAI_API_KEY)
23
 
24
  def detect_anomalies(nu_value, n_clusters):
25
  # Read the CSV file from the environment
 
134
  Keep your analysis concise and focused on financial fraud detection.
135
  """
136
 
137
+ # Call the OpenAI API using the new client format
138
+ response = client.chat.completions.create(
139
  model="gpt-3.5-turbo",
140
  messages=[
141
  {"role": "system", "content": "You are a financial fraud detection expert."},