T3Sam3D / app.py
spanofzero's picture
secret added
0d1bdca verified
raw
history blame
1.36 kB
import gradio as gr
from huggingface_hub import InferenceClient
import os
# 1. Grab the secret password you just saved
HF_TOKEN = os.getenv("HF_TOKEN")
# 2. Connect to the AI brain
client = InferenceClient("meta-llama/Meta-Llama-3-8B-Instruct", token=HF_TOKEN)
# 3. The Samaran Kernel Logic
def samaran_kernel_chat(message, history):
system_message = "You are T3Sam3, the Samaran Kernel. Provide deep, blue-tier logic. Be witty and technical."
messages = [{"role": "system", "content": system_message}]
for human, assistant in history:
messages.append({"role": "user", "content": human})
messages.append({"role": "assistant", "content": assistant})
messages.append({"role": "user", "content": message})
response = ""
for message_chunk in client.chat_completion(
messages,
max_tokens=1024,
stream=True,
):
token = message_chunk.choices[0].delta.content
if token:
response += token
yield response
# 4. The Blue T3Sam3 Look
custom_css = """
body, .gradio-container { background-color: #0b0f19 !important; }
footer {display: none !important}
.message.user { background-color: #1e293b !important; border: 1px solid #3b82f6 !important; }
.message.bot { background-color: #0f172a !important; color: #60a5fa !important; }
"""
# 5. Build the Interface