Roxyzhang commited on
Commit
58e0b8a
1 Parent(s): f73eba6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
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
- # Restart the conversation if greeted
11
- if "hello" in input.lower() or "hi" in input.lower():
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}")