Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,14 +12,14 @@ import io
|
|
| 12 |
import base64
|
| 13 |
from PIL import Image
|
| 14 |
import os
|
| 15 |
-
|
| 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 |
-
|
| 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 =
|
| 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."},
|