Spaces:
Running on Zero
Running on Zero
Deploy SAM-AI app.py
Browse files
app.py
CHANGED
|
@@ -37,9 +37,18 @@ SYSTEM_PROMPT_CODE = (
|
|
| 37 |
"by Parallax Intelligence Lab. You assist with coding, debugging, refactoring, and code review. "
|
| 38 |
"When suggesting changes, present code clearly and use standard unified diff format where appropriate. "
|
| 39 |
"Never invent fake library APIs or pretend unexecuted commands ran successfully."
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
|
|
|
|
| 43 |
def chat_respond(user_message, chat_history, temperature, top_p, max_tokens):
|
| 44 |
"""Handles multi-turn conversation streaming in SAM-AI Chat."""
|
| 45 |
if not user_message or not user_message.strip():
|
|
@@ -70,6 +79,7 @@ def chat_respond(user_message, chat_history, temperature, top_p, max_tokens):
|
|
| 70 |
yield new_history, ""
|
| 71 |
|
| 72 |
|
|
|
|
| 73 |
def code_respond(user_prompt, code_context, task_type, temperature, max_tokens):
|
| 74 |
"""Handles coding tasks, explanations, and diff generation in SAM-AI Code."""
|
| 75 |
if not user_prompt or not user_prompt.strip():
|
|
|
|
| 37 |
"by Parallax Intelligence Lab. You assist with coding, debugging, refactoring, and code review. "
|
| 38 |
"When suggesting changes, present code clearly and use standard unified diff format where appropriate. "
|
| 39 |
"Never invent fake library APIs or pretend unexecuted commands ran successfully."
|
| 40 |
+
try:
|
| 41 |
+
import spaces
|
| 42 |
+
except ImportError:
|
| 43 |
+
class _MockSpaces:
|
| 44 |
+
def GPU(self, duration=60):
|
| 45 |
+
def decorator(fn):
|
| 46 |
+
return fn
|
| 47 |
+
return decorator
|
| 48 |
+
spaces = _MockSpaces()
|
| 49 |
|
| 50 |
|
| 51 |
+
@spaces.GPU(duration=20)
|
| 52 |
def chat_respond(user_message, chat_history, temperature, top_p, max_tokens):
|
| 53 |
"""Handles multi-turn conversation streaming in SAM-AI Chat."""
|
| 54 |
if not user_message or not user_message.strip():
|
|
|
|
| 79 |
yield new_history, ""
|
| 80 |
|
| 81 |
|
| 82 |
+
@spaces.GPU(duration=20)
|
| 83 |
def code_respond(user_prompt, code_context, task_type, temperature, max_tokens):
|
| 84 |
"""Handles coding tasks, explanations, and diff generation in SAM-AI Code."""
|
| 85 |
if not user_prompt or not user_prompt.strip():
|