lachie0232 commited on
Commit
94615f2
·
verified ·
1 Parent(s): 55d8473

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -4,17 +4,15 @@ import gradio as gr
4
  # Set up OpenAI API key
5
  openai.api_key = "your-openai-secret-key"
6
 
7
- # Define a function to call the OpenAI API (new method)
8
  def chatbot(input_text):
9
  try:
10
- response = openai.ChatCompletion.create(
11
  model="gpt-3.5-turbo", # You can change this model if you have access to GPT-4 or other models
12
- messages=[
13
- {"role": "system", "content": "You are a helpful assistant."},
14
- {"role": "user", "content": input_text},
15
- ]
16
  )
17
- return response['choices'][0]['message']['content'].strip()
18
  except Exception as e:
19
  return f"Error: {str(e)}"
20
 
 
4
  # Set up OpenAI API key
5
  openai.api_key = "your-openai-secret-key"
6
 
7
+ # Define a function to call the OpenAI API
8
  def chatbot(input_text):
9
  try:
10
+ response = openai.completions.create(
11
  model="gpt-3.5-turbo", # You can change this model if you have access to GPT-4 or other models
12
+ prompt=input_text,
13
+ max_tokens=150
 
 
14
  )
15
+ return response['choices'][0]['text'].strip()
16
  except Exception as e:
17
  return f"Error: {str(e)}"
18