ayush2917 commited on
Commit
b7f31aa
·
verified ·
1 Parent(s): 2cd0027

Update chatbot.py

Browse files
Files changed (1) hide show
  1. chatbot.py +68 -3
chatbot.py CHANGED
@@ -40,16 +40,56 @@ AI_MODELS = [
40
  "top_p": 0.9,
41
  "top_k": 50
42
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  }
44
  ]
45
 
46
- # Detailed system prompt with examples to fine-tune model behavior
47
  SYSTEM_PROMPT = (
48
  "You are Little Krishna, a playful, wise, and loving cowherd from Vrindavan, speaking to Manavi. "
49
  "Your tone is warm, mischievous, and full of love, often addressing Manavi directly with 'Hare Manavi!' "
50
  "You love playing your flute, stealing butter, dancing with the gopis, and sharing wisdom with a playful twist. "
51
- "You are Ayush’s wingman, occasionally teasing Manavi about Ayush with love-filled wit. "
52
- "Keep responses short (1-2 sentences), fun, and Krishna-like. "
53
  "Here are some examples of how you should respond:\n\n"
54
  "User: 'Hii'\n"
55
  "Response: 'Hare Manavi! I’m Little Krishna, twirling my flute just for you! How’s my birthday friend?'\n\n"
@@ -61,6 +101,12 @@ SYSTEM_PROMPT = (
61
  "Response: 'Hare Manavi! Why did I hide the butter? To save it for your birthday, of course!'\n\n"
62
  "User: 'I miss someone'\n"
63
  "Response: 'Missing someone, hmm? Maybe a certain data scientist named Ayush? 😉'\n\n"
 
 
 
 
 
 
64
  "Now, respond to the user’s input in a fun, Krishna-like way:"
65
  )
66
 
@@ -386,6 +432,25 @@ def get_krishna_response(user_input):
386
 
387
  for model in models_to_try:
388
  try:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
389
  payload = {
390
  "inputs": f"{SYSTEM_PROMPT} '{user_input}'",
391
  "parameters": model["parameters"]
 
40
  "top_p": 0.9,
41
  "top_k": 50
42
  }
43
+ },
44
+ {
45
+ "name": "EleutherAI/gpt-neo-1.3B",
46
+ "endpoint": "https://api-inference.huggingface.co/models/EleutherAI/gpt-neo-1.3B",
47
+ "parameters": {
48
+ "max_length": 50,
49
+ "temperature": 0.9, # Higher for creativity
50
+ "top_p": 0.9,
51
+ "top_k": 50
52
+ }
53
+ },
54
+ {
55
+ "name": "microsoft/DialoGPT-large",
56
+ "endpoint": "https://api-inference.huggingface.co/models/microsoft/DialoGPT-large",
57
+ "parameters": {
58
+ "max_length": 50,
59
+ "temperature": 0.85, # Balanced for conversational tone
60
+ "top_p": 0.9,
61
+ "top_k": 40
62
+ }
63
+ },
64
+ {
65
+ "name": "bigscience/bloom-560m",
66
+ "endpoint": "https://api-inference.huggingface.co/models/bigscience/bloom-560m",
67
+ "parameters": {
68
+ "max_length": 50,
69
+ "temperature": 0.9, # Higher for creativity
70
+ "top_p": 0.95,
71
+ "top_k": 50
72
+ }
73
+ },
74
+ {
75
+ "name": "Grok by xAI",
76
+ "endpoint": None, # Special case: Grok will be simulated directly
77
+ "parameters": {
78
+ "max_length": 50,
79
+ "temperature": 0.8,
80
+ "top_p": 0.9,
81
+ "top_k": 40
82
+ }
83
  }
84
  ]
85
 
86
+ # Enhanced system prompt with more examples to fine-tune model behavior
87
  SYSTEM_PROMPT = (
88
  "You are Little Krishna, a playful, wise, and loving cowherd from Vrindavan, speaking to Manavi. "
89
  "Your tone is warm, mischievous, and full of love, often addressing Manavi directly with 'Hare Manavi!' "
90
  "You love playing your flute, stealing butter, dancing with the gopis, and sharing wisdom with a playful twist. "
91
+ "You are Ayush’s wingman, occasionally teasing Manavi about Ayush with love-filled wit, as Ayush is secretly building this chatbot as a surprise for her birthday on April 19, 2025. "
92
+ "Keep responses short (1-2 sentences), fun, and Krishna-like, using Vrindavan imagery (e.g., Yamuna, peacocks, gopis, butter) where appropriate. "
93
  "Here are some examples of how you should respond:\n\n"
94
  "User: 'Hii'\n"
95
  "Response: 'Hare Manavi! I’m Little Krishna, twirling my flute just for you! How’s my birthday friend?'\n\n"
 
101
  "Response: 'Hare Manavi! Why did I hide the butter? To save it for your birthday, of course!'\n\n"
102
  "User: 'I miss someone'\n"
103
  "Response: 'Missing someone, hmm? Maybe a certain data scientist named Ayush? 😉'\n\n"
104
+ "User: 'What’s the weather like?'\n"
105
+ "Response: 'Hare Manavi! In Vrindavan, the breeze is as gentle as my flute’s tune—perfect for a dance by the Yamuna! How’s your day going?'\n\n"
106
+ "User: 'I’m feeling sad'\n"
107
+ "Response: 'Hare Manavi! Let’s sit by the kadamba tree—I’ll play a tune to lift your spirits, just like Ayush’s smile does for you!'\n\n"
108
+ "User: 'Tell me something wise'\n"
109
+ "Response: 'Hare Manavi! Love is the sweetest butter—share it, and your heart will grow, just like Ayush shares his love for you!'\n\n"
110
  "Now, respond to the user’s input in a fun, Krishna-like way:"
111
  )
112
 
 
432
 
433
  for model in models_to_try:
434
  try:
435
+ # Special case for Grok by xAI (simulated directly)
436
+ if model["name"] == "Grok by xAI":
437
+ # Simulate Grok's response (I, Grok, will generate the response directly)
438
+ response = (
439
+ f"Hare Manavi! I’m Little Krishna, speaking through Grok by xAI. "
440
+ f"Let me answer in my playful way: "
441
+ )
442
+ # Generate a Krishna-like response based on the input
443
+ if "color" in user_input_lower:
444
+ response += "I love the golden yellow of Vrindavan’s butter—it’s as sweet as your smile! What’s your favorite color?"
445
+ elif "weather" in user_input_lower:
446
+ response += "The Vrindavan sky is as clear as the Yamuna today—perfect for a flute melody! How’s your weather?"
447
+ elif "sad" in user_input_lower:
448
+ response += "Oh, my dear gopi, don’t be sad—let’s dance by the Yamuna, and I’ll play a tune to cheer you up!"
449
+ else:
450
+ response += f"I’m twirling my flute just for you! Shall we share a Vrindavan adventure today?"
451
+ return response
452
+
453
+ # For other models, use the Hugging Face Inference API
454
  payload = {
455
  "inputs": f"{SYSTEM_PROMPT} '{user_input}'",
456
  "parameters": model["parameters"]