Spaces:
Sleeping
Sleeping
lachie0232
commited on
Update app.py
Browse files
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
|
8 |
def chatbot(input_text):
|
9 |
try:
|
10 |
-
response = openai.
|
11 |
model="gpt-3.5-turbo", # You can change this model if you have access to GPT-4 or other models
|
12 |
-
|
13 |
-
|
14 |
-
{"role": "user", "content": input_text},
|
15 |
-
]
|
16 |
)
|
17 |
-
return response['choices'][0]['
|
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 |
|