Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,9 @@ import gradio as gr
|
|
3 |
import os
|
4 |
|
5 |
# Set your OpenAI API key
|
6 |
-
|
|
|
|
|
7 |
|
8 |
# Initialize a list to store the conversation history
|
9 |
conversation_history = []
|
@@ -28,7 +30,7 @@ def chatbot(input):
|
|
28 |
messages.extend([{"role": "user", "content": message} for message in conversation_history])
|
29 |
|
30 |
# Use OpenAI's GPT-3.5 Turbo model to generate a response
|
31 |
-
chat =
|
32 |
reply = chat.choices[0].message.content
|
33 |
|
34 |
# Append the chatbot's response to the conversation history
|
|
|
3 |
import os
|
4 |
|
5 |
# Set your OpenAI API key
|
6 |
+
client = OpenAI(
|
7 |
+
api_key=os.environ["APITOKEN"], # this is also the default, it can be omitted
|
8 |
+
)
|
9 |
|
10 |
# Initialize a list to store the conversation history
|
11 |
conversation_history = []
|
|
|
30 |
messages.extend([{"role": "user", "content": message} for message in conversation_history])
|
31 |
|
32 |
# Use OpenAI's GPT-3.5 Turbo model to generate a response
|
33 |
+
chat = client.chat.completions.create(model="gpt-3.5-turbo", messages=messages)
|
34 |
reply = chat.choices[0].message.content
|
35 |
|
36 |
# Append the chatbot's response to the conversation history
|