sal-maq commited on
Commit
f230a5b
·
verified ·
1 Parent(s): fe6485e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -23,18 +23,19 @@ def meal_plan_generate(fasting_sugar_level, pre_meal_sugar, post_meal_sugar, die
23
  """
24
 
25
  # API call to generate meal plan using Messages API
26
- response = client.messages.create(
27
  model="claude-3-opus-20240229", # Correct model name
28
- messages=[
29
- {"role": "user", "content": prompt}
30
- ],
31
  max_tokens=200,
32
  temperature=0.2
33
  )
34
-
35
  # Process the response
36
- raw_context = response['choices'][0]['message']['content']
37
- return raw_context if raw_context else "No content returned from the API."
 
 
 
38
  except Exception as e:
39
  return f"An error occurred: {e}"
40
 
 
23
  """
24
 
25
  # API call to generate meal plan using Messages API
26
+ response = client.completions.create(
27
  model="claude-3-opus-20240229", # Correct model name
28
+ prompt=prompt,
 
 
29
  max_tokens=200,
30
  temperature=0.2
31
  )
32
+
33
  # Process the response
34
+ if 'choices' in response and len(response['choices']) > 0:
35
+ raw_context = response['choices'][0]['text']
36
+ return raw_context if raw_context else "No content returned from the API."
37
+ else:
38
+ return "Unexpected response format from the API."
39
  except Exception as e:
40
  return f"An error occurred: {e}"
41