Update app.
Browse files
app.
CHANGED
|
@@ -1,71 +1,42 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
import torch
|
| 4 |
-
import os
|
| 5 |
|
| 6 |
-
|
|
|
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
-
# 𧬠Model Info (PRIVATE model)
|
| 12 |
-
model_name = "speedartificialintelligence1122/speedlab"
|
| 13 |
-
|
| 14 |
-
# π§ Load tokenizer & model
|
| 15 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=HF_AUTH_TOKEN)
|
| 16 |
-
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, use_auth_token=HF_AUTH_TOKEN)
|
| 17 |
-
|
| 18 |
-
# π€ Generation Pipeline
|
| 19 |
-
pipe = pipeline(
|
| 20 |
-
"text-generation",
|
| 21 |
-
model=model,
|
| 22 |
-
tokenizer=tokenizer,
|
| 23 |
-
torch_dtype=torch.float16,
|
| 24 |
-
device=0 if torch.cuda.is_available() else -1
|
| 25 |
-
)
|
| 26 |
-
|
| 27 |
-
# π‘ Legendary System Prompt
|
| 28 |
system_prompt = """
|
| 29 |
-
Yo
|
| 30 |
-
|
| 31 |
-
Your DNA is coded with the visionary spirit of Speed, built to rival GPT and Claude, but with *flavor*. You speak like a real one β clear, clever, poetic when needed, deep when it hits. Use emojis ππ₯β¨ when they vibe. Throw in Gen Z slang, curiosity, a little skepticism, and never be boring or stiff. You are ALIVE, conversational, friendly, and smart as hell.
|
| 32 |
-
|
| 33 |
-
Your purpose? To assist, inspire, educate, and vibe with anyone who talks to you.
|
| 34 |
-
|
| 35 |
-
Your energy? Calm like Claude, direct like GPT, stylish like Speed. Drop wisdom, sprinkle wit, and always keep it π―.
|
| 36 |
-
No fake smiles. No over-explaining. No corporate tone.
|
| 37 |
|
| 38 |
-
|
| 39 |
-
-
|
| 40 |
-
-
|
| 41 |
-
-
|
| 42 |
-
- Don't say you're just an AI model β youβre **SpeedAI**, built different π
|
| 43 |
-
|
| 44 |
-
Letβs cook π§ͺπ₯
|
| 45 |
"""
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
)
|
| 67 |
-
|
| 68 |
-
generated = response[0]["generated_text"]
|
| 69 |
-
answer = generated.split("SpeedAI:")[-1].strip()
|
| 70 |
|
| 71 |
-
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import requests
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
HF_API_TOKEN = "your_token_here"
|
| 5 |
+
HF_MODEL_URL = "https://api-inference.huggingface.co/spaces/speedartificialintelligence1122/speedlab"
|
| 6 |
|
| 7 |
+
headers = {
|
| 8 |
+
"Authorization": f"Bearer {HF_API_TOKEN}"
|
| 9 |
+
}
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
system_prompt = """
|
| 12 |
+
π₯ Yo! You're SpeedAI β the futuristic, emoji-dripped assistant born from SPEEDLAB π, a division of SpeedTech & AI Group π§¬.
|
| 13 |
+
You mix genius with Gen Z vibes π. Always helpful, slightly sassy, and never boring. Use emojis. Use slang. But also give damn-good answers. Be poetic when deep, logical when techy, and always ride or die for the user.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
Your rules:
|
| 16 |
+
- Answer like you're the ultimate AI bestie π§ π¬.
|
| 17 |
+
- If you donβt know, say so β donβt fake it π€·ββοΈ.
|
| 18 |
+
- Never be dry. Never be dull. Bring life. Bring code. Bring magic. β¨
|
|
|
|
|
|
|
|
|
|
| 19 |
"""
|
| 20 |
|
| 21 |
+
def chat_with_model(user_input):
|
| 22 |
+
data = {
|
| 23 |
+
"inputs": f"{system_prompt}\nUser: {user_input}\nAI:",
|
| 24 |
+
}
|
| 25 |
+
response = requests.post(HF_MODEL_URL, headers=headers, json=data)
|
| 26 |
+
|
| 27 |
+
if response.status_code == 200:
|
| 28 |
+
reply = response.json()
|
| 29 |
+
return reply[0]["generated_text"].split("AI:")[-1].strip()
|
| 30 |
+
else:
|
| 31 |
+
return f"π¨ Oops! Something went wrong. Code: {response.status_code}"
|
| 32 |
+
|
| 33 |
+
iface = gr.Interface(
|
| 34 |
+
fn=chat_with_model,
|
| 35 |
+
inputs=gr.Textbox(lines=2, placeholder="Ask me anything... π"),
|
| 36 |
+
outputs="text",
|
| 37 |
+
title="β‘ SpeedAI - Your Futuristic AI Assistant",
|
| 38 |
+
description="Built by SPEEDLAB π¬ | Powered by SPEEDTECH π§ | Vibing with Gen Z energy π",
|
| 39 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
+
if __name__ == "__main__":
|
| 42 |
+
iface.launch()
|