Run this model with HF Jobs

Run germanhcsuj/itsmyAI on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/germanhcsuj/itsmyAI. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/germanhcsuj/itsmyAI on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/germanhcsuj/itsmyAI. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/germanhcsuj/itsmyAI. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
itsmyAI / app.py
germanhcsuj's picture
Create app.py
0c5484c verified
Raw History Blame Contribute Delete
10.2 kB
"""
╔══════════════════════════════════════╗
║ SOLIFON AI — OFFLINE EDITION ║
║ Автор: Томанбаев Дастан ║
║ © 2026 Solifon AI ║
╚══════════════════════════════════════╝
"""
import os, sys, json, threading, webbrowser, time
from http.server import HTTPServer, BaseHTTPRequestHandler
# ── ЗАЩИТА АВТОРСТВА ──
AUTHOR = "Томанбаев Дастан © 2026 Solifon AI"
if not os.path.exists("AUTHOR.txt"):
print("\n⚠️ Файл AUTHOR.txt не найден. Возможно файлы повреждены.")
print(" Скачай оригинал: germanhcsuj-solifon-ai.static.hf.space")
input("Нажми Enter...")
sys.exit(1)
# ── АВТОУСТАНОВКА ──
def install(pkg):
import subprocess
subprocess.check_call([sys.executable, "-m", "pip", "install", pkg, "-q"])
try:
from llama_cpp import Llama
except ImportError:
print("[Solifon] Устанавливаю зависимости...")
install("llama-cpp-python")
from llama_cpp import Llama
# ── ПОИСК МОДЕЛИ ──
MODEL_PATH = None
for d in [".", ".solifon", "model", "models"]:
if os.path.exists(d):
for f in os.listdir(d):
if f.endswith(".gguf"):
MODEL_PATH = os.path.join(d, f)
break
if MODEL_PATH:
break
if not MODEL_PATH:
print("\n❌ Файл модели (.gguf) не найден!")
print(" Скачай полный архив с сайта: germanhcsuj-solifon-ai.static.hf.space")
input("\nНажми Enter...")
sys.exit(1)
print(f"\n🧠 Загрузка: {os.path.basename(MODEL_PATH)}")
print(f" {AUTHOR}")
llm = Llama(
model_path=MODEL_PATH,
n_ctx=4096,
n_threads=max(4, (os.cpu_count() or 4) - 1),
n_gpu_layers=0,
verbose=False
)
print("✅ Готово!\n")
# ── ИНТЕРФЕЙС ──
HTML = """<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Solifon AI — Offline</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<style>
:root{--bg:#0d0d0e;--border:rgba(255,255,255,0.08);--blue:#0044ff;--cyan:#00d4ff;}
*{margin:0;padding:0;box-sizing:border-box;}
body{background:var(--bg);color:#fff;font-family:'Inter',sans-serif;height:100vh;display:flex;flex-direction:column;overflow:hidden;}
body::before{content:'';position:fixed;inset:0;background-image:linear-gradient(rgba(0,68,255,0.03) 1px,transparent 1px),linear-gradient(90deg,rgba(0,68,255,0.03) 1px,transparent 1px);background-size:60px 60px;pointer-events:none;}
header{display:flex;align-items:center;padding:0 20px;height:60px;border-bottom:1px solid var(--border);background:rgba(13,13,14,0.9);backdrop-filter:blur(20px);gap:10px;z-index:10;}
.sq{width:16px;height:16px;background:#fff;border-radius:4px;box-shadow:0 0 15px #fff;}
.logo{font-weight:700;font-size:0.95rem;letter-spacing:1px;}
.badge{background:rgba(0,212,255,0.1);border:1px solid rgba(0,212,255,0.25);color:var(--cyan);font-size:0.68rem;padding:3px 10px;border-radius:20px;margin-left:auto;}
.chat{flex:1;overflow-y:auto;padding:20px;display:flex;flex-direction:column;gap:12px;scrollbar-width:thin;scrollbar-color:rgba(255,255,255,0.1) transparent;}
.welcome{margin:auto;text-align:center;}
.welcome svg{width:160px;height:160px;margin-bottom:16px;}
.welcome h2{font-size:1.6rem;font-weight:600;letter-spacing:2px;}
.welcome p{color:rgba(255,255,255,0.35);font-size:0.8rem;margin-top:6px;}
.welcome small{display:block;margin-top:12px;font-size:0.68rem;color:rgba(255,255,255,0.2);}
.msg{max-width:78%;padding:11px 15px;border-radius:14px;font-size:0.9rem;line-height:1.6;animation:up .3s ease;}
@keyframes up{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
.user{align-self:flex-end;background:rgba(255,255,255,0.08);border:1px solid var(--border);border-radius:14px 14px 2px 14px;}
.ai{align-self:flex-start;background:rgba(255,255,255,0.04);border:1px solid var(--border);border-radius:14px 14px 14px 2px;}
.typing{display:flex;gap:5px;padding:12px 16px;}
.dot{width:6px;height:6px;background:var(--cyan);border-radius:50%;animation:b 1.2s infinite;}
.dot:nth-child(2){animation-delay:.2s}.dot:nth-child(3){animation-delay:.4s}
@keyframes b{0%,100%{transform:translateY(0)}50%{transform:translateY(-8px)}}
.input-area{padding:14px 20px;}
.wrap{position:relative;padding:1.5px;border-radius:22px;overflow:hidden;background:#111;}
.wrap::before{content:'';position:absolute;width:200%;height:200%;top:-50%;left:-50%;background:conic-gradient(var(--blue),var(--cyan),transparent 60%);animation:rot 6s linear infinite;}
@keyframes rot{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}
.inner{position:relative;z-index:2;background:#0c0c0e;border-radius:21px;padding:11px 14px;display:flex;align-items:center;gap:10px;}
.inner input{flex:1;background:transparent;border:none;color:#fff;font-size:0.92rem;outline:none;font-family:'Inter',sans-serif;}
.inner input::placeholder{color:rgba(255,255,255,0.25);}
.sbtn{position:relative;width:110px;height:40px;border-radius:12px;overflow:hidden;padding:1.5px;background:var(--blue);}
.sbtn::before{content:'';position:absolute;width:250%;height:250%;background:conic-gradient(var(--blue),var(--cyan),transparent 30%,var(--blue),var(--cyan),transparent 70%);animation:rot 2.5s linear infinite;}
.sbtn button{position:relative;z-index:2;width:100%;height:100%;border:none;border-radius:11px;background:linear-gradient(180deg,#1e1e20,#0c0c0e);color:#fff;font-weight:700;font-size:0.78rem;letter-spacing:.5px;cursor:pointer;text-transform:uppercase;}
</style>
</head>
<body>
<header>
<div class="sq"></div>
<span class="logo">SOLIFON AI</span>
<span class="badge">📴 OFFLINE</span>
</header>
<div class="chat" id="chat">
<div class="welcome" id="welcome">
<svg viewBox="0 0 200 200" fill="none">
<path d="M100 10L115 75L180 75L130 115L150 180L100 145L50 180L70 115L20 75L85 75Z" stroke="white" stroke-width="3" stroke-linejoin="round" opacity="0.25"/>
<path d="M100 10L115 75L180 75L130 115L150 180L100 145L50 180L70 115L20 75L85 75Z" stroke="#0044ff" stroke-width="2.5" stroke-linejoin="round" stroke-dasharray="50 150">
<animate attributeName="stroke-dashoffset" from="400" to="0" dur="4s" repeatCount="indefinite"/>
</path>
<path d="M100 10L115 75L180 75L130 115L150 180L100 145L50 180L70 115L20 75L85 75Z" stroke="#00d4ff" stroke-width="2" stroke-linejoin="round" stroke-dasharray="35 165">
<animate attributeName="stroke-dashoffset" from="0" to="400" dur="4s" repeatCount="indefinite"/>
</path>
</svg>
<h2>SOLIFON AI</h2>
<p>Gemma 3 · Offline · Без интернета</p>
<small>© 2026 Томанбаев Дастан</small>
</div>
</div>
<div class="input-area">
<div class="wrap"><div class="inner">
<input id="inp" placeholder="Напиши что-нибудь..." onkeydown="if(event.key==='Enter')send()">
<div class="sbtn"><button onclick="send()">Send →</button></div>
</div></div>
</div>
<script>
const chat=document.getElementById('chat'),inp=document.getElementById('inp');
const welcome=document.getElementById('welcome');
const history=[];
function add(text,role){
welcome.style.display='none';
const d=document.createElement('div');
d.className='msg '+role;
d.textContent=text;
chat.appendChild(d);
chat.scrollTop=chat.scrollHeight;
}
function typing(){
const d=document.createElement('div');
d.className='msg ai typing';
d.innerHTML='<div class="dot"></div><div class="dot"></div><div class="dot"></div>';
chat.appendChild(d);
chat.scrollTop=chat.scrollHeight;
return d;
}
async function send(){
const t=inp.value.trim();
if(!t)return;
inp.value='';
add(t,'user');
history.push({role:'user',content:t});
const ty=typing();
try{
const r=await fetch('/api/chat',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({messages:history})});
const d=await r.json();
ty.remove();
add(d.reply||'...','ai');
history.push({role:'assistant',content:d.reply});
}catch(e){ty.remove();add('Ошибка: '+e.message,'ai');}
}
</script>
</body>
</html>"""
class Handler(BaseHTTPRequestHandler):
def log_message(self,*a): pass
def do_GET(self):
self.send_response(200)
self.send_header("Content-type","text/html; charset=utf-8")
self.end_headers()
self.wfile.write(HTML.encode())
def do_POST(self):
if self.path!="/api/chat":
self.send_error(404); return
data=json.loads(self.rfile.read(int(self.headers["Content-Length"])))
msgs=data.get("messages",[])
prompt="<start_of_turn>user\nТы Solifon AI — офлайн-ассистент. Отвечай на языке пользователя (казахский/русский/английский).\n\n"
for m in msgs:
if m["role"]=="user":
prompt+=f"{m['content']}<end_of_turn>\n<start_of_turn>model\n"
else:
prompt+=f"{m['content']}<end_of_turn>\n<start_of_turn>user\n"
out=llm(prompt,max_tokens=1024,temperature=0.7,stop=["<end_of_turn>","<start_of_turn>"])
reply=out["choices"][0]["text"].strip()
self.send_response(200)
self.send_header("Content-type","application/json")
self.send_header("Access-Control-Allow-Origin","*")
self.end_headers()
self.wfile.write(json.dumps({"reply":reply}).encode())
threading.Thread(target=lambda:(time.sleep(1.5),webbrowser.open("http://localhost:7860")),daemon=True).start()
print("🌐 Solifon AI запущен: http://localhost:7860")
print(" Ctrl+C — остановить\n")
try:
HTTPServer(("",7860),Handler).serve_forever()
except KeyboardInterrupt:
print("\n👋 Остановлен")