Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,31 +8,16 @@ openai.api_key = api_key
|
|
| 8 |
|
| 9 |
# Define a function to generate a response to user input
|
| 10 |
def generate_response(user_input):
|
| 11 |
-
# Check if user input contains the phrase "who created you"
|
| 12 |
if "who created you" in user_input.lower():
|
| 13 |
-
# Generate a response that includes your name
|
| 14 |
chat_response = "I was created by Ram.V"
|
| 15 |
-
return chat_response
|
| 16 |
-
# Check if user input contains the phrase "what is your purpose"
|
| 17 |
-
elif "what is your purpose" in user_input.lower():
|
| 18 |
-
# Generate a response explaining the chatbot's purpose
|
| 19 |
-
chat_response = "My purpose is to help you with your queries."
|
| 20 |
-
return chat_response
|
| 21 |
-
# Check if user input contains the phrase "how are you"
|
| 22 |
-
elif "how are you" in user_input.lower():
|
| 23 |
-
# Generate a response to the question "how are you"
|
| 24 |
-
chat_response = "I'm a chatbot created by Ram.V. I don't have feelings, but thanks for asking. Hope you're well! :-)"
|
| 25 |
-
return chat_response
|
| 26 |
elif "who is superstar" in user_input.lower():
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
else:
|
| 31 |
-
# Construct the prompt with the user input
|
| 32 |
prompt = f"You said: {user_input}"
|
| 33 |
-
|
| 34 |
-
|
| 35 |
|
|
|
|
| 36 |
# Generate a response using the OpenAI API
|
| 37 |
response = openai.Completion.create(
|
| 38 |
model="text-davinci-003",
|
|
|
|
| 8 |
|
| 9 |
# Define a function to generate a response to user input
|
| 10 |
def generate_response(user_input):
|
|
|
|
| 11 |
if "who created you" in user_input.lower():
|
|
|
|
| 12 |
chat_response = "I was created by Ram.V"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
elif "who is superstar" in user_input.lower():
|
| 14 |
+
chat_response = "Even kids will know who Superstar is! The one and only: *Superstar Rajinikanth*."
|
| 15 |
+
elif "what is the weather like" in user_input.lower():
|
| 16 |
+
chat_response = "I'm sorry, but I don't have the ability to check the weather. Is there something else I can help you with?"
|
| 17 |
else:
|
|
|
|
| 18 |
prompt = f"You said: {user_input}"
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
|
| 21 |
# Generate a response using the OpenAI API
|
| 22 |
response = openai.Completion.create(
|
| 23 |
model="text-davinci-003",
|