Create chatbot.py
Browse files- backend/chatbot.py +22 -0
backend/chatbot.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
from messages import krishna_blessings
|
3 |
+
from ayush_messages import ayush_surprises
|
4 |
+
|
5 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
6 |
+
|
7 |
+
def get_krishna_response(user_input):
|
8 |
+
if "birthday" in user_input.lower():
|
9 |
+
return ayush_surprises["birthday"]
|
10 |
+
if "shy" in user_input.lower():
|
11 |
+
return "Hare Manavi! I hid from the gopis too—quiet time is golden like my butter!"
|
12 |
+
prompt = (
|
13 |
+
"You are Little Krishna, playful and wise. Respond to this in a fun, Krishna-like way: "
|
14 |
+
f"'{user_input}'"
|
15 |
+
)
|
16 |
+
response = openai.Completion.create(
|
17 |
+
engine="text-davinci-003",
|
18 |
+
prompt=prompt,
|
19 |
+
max_tokens=60,
|
20 |
+
temperature=0.9
|
21 |
+
)
|
22 |
+
return response.choices[0].text.strip()
|