HemanM commited on
Commit
23012c7
Β·
verified Β·
1 Parent(s): 0aea990

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -1,4 +1,4 @@
1
- # βœ… Evo Showcase Mode: Full Gradio App with GPT-3.5 Comparison
2
 
3
  import gradio as gr
4
  import openai
@@ -7,17 +7,19 @@ from inference import predict as evo_predict
7
  # πŸ” SET YOUR GPT-3.5 API KEY HERE
8
  openai.api_key = "sk-..." # You must insert your OpenAI API key
9
 
 
 
 
10
  def gpt_predict(prompt):
11
  try:
12
- system_msg = "You're a commonsense reasoning assistant. Given a goal and two options, pick the better one. Only say: Solution 1 or Solution 2."
13
- completion = openai.ChatCompletion.create(
14
  model="gpt-3.5-turbo",
15
  messages=[
16
- {"role": "system", "content": system_msg},
17
  {"role": "user", "content": prompt}
18
  ]
19
  )
20
- return completion["choices"][0]["message"]["content"].strip()
21
  except Exception as e:
22
  return f"GPT Error: {str(e)}"
23
 
 
1
+ # βœ… Evo Showcase Mode: Gradio App with GPT-3.5 Comparison (openai>=1.0 fix)
2
 
3
  import gradio as gr
4
  import openai
 
7
  # πŸ” SET YOUR GPT-3.5 API KEY HERE
8
  openai.api_key = "sk-..." # You must insert your OpenAI API key
9
 
10
+ # βœ… Use the new openai>=1.0.0 API
11
+ client = openai.OpenAI()
12
+
13
  def gpt_predict(prompt):
14
  try:
15
+ response = client.chat.completions.create(
 
16
  model="gpt-3.5-turbo",
17
  messages=[
18
+ {"role": "system", "content": "You're a commonsense reasoning assistant. Only say: Solution 1 or Solution 2."},
19
  {"role": "user", "content": prompt}
20
  ]
21
  )
22
+ return response.choices[0].message.content.strip()
23
  except Exception as e:
24
  return f"GPT Error: {str(e)}"
25