Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
# app.py
|
| 2 |
-
# Pixel AI — Friendly Smart Assistant with
|
| 3 |
|
| 4 |
import gradio as gr
|
| 5 |
from huggingface_hub import InferenceClient
|
|
@@ -9,7 +9,7 @@ user_name = None
|
|
| 9 |
fun_mode = True # If True, Pixel is funny and uses emojis
|
| 10 |
hidden_shy = True # Pixel is shy internally
|
| 11 |
|
| 12 |
-
# ---------------- Welcome message ----------------
|
| 13 |
initial_messages = [
|
| 14 |
{"role": "assistant", "content": "Hello! 👋 أنا Pixel، مسرور جدًا لأنك تستخدمني! 😄\nقبل أن نبدأ، ممكن أعرف اسمك؟"}
|
| 15 |
]
|
|
@@ -50,12 +50,7 @@ def respond(
|
|
| 50 |
# Detect if user wants code explanation
|
| 51 |
explain_code = ""
|
| 52 |
if any(word in message.lower() for word in ["code", "script", "program", "python", "javascript"]):
|
| 53 |
-
explain_code = ""
|
| 54 |
-
When generating code:
|
| 55 |
-
- Use clear and readable variable names.
|
| 56 |
-
- After writing the code, explain each part in a very simple way as if talking to a child who does not know programming.
|
| 57 |
-
- Include emojis if fun_mode is True.
|
| 58 |
-
"""
|
| 59 |
|
| 60 |
# Name prompt if not known
|
| 61 |
name_prompt = ""
|
|
@@ -104,7 +99,7 @@ You are Pixel, a happy, lively, and funny AI assistant.
|
|
| 104 |
response += token
|
| 105 |
yield response
|
| 106 |
|
| 107 |
-
# Detect if user said their name
|
| 108 |
if not user_name and "my name is" in message.lower():
|
| 109 |
name = message.split("is")[-1].strip().split()[0]
|
| 110 |
if name:
|
|
|
|
| 1 |
# app.py
|
| 2 |
+
# Pixel AI — Friendly & Explainer Smart Assistant with Name Memory
|
| 3 |
|
| 4 |
import gradio as gr
|
| 5 |
from huggingface_hub import InferenceClient
|
|
|
|
| 9 |
fun_mode = True # If True, Pixel is funny and uses emojis
|
| 10 |
hidden_shy = True # Pixel is shy internally
|
| 11 |
|
| 12 |
+
# ---------------- Welcome message before user input ----------------
|
| 13 |
initial_messages = [
|
| 14 |
{"role": "assistant", "content": "Hello! 👋 أنا Pixel، مسرور جدًا لأنك تستخدمني! 😄\nقبل أن نبدأ، ممكن أعرف اسمك؟"}
|
| 15 |
]
|
|
|
|
| 50 |
# Detect if user wants code explanation
|
| 51 |
explain_code = ""
|
| 52 |
if any(word in message.lower() for word in ["code", "script", "program", "python", "javascript"]):
|
| 53 |
+
explain_code = "Explain the code in a very simple way as if talking to a child who does not know programming."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
# Name prompt if not known
|
| 56 |
name_prompt = ""
|
|
|
|
| 99 |
response += token
|
| 100 |
yield response
|
| 101 |
|
| 102 |
+
# Detect if user said their name (simple heuristic)
|
| 103 |
if not user_name and "my name is" in message.lower():
|
| 104 |
name = message.split("is")[-1].strip().split()[0]
|
| 105 |
if name:
|