Update app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,7 @@ def smart_response(command, execute):
|
|
| 10 |
# Dynamically adjust max_new_tokens based on complexity
|
| 11 |
simple_keywords = ["open", "close", "shutdown", "restart", "lock", "screenshot"]
|
| 12 |
is_simple = any(keyword in command.lower() for keyword in simple_keywords)
|
| 13 |
-
max_tokens = 128 if is_simple else 1024 #
|
| 14 |
|
| 15 |
return get_assistant_response(pipe, command, execute, max_new_tokens=max_tokens)
|
| 16 |
|
|
@@ -18,16 +18,25 @@ def smart_response(command, execute):
|
|
| 18 |
demo = gr.Interface(
|
| 19 |
fn=smart_response,
|
| 20 |
inputs=[
|
| 21 |
-
gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
gr.Checkbox(label="🛠️ Execute command (if possible)")
|
| 23 |
],
|
| 24 |
outputs="text",
|
| 25 |
title="🧠 Smart AI Assistant",
|
| 26 |
description=(
|
| 27 |
-
"AI assistant powered by
|
| 28 |
-
"Try commands like
|
| 29 |
-
"
|
| 30 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
),
|
| 32 |
flagging_mode="never"
|
| 33 |
)
|
|
|
|
| 10 |
# Dynamically adjust max_new_tokens based on complexity
|
| 11 |
simple_keywords = ["open", "close", "shutdown", "restart", "lock", "screenshot"]
|
| 12 |
is_simple = any(keyword in command.lower() for keyword in simple_keywords)
|
| 13 |
+
max_tokens = 128 if is_simple else 1024 # Shorter for quick commands, longer for reasoning
|
| 14 |
|
| 15 |
return get_assistant_response(pipe, command, execute, max_new_tokens=max_tokens)
|
| 16 |
|
|
|
|
| 18 |
demo = gr.Interface(
|
| 19 |
fn=smart_response,
|
| 20 |
inputs=[
|
| 21 |
+
gr.Textbox(
|
| 22 |
+
lines=2,
|
| 23 |
+
placeholder="e.g. Open Chrome or Take a screenshot",
|
| 24 |
+
label="🧾 Command"
|
| 25 |
+
),
|
| 26 |
gr.Checkbox(label="🛠️ Execute command (if possible)")
|
| 27 |
],
|
| 28 |
outputs="text",
|
| 29 |
title="🧠 Smart AI Assistant",
|
| 30 |
description=(
|
| 31 |
+
"AI assistant powered by **Mistral-7B-Instruct** 🧠\n\n"
|
| 32 |
+
"Try commands like:\n"
|
| 33 |
+
"• 'Open Chrome'\n"
|
| 34 |
+
"• 'Take a screenshot'\n"
|
| 35 |
+
"• 'What is AGI?'\n"
|
| 36 |
+
"• 'Summarize the history of AI'\n\n"
|
| 37 |
+
"✅ Simple commands → fast replies\n"
|
| 38 |
+
"🧠 Complex questions → thoughtful answers\n"
|
| 39 |
+
"⚠️ Check the box to allow real OS command execution"
|
| 40 |
),
|
| 41 |
flagging_mode="never"
|
| 42 |
)
|