Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,24 +21,31 @@ def format_emem_cell64(claim: str) -> str:
|
|
| 21 |
|
| 22 |
@spaces.GPU(duration=30)
|
| 23 |
def phoebus_respond(message, history, enable_tinyfish, enable_emem):
|
| 24 |
-
system_prompt = (
|
| 25 |
-
"You are Phoebus 3.1 Flash, a rapid-reasoning model specialized in deep space telemetry, "
|
| 26 |
-
"Earth geography, and coding, developed by Clovr (atclovr.dev). "
|
| 27 |
-
"Always cite emem protocol receipts when validating spatial coordinates."
|
| 28 |
-
)
|
| 29 |
-
|
| 30 |
-
context = ""
|
| 31 |
msg_text = message if isinstance(message, str) else message.get("text", "")
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
receipt = format_emem_cell64(msg_text)
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
-
# Build conversation messages
|
| 41 |
-
formatted_messages = [{"role": "system", "content":
|
| 42 |
|
| 43 |
for turn in history:
|
| 44 |
if isinstance(turn, dict):
|
|
@@ -47,7 +54,7 @@ def phoebus_respond(message, history, enable_tinyfish, enable_emem):
|
|
| 47 |
formatted_messages.append({"role": "user", "content": str(turn[0])})
|
| 48 |
formatted_messages.append({"role": "assistant", "content": str(turn[1])})
|
| 49 |
|
| 50 |
-
formatted_messages.append({"role": "user", "content": msg_text
|
| 51 |
|
| 52 |
prompt = tokenizer.apply_chat_template(
|
| 53 |
formatted_messages,
|
|
@@ -59,7 +66,7 @@ def phoebus_respond(message, history, enable_tinyfish, enable_emem):
|
|
| 59 |
with torch.no_grad():
|
| 60 |
outputs = model.generate(
|
| 61 |
**inputs,
|
| 62 |
-
max_new_tokens=
|
| 63 |
temperature=0.7,
|
| 64 |
do_sample=True,
|
| 65 |
pad_token_id=tokenizer.eos_token_id
|
|
@@ -72,7 +79,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="purple")) as demo:
|
|
| 72 |
gr.Markdown("# ⚡ Phoebus 3.1 Flash Console\n*Ultra-fast reasoning model by Clovr (atclovr.dev)*")
|
| 73 |
|
| 74 |
with gr.Row():
|
| 75 |
-
tinyfish_toggle = gr.Checkbox(label="Enable TinyFish
|
| 76 |
emem_toggle = gr.Checkbox(label="Enable emem cell64 Protocol", value=True)
|
| 77 |
|
| 78 |
gr.ChatInterface(
|
|
|
|
| 21 |
|
| 22 |
@spaces.GPU(duration=30)
|
| 23 |
def phoebus_respond(message, history, enable_tinyfish, enable_emem):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
msg_text = message if isinstance(message, str) else message.get("text", "")
|
| 25 |
|
| 26 |
+
# System instructions
|
| 27 |
+
system_rules = [
|
| 28 |
+
"You are Phoebus 3.1 Flash, an ultra-fast reasoning model developed by Clovr (atclovr.dev).",
|
| 29 |
+
"You specialize in deep space telemetry, geography, urban infrastructure, and coding."
|
| 30 |
+
]
|
| 31 |
+
|
| 32 |
+
# Handle emem Protocol
|
| 33 |
+
if enable_emem:
|
| 34 |
receipt = format_emem_cell64(msg_text)
|
| 35 |
+
system_rules.append(
|
| 36 |
+
f"MANDATORY PROTOCOL: You must cite spatial verification receipt `{receipt}` in your final response when answering geographic or spatial queries."
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
+
# Handle TinyFish Protocol
|
| 40 |
+
if enable_tinyfish:
|
| 41 |
+
system_rules.append(
|
| 42 |
+
f"[TinyFish Telemetry]: Physical and spatial telemetry index verified for query: '{msg_text}'."
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
formatted_system_prompt = " ".join(system_rules)
|
| 46 |
|
| 47 |
+
# Build conversation messages
|
| 48 |
+
formatted_messages = [{"role": "system", "content": formatted_system_prompt}]
|
| 49 |
|
| 50 |
for turn in history:
|
| 51 |
if isinstance(turn, dict):
|
|
|
|
| 54 |
formatted_messages.append({"role": "user", "content": str(turn[0])})
|
| 55 |
formatted_messages.append({"role": "assistant", "content": str(turn[1])})
|
| 56 |
|
| 57 |
+
formatted_messages.append({"role": "user", "content": msg_text})
|
| 58 |
|
| 59 |
prompt = tokenizer.apply_chat_template(
|
| 60 |
formatted_messages,
|
|
|
|
| 66 |
with torch.no_grad():
|
| 67 |
outputs = model.generate(
|
| 68 |
**inputs,
|
| 69 |
+
max_new_tokens=300,
|
| 70 |
temperature=0.7,
|
| 71 |
do_sample=True,
|
| 72 |
pad_token_id=tokenizer.eos_token_id
|
|
|
|
| 79 |
gr.Markdown("# ⚡ Phoebus 3.1 Flash Console\n*Ultra-fast reasoning model by Clovr (atclovr.dev)*")
|
| 80 |
|
| 81 |
with gr.Row():
|
| 82 |
+
tinyfish_toggle = gr.Checkbox(label="Enable TinyFish Telemetry", value=True)
|
| 83 |
emem_toggle = gr.Checkbox(label="Enable emem cell64 Protocol", value=True)
|
| 84 |
|
| 85 |
gr.ChatInterface(
|