Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
|
|
@@ -12,7 +13,7 @@ def chat_with_groq(prompt, history):
|
|
| 12 |
headers = {"Authorization": f"Bearer {GROQ_API_KEY}", "Content-Type": "application/json"}
|
| 13 |
|
| 14 |
# System role for chatbot identity
|
| 15 |
-
messages = [{"role": "system", "content": "You are Faraz-Chatbot, an AI assistant
|
| 16 |
|
| 17 |
# Ensure history is in the correct format
|
| 18 |
for entry in history:
|
|
@@ -24,6 +25,10 @@ def chat_with_groq(prompt, history):
|
|
| 24 |
# Add the latest user query
|
| 25 |
messages.append({"role": "user", "content": prompt})
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
payload = {"model": "llama3-8b-8192", "messages": messages} # Groq's LLaMA 3 model
|
| 28 |
|
| 29 |
try:
|
|
@@ -53,6 +58,7 @@ def chatbot(query, history):
|
|
| 53 |
# Gradio Interface
|
| 54 |
with gr.Blocks() as demo:
|
| 55 |
gr.HTML("<h1 style='text-align: center; color: #00FF00; font-family: monospace;'>☠️ FARAZ-CHATBOT ☠️</h1>")
|
|
|
|
| 56 |
|
| 57 |
chatbot_interface = gr.Chatbot()
|
| 58 |
user_input = gr.Textbox(placeholder="Ask me anything...", show_label=False)
|
|
|
|
| 1 |
+
|
| 2 |
import gradio as gr
|
| 3 |
import requests
|
| 4 |
|
|
|
|
| 13 |
headers = {"Authorization": f"Bearer {GROQ_API_KEY}", "Content-Type": "application/json"}
|
| 14 |
|
| 15 |
# System role for chatbot identity
|
| 16 |
+
messages = [{"role": "system", "content": "You are Faraz-Chatbot, an AI assistant created by Muhammad Faraz to provide helpful responses."}]
|
| 17 |
|
| 18 |
# Ensure history is in the correct format
|
| 19 |
for entry in history:
|
|
|
|
| 25 |
# Add the latest user query
|
| 26 |
messages.append({"role": "user", "content": prompt})
|
| 27 |
|
| 28 |
+
# Custom response when asked about the owner
|
| 29 |
+
if "who is your owner" in prompt.lower() or "who created you" in prompt.lower():
|
| 30 |
+
return "I was created by Muhammad Faraz, a passionate developer!"
|
| 31 |
+
|
| 32 |
payload = {"model": "llama3-8b-8192", "messages": messages} # Groq's LLaMA 3 model
|
| 33 |
|
| 34 |
try:
|
|
|
|
| 58 |
# Gradio Interface
|
| 59 |
with gr.Blocks() as demo:
|
| 60 |
gr.HTML("<h1 style='text-align: center; color: #00FF00; font-family: monospace;'>☠️ FARAZ-CHATBOT ☠️</h1>")
|
| 61 |
+
gr.HTML("<p style='text-align: center; font-size: 18px;'>🤖 How can I help you?</p>")
|
| 62 |
|
| 63 |
chatbot_interface = gr.Chatbot()
|
| 64 |
user_input = gr.Textbox(placeholder="Ask me anything...", show_label=False)
|