Update app.py
Browse files
app.py
CHANGED
|
@@ -5,11 +5,13 @@ import os
|
|
| 5 |
# Set your OpenAI API key
|
| 6 |
client = OpenAI(api_key=os.environ["APITOKEN"])
|
| 7 |
|
|
|
|
|
|
|
| 8 |
def chatbot(input, conversation_history=[]):
|
| 9 |
if input:
|
| 10 |
-
#
|
| 11 |
-
if
|
| 12 |
-
conversation_history = [] # Reset the conversation history
|
| 13 |
|
| 14 |
# Append the user's input to the conversation history
|
| 15 |
conversation_history.append(f"User: {input}")
|
|
|
|
| 5 |
# Set your OpenAI API key
|
| 6 |
client = OpenAI(api_key=os.environ["APITOKEN"])
|
| 7 |
|
| 8 |
+
greetings = ["hello", "hi", "hey", "greetings", "good morning", "good afternoon", "good evening"]
|
| 9 |
+
|
| 10 |
def chatbot(input, conversation_history=[]):
|
| 11 |
if input:
|
| 12 |
+
# Check if the input starts with a common greeting, case-insensitive
|
| 13 |
+
if any(input.lower().startswith(greet) for greet in greetings):
|
| 14 |
+
conversation_history = [] # Reset the conversation history if a greeting is detected
|
| 15 |
|
| 16 |
# Append the user's input to the conversation history
|
| 17 |
conversation_history.append(f"User: {input}")
|