Spaces:
Running
Running
new name speeded up
Browse files
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 |
-
|
| 12 |
-
class SumerianKernel:
|
| 13 |
def __init__(self):
|
| 14 |
-
self.
|
| 15 |
-
self.
|
| 16 |
-
self.
|
| 17 |
-
self.
|
| 18 |
|
| 19 |
-
def
|
| 20 |
for i in range(51):
|
| 21 |
-
self.
|
| 22 |
-
return "
|
| 23 |
|
| 24 |
-
def
|
| 25 |
-
|
| 26 |
for i in range(121):
|
| 27 |
-
if i == 120:
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
def
|
| 33 |
-
self.
|
| 34 |
-
self.
|
| 35 |
-
return "
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
output = f"
|
| 43 |
-
output +=
|
| 44 |
-
output += f"
|
| 45 |
-
output +=
|
|
|
|
| 46 |
yield output
|
| 47 |
return
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
"You
|
| 52 |
-
"
|
| 53 |
-
"and Chevron quantization to avoid floating-point waste. "
|
| 54 |
-
"Be witty, highly technical, and decisive."
|
| 55 |
)
|
| 56 |
|
| 57 |
-
messages = [{"role": "system", "content":
|
| 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 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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("#
|
| 85 |
gr.ChatInterface(
|
| 86 |
-
fn=
|
| 87 |
-
description="
|
| 88 |
examples=[
|
| 89 |
-
"Run
|
| 90 |
-
"
|
| 91 |
-
"
|
| 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 |
)
|