Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -37,8 +37,8 @@ def process_chat(user_text):
|
|
37 |
return
|
38 |
|
39 |
try:
|
40 |
-
#
|
41 |
-
response = openai.
|
42 |
model="gpt-4",
|
43 |
messages=[
|
44 |
{"role": "system", "content": "You are a helpful assistant named Diane specializing in digital art advice."},
|
@@ -48,14 +48,15 @@ def process_chat(user_text):
|
|
48 |
)
|
49 |
response_text = ""
|
50 |
for chunk in response:
|
51 |
-
if
|
52 |
-
token = chunk
|
53 |
response_text += token
|
54 |
yield response_text
|
55 |
except Exception as e:
|
56 |
yield f"❌ An error occurred: {str(e)}"
|
57 |
|
58 |
|
|
|
59 |
# Function to analyze image contrast
|
60 |
def analyze_contrast_opencv(image_path):
|
61 |
img = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
|
|
|
37 |
return
|
38 |
|
39 |
try:
|
40 |
+
# Use ChatCompletion API for chat models
|
41 |
+
response = openai.ChatCompletion.create(
|
42 |
model="gpt-4",
|
43 |
messages=[
|
44 |
{"role": "system", "content": "You are a helpful assistant named Diane specializing in digital art advice."},
|
|
|
48 |
)
|
49 |
response_text = ""
|
50 |
for chunk in response:
|
51 |
+
if "choices" in chunk and chunk.choices[0].delta.get("content"):
|
52 |
+
token = chunk.choices[0].delta["content"]
|
53 |
response_text += token
|
54 |
yield response_text
|
55 |
except Exception as e:
|
56 |
yield f"❌ An error occurred: {str(e)}"
|
57 |
|
58 |
|
59 |
+
|
60 |
# Function to analyze image contrast
|
61 |
def analyze_contrast_opencv(image_path):
|
62 |
img = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
|