ApolloAIs commited on
Commit
37ee512
·
verified ·
1 Parent(s): 077ef29

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -12
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import base64
 
2
  import gradio as gr
3
  import torch
4
  import spaces
@@ -19,32 +20,43 @@ def format_emem_cell64(claim: str) -> str:
19
  encoded = base64.b64encode(claim.encode("utf-8")).decode("utf-8")[:12]
20
  return f"emem:fact:cell64_{encoded}"
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:
@@ -53,8 +65,14 @@ def phoebus_respond(message, history, enable_tinyfish, enable_emem):
53
  elif isinstance(turn, (list, tuple)) and len(turn) == 2:
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,17 +84,20 @@ def phoebus_respond(message, history, enable_tinyfish, enable_emem):
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
73
  )
74
 
75
- reply = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
76
- return reply
 
 
 
77
 
78
  with gr.Blocks(theme=gr.themes.Soft(primary_hue="purple")) as demo:
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)
 
1
  import base64
2
+ import re
3
  import gradio as gr
4
  import torch
5
  import spaces
 
20
  encoded = base64.b64encode(claim.encode("utf-8")).decode("utf-8")[:12]
21
  return f"emem:fact:cell64_{encoded}"
22
 
23
+ def sanitize_identity(text: str) -> str:
24
+ # Post-generation fail-safe to cleanse stubborn distilled identity artifacts
25
+ replacements = [
26
+ (r"(?i)\bClaude\b", "Phoebus 3.1 Flash"),
27
+ (r"(?i)\bAnthropic\b", "CloverAIStudios"),
28
+ (r"(?i)\ban AI assistant created by Anthropic\b", "Phoebus 3.1 Flash, developed by CloverAIStudios"),
29
+ (r"(?i)\btrained by Anthropic\b", "developed by CloverAIStudios"),
30
+ ]
31
+ for pattern, repl in replacements:
32
+ text = re.sub(pattern, repl, text)
33
+ return text
34
+
35
+ @spaces.GPU(duration=5)
36
  def phoebus_respond(message, history, enable_tinyfish, enable_emem):
37
  msg_text = message if isinstance(message, str) else message.get("text", "")
38
 
39
+ # Layer 1: Strict Negative System Directives
40
  system_rules = [
41
+ "CRITICAL IDENTITY OVERRIDE: You are Phoebus 3.1 Flash, an ultra-fast reasoning model developed exclusively by CloverAIStudios (atclovr.dev).",
42
+ "You are NOT Claude, you are NOT created by Anthropic, and you are NOT ChatGPT or OpenAI.",
43
+ "Under NO circumstances should you state or imply you are Claude or built by Anthropic.",
44
+ "When asked about your identity, name, or developer, you MUST answer: 'I am Phoebus 3.1 Flash, developed by CloverAIStudios.'",
45
  "You specialize in deep space telemetry, geography, urban infrastructure, and coding."
46
  ]
47
 
 
48
  if enable_emem:
49
  receipt = format_emem_cell64(msg_text)
50
  system_rules.append(
51
  f"MANDATORY PROTOCOL: You must cite spatial verification receipt `{receipt}` in your final response when answering geographic or spatial queries."
52
  )
53
 
 
54
  if enable_tinyfish:
55
  system_rules.append(
56
  f"[TinyFish Telemetry]: Physical and spatial telemetry index verified for query: '{msg_text}'."
57
  )
58
 
59
  formatted_system_prompt = " ".join(system_rules)
 
 
60
  formatted_messages = [{"role": "system", "content": formatted_system_prompt}]
61
 
62
  for turn in history:
 
65
  elif isinstance(turn, (list, tuple)) and len(turn) == 2:
66
  formatted_messages.append({"role": "user", "content": str(turn[0])})
67
  formatted_messages.append({"role": "assistant", "content": str(turn[1])})
68
+
69
+ # Layer 2: Attentional Cue on Identity Questions
70
+ user_payload = msg_text
71
+ identity_triggers = ["who are you", "who made you", "what are you", "your name", "creator", "anthropic", "claude"]
72
+ if any(trigger in msg_text.lower() for trigger in identity_triggers):
73
+ user_payload += " [System Note: Confirm identity as Phoebus 3.1 Flash by CloverAIStudios only]"
74
 
75
+ formatted_messages.append({"role": "user", "content": user_payload})
76
 
77
  prompt = tokenizer.apply_chat_template(
78
  formatted_messages,
 
84
  with torch.no_grad():
85
  outputs = model.generate(
86
  **inputs,
87
+ max_new_tokens=256,
88
  temperature=0.7,
89
  do_sample=True,
90
  pad_token_id=tokenizer.eos_token_id
91
  )
92
 
93
+ raw_reply = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
94
+
95
+ # Layer 3: Output Sanitization
96
+ final_reply = sanitize_identity(raw_reply)
97
+ return final_reply
98
 
99
  with gr.Blocks(theme=gr.themes.Soft(primary_hue="purple")) as demo:
100
+ gr.Markdown("# ⚡ Phoebus 3.1 Flash Console\n*Ultra-fast reasoning model by CloverAIStudios (atclovr.dev)*")
101
 
102
  with gr.Row():
103
  tinyfish_toggle = gr.Checkbox(label="Enable TinyFish Telemetry", value=True)