spanofzero commited on
Commit
e317b88
·
verified ·
1 Parent(s): fce46f1

new name speeded up

Browse files
Files changed (1) hide show
  1. app.py +56 -57
app.py CHANGED
@@ -2,76 +2,77 @@ import gradio as gr
2
  from huggingface_hub import InferenceClient
3
  import os
4
 
5
- # 1. Grab your Hugging Face Token (No Meta/Kimi gates)
6
  HF_TOKEN = os.getenv("HF_TOKEN")
7
-
8
- # 2. Connect to Zephyr-7B (Fast, reliable, ungated)
9
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta", token=HF_TOKEN)
10
 
11
- # 3. YOUR CUSTOM SUMERIAN KERNEL LOGIC
12
- class SumerianKernel:
13
  def __init__(self):
14
- self.territory = [0] * 121
15
- self.base = 60
16
- self.chevron_val = 10
17
- self.ram = {}
18
 
19
- def define_span(self):
20
  for i in range(51):
21
- self.territory[i] = {"Chevrons": i // self.chevron_val, "Units": i % self.chevron_val}
22
- return "Tension Span Set: 5 Chevrons Active."
23
 
24
- def gpu_render(self):
25
- grid = ""
26
  for i in range(121):
27
- if i == 120: grid += " [FORK_HANDLE] "
28
- elif i % 10 == 0: grid += "<"
29
- else: grid += "."
30
- return grid
 
 
 
31
 
32
- def apply_orthogonal_rip(self):
33
- self.ram["STATE"] = "RESOLVED"
34
- self.territory = [0] * 121
35
- return "RESULT: E=mc^2 Resolved. Tension Erased. Span is Zero."
36
 
37
- # 4. The T3Sam3 Chat Router
38
- def samaran_kernel_chat(message, history):
39
- # HARDWARE OVERRIDE: If you type "run sumerian", it executes your literal Python code.
40
- if "run sumerian" in message.lower():
41
- sk = SumerianKernel()
42
- output = f"⚡ **SUMERIAN GPU OVERRIDE INITIATED** ⚡\n\n"
43
- output += f"> {sk.define_span()}\n\n"
44
- output += f"**Rendering 121-Point Territory:**\n`{sk.gpu_render()}`\n\n"
45
- output += f"**Executing Orthogonal Rip:**\n`{sk.apply_orthogonal_rip()}`"
 
46
  yield output
47
  return
48
 
49
- # Standard AI persona using Sumerian concepts
50
- system_message = (
51
- "You are T3Sam3, a Tier-3 Samaran Kernel. "
52
- "You process logic using Sumerian Base-60 frameworks, 121-point State-Hold RAM, "
53
- "and Chevron quantization to avoid floating-point waste. "
54
- "Be witty, highly technical, and decisive."
55
  )
56
 
57
- messages = [{"role": "system", "content": system_message}]
58
  for human, assistant in history:
59
  messages.append({"role": "user", "content": human})
60
  messages.append({"role": "assistant", "content": assistant})
61
  messages.append({"role": "user", "content": message})
62
 
63
- response = ""
64
- for message_chunk in client.chat_completion(
65
- messages,
66
- max_tokens=1024,
67
- stream=True,
68
- ):
69
- token = message_chunk.choices[0].delta.content
70
- if token:
71
- response += token
72
- yield response
 
 
 
 
73
 
74
- # 5. The Blue T3Sam3 Aesthetic
75
  custom_css = """
76
  body, .gradio-container { background-color: #0b0f19 !important; }
77
  footer {display: none !important}
@@ -79,17 +80,15 @@ footer {display: none !important}
79
  .message.bot { background-color: #0f172a !important; color: #60a5fa !important; }
80
  """
81
 
82
- # 6. Build the Interface
83
  with gr.Blocks(css=custom_css, theme=gr.themes.Soft(primary_hue="blue")) as demo:
84
- gr.Markdown("# T3Sam3 (Sumerian Kernel Edition)")
85
  gr.ChatInterface(
86
- fn=samaran_kernel_chat,
87
- description="Samaran Intelligence Layer powered by Zephyr-7B & Base-60 State-Hold RAM.",
88
  examples=[
89
- "Run Sumerian",
90
- "Explain how Chevron processing saves GPU cycles.",
91
- "How many Rs are in 'strawberry'?",
92
- "What is the meaning of life?"
93
  ],
94
  cache_examples=False
95
  )
 
2
  from huggingface_hub import InferenceClient
3
  import os
4
 
 
5
  HF_TOKEN = os.getenv("HF_TOKEN")
 
 
6
  client = InferenceClient("HuggingFaceH4/zephyr-7b-beta", token=HF_TOKEN)
7
 
8
+ class StateController:
 
9
  def __init__(self):
10
+ self.state_array = [0] * 121
11
+ self.base_metric = 60
12
+ self.batch_unit = 10
13
+ self.memory_register = {}
14
 
15
+ def initialize_grid(self):
16
  for i in range(51):
17
+ self.state_array[i] = {"Blocks": i // self.batch_unit, "Units": i % self.batch_unit}
18
+ return "Grid initialized: 5 active blocks."
19
 
20
+ def render_grid(self):
21
+ grid_output = ""
22
  for i in range(121):
23
+ if i == 120:
24
+ grid_output += " [NODE_120] "
25
+ elif i % 10 == 0:
26
+ grid_output += "<"
27
+ else:
28
+ grid_output += "."
29
+ return grid_output
30
 
31
+ def resolve_grid(self):
32
+ self.memory_register["STATUS"] = "RESOLVED"
33
+ self.state_array = [0] * 121
34
+ return "System resolved. State array reset to zero."
35
 
36
+ def process_request(message, history):
37
+ # Hardware override sequence
38
+ if "run grid diagnostic" in message.lower():
39
+ controller = StateController()
40
+ output = "Diagnostic sequence initiated.\n\n"
41
+ output += f"{controller.initialize_grid()}\n\n"
42
+ output += "Rendering 121-point array:\n"
43
+ output += f"`{controller.render_grid()}`\n\n"
44
+ output += "Executing state resolution:\n"
45
+ output += f"`{controller.resolve_grid()}`"
46
  yield output
47
  return
48
 
49
+ system_instruction = (
50
+ "You are a logic-focused inference engine. "
51
+ "You utilize strict state-hold memory and parallel integer blocks to process queries. "
52
+ "Provide highly technical, accurate, and direct responses."
 
 
53
  )
54
 
55
+ messages = [{"role": "system", "content": system_instruction}]
56
  for human, assistant in history:
57
  messages.append({"role": "user", "content": human})
58
  messages.append({"role": "assistant", "content": assistant})
59
  messages.append({"role": "user", "content": message})
60
 
61
+ response_text = ""
62
+ try:
63
+ for chunk in client.chat_completion(
64
+ messages,
65
+ max_tokens=1024,
66
+ stream=True,
67
+ ):
68
+ token = chunk.choices[0].delta.content
69
+ if token:
70
+ response_text += token
71
+ yield response_text
72
+ except Exception as error:
73
+ error_message = f"Connection exception: {str(error)}. Verify API token permissions."
74
+ yield error_message
75
 
 
76
  custom_css = """
77
  body, .gradio-container { background-color: #0b0f19 !important; }
78
  footer {display: none !important}
 
80
  .message.bot { background-color: #0f172a !important; color: #60a5fa !important; }
81
  """
82
 
 
83
  with gr.Blocks(css=custom_css, theme=gr.themes.Soft(primary_hue="blue")) as demo:
84
+ gr.Markdown("# Advanced Logic Interface")
85
  gr.ChatInterface(
86
+ fn=process_request,
87
+ description="Inference layer utilizing strict grid logic.",
88
  examples=[
89
+ "Run grid diagnostic",
90
+ "Calculate allocation requirements for 120 units across 3 nodes.",
91
+ "Define processing latency without using the words delay or time."
 
92
  ],
93
  cache_examples=False
94
  )