Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,31 @@
|
|
1 |
import gradio as gr
|
2 |
import openai
|
3 |
import os
|
|
|
4 |
|
5 |
# Setting up the API key for Groq API
|
6 |
openai.api_key = os.getenv("GROQ_API_KEY")
|
7 |
openai.api_base = "https://api.groq.com/openai/v1"
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# Function to get a casual, funny response with grammatical errors
|
10 |
def get_groq_response(message):
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
try:
|
12 |
response = openai.ChatCompletion.create(
|
13 |
model="llama-3.1-70b-versatile",
|
|
|
1 |
import gradio as gr
|
2 |
import openai
|
3 |
import os
|
4 |
+
import random
|
5 |
|
6 |
# Setting up the API key for Groq API
|
7 |
openai.api_key = os.getenv("GROQ_API_KEY")
|
8 |
openai.api_base = "https://api.groq.com/openai/v1"
|
9 |
|
10 |
+
# Predefined fine-tuned chat dataset for reference
|
11 |
+
fine_tuned_chats = [
|
12 |
+
{"user": "Bhai, padhai nahi ho rahi…", "bot": "Arre, chill kar bhai! Padhai ki tension mat le, thoda break le… Mast coffee maar aur wapas aa ja. ☕"},
|
13 |
+
{"user": "Yaar, motivation nahi mil raha…", "bot": "Motivation milta nahi… Usko dhoondhna padta hai! 😎 Ek goal set kar aur bas lag ja kaam pe."},
|
14 |
+
{"user": "Life boring lag rahi hai…", "bot": "Arre bhai, life boring nahi hoti… Bas hum thoda lazy ho jate hai! 😂 Chal, kuch naya try kar!"},
|
15 |
+
{"user": "Bro, exam aa raha hai… tension ho rahi hai.", "bot": "Arre bhai, tension lene ka nahi… Last night ke revision pe bharosa rakh! 📚"},
|
16 |
+
{"user": "Bhai, dosti mein problem ho gayi hai…", "bot": "Arre, dosti ka funda simple hai… Ego hatao, apna dil kholo. Jo real friend hoga, woh samjhega. 🤝"},
|
17 |
+
{"user": "Bore ho raha hoon… Timepass karna hai.", "bot": "Arre, meme dekho, thoda gaming karlo, ya kisi se baat karlo. Zindagi ka mazza lo! 😂"},
|
18 |
+
{"user": "Career ko lekar confuse hoon… kya karu?", "bot": "Confusion sabko hota hai… Thoda explore karo, apne interest find karo. Passion follow karo, paise apne aap aayenge. 💼"}
|
19 |
+
]
|
20 |
+
|
21 |
# Function to get a casual, funny response with grammatical errors
|
22 |
def get_groq_response(message):
|
23 |
+
# Check if the user message matches any fine-tuned chat
|
24 |
+
for chat in fine_tuned_chats:
|
25 |
+
if message.lower() == chat["user"].lower():
|
26 |
+
return chat["bot"]
|
27 |
+
|
28 |
+
# If not in the predefined chats, call the Groq API
|
29 |
try:
|
30 |
response = openai.ChatCompletion.create(
|
31 |
model="llama-3.1-70b-versatile",
|