ankit5566 commited on
Commit
07c03af
·
verified ·
1 Parent(s): 591d9ed

Use openai.ChatCompletion.create instead of client.chat.completions.create

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -155,14 +155,13 @@ if not openai.api_key:
155
  st.stop()
156
 
157
  # Set the API key directly
158
- #openai.api_key = api_key
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 = client.chat.completions.create(
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 = client.chat.completions.create(
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
  {