Spaces:
Running
Running
Use openai.ChatCompletion.create instead of client.chat.completions.create
Browse files
app.py
CHANGED
|
@@ -155,14 +155,13 @@ if not openai.api_key:
|
|
| 155 |
st.stop()
|
| 156 |
|
| 157 |
# Set the API key directly
|
| 158 |
-
|
| 159 |
-
client = OpenAI(api_key=api_key)
|
| 160 |
|
| 161 |
# Function to analyze image with OpenAI
|
| 162 |
def analyze_image_with_image_recognition(image_bytes):
|
| 163 |
base64_image = base64.b64encode(image_bytes).decode("utf-8")
|
| 164 |
|
| 165 |
-
response =
|
| 166 |
model="gpt-4o-mini",
|
| 167 |
messages=[
|
| 168 |
{
|
|
@@ -337,7 +336,7 @@ Provide the nutritional information in the following JSON format only:
|
|
| 337 |
}}'''
|
| 338 |
|
| 339 |
# Update the analyze function to include meal description
|
| 340 |
-
response =
|
| 341 |
model="gpt-4o",
|
| 342 |
messages=[
|
| 343 |
{
|
|
|
|
| 155 |
st.stop()
|
| 156 |
|
| 157 |
# Set the API key directly
|
| 158 |
+
openai.api_key = api_key
|
|
|
|
| 159 |
|
| 160 |
# Function to analyze image with OpenAI
|
| 161 |
def analyze_image_with_image_recognition(image_bytes):
|
| 162 |
base64_image = base64.b64encode(image_bytes).decode("utf-8")
|
| 163 |
|
| 164 |
+
response = openai.ChatCompletion.create(
|
| 165 |
model="gpt-4o-mini",
|
| 166 |
messages=[
|
| 167 |
{
|
|
|
|
| 336 |
}}'''
|
| 337 |
|
| 338 |
# Update the analyze function to include meal description
|
| 339 |
+
response = openai.ChatCompletion.create(
|
| 340 |
model="gpt-4o",
|
| 341 |
messages=[
|
| 342 |
{
|