Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -90,7 +90,8 @@ init_whisper()
|
|
| 90 |
def get_status():
|
| 91 |
available = [name for name, file in MODELS.items() if os.path.exists(os.path.join(MODELS_DIR, file))]
|
| 92 |
if current_model_name:
|
| 93 |
-
|
|
|
|
| 94 |
return f"🟡 {len(available)} models available"
|
| 95 |
|
| 96 |
def get_model_info(model_name):
|
|
@@ -120,7 +121,6 @@ def generate_response(model_name, prompt, temperature=0.7, max_tokens=2048):
|
|
| 120 |
return "❌ **Model not available.** Check if downloaded."
|
| 121 |
|
| 122 |
try:
|
| 123 |
-
# Qwen2.5 chat format
|
| 124 |
formatted = f"<|im_start|>system\nYou are an expert coding assistant.<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n"
|
| 125 |
|
| 126 |
output = llm(
|
|
@@ -166,7 +166,6 @@ def chat_stream(message, history, model_name, temperature, max_tokens):
|
|
| 166 |
yield history + [[message, "❌ Model not available."]]
|
| 167 |
return
|
| 168 |
|
| 169 |
-
# Build conversation
|
| 170 |
conv = "<|im_start|>system\nYou are an expert coding assistant. Use markdown code blocks.<|im_end|>\n"
|
| 171 |
for u, a in history:
|
| 172 |
conv += f"<|im_start|>user\n{u}<|im_end|>\n"
|
|
@@ -401,7 +400,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 401 |
gr.HTML("""
|
| 402 |
<div style="background: linear-gradient(135deg, #6366f1, #8b5cf6, #06b6d4); border-radius: 16px; padding: 24px; margin-bottom: 16px;">
|
| 403 |
<h1 style="color: white; margin: 0; font-size: 2rem;">🔥 Axon v6</h1>
|
| 404 |
-
<p style="color: rgba(255,255,255,0.9); margin: 4px 0 0 0;">llama.cpp Edition • 19 Tools •
|
| 405 |
<div style="display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap;">
|
| 406 |
<span style="background: rgba(255,255,255,0.2); padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; color: white;">🤖 3 Models</span>
|
| 407 |
<span style="background: rgba(255,255,255,0.2); padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; color: white;">🛠️ 19 Tools</span>
|
|
@@ -423,6 +422,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 423 |
|
| 424 |
with gr.Tabs():
|
| 425 |
|
|
|
|
| 426 |
with gr.TabItem("💬 Chat"):
|
| 427 |
chatbot = gr.Chatbot(height=400)
|
| 428 |
with gr.Row():
|
|
@@ -433,6 +433,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 433 |
transcribe = gr.Button("🎤 Transcribe", scale=1)
|
| 434 |
clear = gr.Button("🗑️ Clear", scale=1)
|
| 435 |
|
|
|
|
| 436 |
with gr.TabItem("⚡ Generate"):
|
| 437 |
with gr.Row():
|
| 438 |
with gr.Column():
|
|
@@ -444,6 +445,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 444 |
with gr.Column():
|
| 445 |
gen_output = gr.Code(label="Code", language="python", lines=14)
|
| 446 |
|
|
|
|
| 447 |
with gr.TabItem("🔍 Explain"):
|
| 448 |
with gr.Row():
|
| 449 |
with gr.Column():
|
|
@@ -453,6 +455,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 453 |
with gr.Column():
|
| 454 |
explain_output = gr.Markdown()
|
| 455 |
|
|
|
|
| 456 |
with gr.TabItem("🔧 Debug"):
|
| 457 |
with gr.Row():
|
| 458 |
with gr.Column():
|
|
@@ -462,6 +465,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 462 |
with gr.Column():
|
| 463 |
fix_output = gr.Markdown()
|
| 464 |
|
|
|
|
| 465 |
with gr.TabItem("📋 Review"):
|
| 466 |
with gr.Row():
|
| 467 |
with gr.Column():
|
|
@@ -470,6 +474,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 470 |
with gr.Column():
|
| 471 |
review_output = gr.Markdown()
|
| 472 |
|
|
|
|
| 473 |
with gr.TabItem("🔐 Security"):
|
| 474 |
with gr.Row():
|
| 475 |
with gr.Column():
|
|
@@ -478,6 +483,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 478 |
with gr.Column():
|
| 479 |
security_output = gr.Markdown()
|
| 480 |
|
|
|
|
| 481 |
with gr.TabItem("📊 Complexity"):
|
| 482 |
with gr.Row():
|
| 483 |
with gr.Column():
|
|
@@ -486,6 +492,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 486 |
with gr.Column():
|
| 487 |
complexity_output = gr.Markdown()
|
| 488 |
|
|
|
|
| 489 |
with gr.TabItem("🔄 Convert"):
|
| 490 |
with gr.Row():
|
| 491 |
with gr.Column():
|
|
@@ -497,6 +504,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 497 |
with gr.Column():
|
| 498 |
convert_output = gr.Code(label="Result", lines=10)
|
| 499 |
|
|
|
|
| 500 |
with gr.TabItem("🧪 Test"):
|
| 501 |
with gr.Row():
|
| 502 |
with gr.Column():
|
|
@@ -508,6 +516,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 508 |
with gr.Column():
|
| 509 |
test_output = gr.Code(label="Tests", lines=10)
|
| 510 |
|
|
|
|
| 511 |
with gr.TabItem("📝 Document"):
|
| 512 |
with gr.Row():
|
| 513 |
with gr.Column():
|
|
@@ -519,6 +528,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 519 |
with gr.Column():
|
| 520 |
doc_output = gr.Code(label="Documented", lines=10)
|
| 521 |
|
|
|
|
| 522 |
with gr.TabItem("🚀 Optimize"):
|
| 523 |
with gr.Row():
|
| 524 |
with gr.Column():
|
|
@@ -530,6 +540,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 530 |
with gr.Column():
|
| 531 |
opt_output = gr.Markdown()
|
| 532 |
|
|
|
|
| 533 |
with gr.TabItem("🔀 Diff"):
|
| 534 |
with gr.Row():
|
| 535 |
with gr.Column():
|
|
@@ -539,6 +550,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 539 |
with gr.Column():
|
| 540 |
diff_output = gr.Markdown()
|
| 541 |
|
|
|
|
| 542 |
with gr.TabItem("📐 Pseudo"):
|
| 543 |
with gr.Row():
|
| 544 |
with gr.Column():
|
|
@@ -548,6 +560,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 548 |
with gr.Column():
|
| 549 |
pseudo_output = gr.Markdown()
|
| 550 |
|
|
|
|
| 551 |
with gr.TabItem("🎓 Interview"):
|
| 552 |
with gr.Row():
|
| 553 |
with gr.Column():
|
|
@@ -559,6 +572,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 559 |
with gr.Column():
|
| 560 |
interview_output = gr.Markdown()
|
| 561 |
|
|
|
|
| 562 |
with gr.TabItem("🛠️ Builders"):
|
| 563 |
gr.Markdown("### 🗄️ SQL")
|
| 564 |
with gr.Row():
|
|
@@ -567,7 +581,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 567 |
sql_type = gr.Dropdown(["PostgreSQL", "MySQL", "SQLite"], value="PostgreSQL")
|
| 568 |
sql_btn = gr.Button("🗄️ Build", variant="primary")
|
| 569 |
with gr.Column():
|
| 570 |
-
sql_output = gr.Code(
|
| 571 |
|
| 572 |
gr.Markdown("---\n### 🐚 Shell")
|
| 573 |
with gr.Row():
|
|
@@ -576,7 +590,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 576 |
shell_type = gr.Dropdown(["Bash", "PowerShell", "Zsh"], value="Bash")
|
| 577 |
shell_btn = gr.Button("🐚 Build", variant="primary")
|
| 578 |
with gr.Column():
|
| 579 |
-
shell_output = gr.Code(
|
| 580 |
|
| 581 |
gr.Markdown("---\n### ⏰ Cron")
|
| 582 |
with gr.Row():
|
|
@@ -603,6 +617,7 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 603 |
with gr.Column():
|
| 604 |
api_output = gr.Code(lines=8)
|
| 605 |
|
|
|
|
| 606 |
with gr.TabItem("📦 Data"):
|
| 607 |
gr.Markdown("### 📦 Mock Data")
|
| 608 |
with gr.Row():
|
|
@@ -626,7 +641,11 @@ with gr.Blocks(title="Axon v6") as demo:
|
|
| 626 |
with gr.Column():
|
| 627 |
format_output = gr.Code(label="Output", lines=6)
|
| 628 |
|
| 629 |
-
gr.HTML(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 630 |
|
| 631 |
# ===== EVENTS =====
|
| 632 |
def respond(message, history, model, temp, tokens):
|
|
|
|
| 90 |
def get_status():
|
| 91 |
available = [name for name, file in MODELS.items() if os.path.exists(os.path.join(MODELS_DIR, file))]
|
| 92 |
if current_model_name:
|
| 93 |
+
short_name = current_model_name.split()[1] if len(current_model_name.split()) > 1 else current_model_name
|
| 94 |
+
return f"🟢 Ready • {len(available)} models • Active: {short_name}"
|
| 95 |
return f"🟡 {len(available)} models available"
|
| 96 |
|
| 97 |
def get_model_info(model_name):
|
|
|
|
| 121 |
return "❌ **Model not available.** Check if downloaded."
|
| 122 |
|
| 123 |
try:
|
|
|
|
| 124 |
formatted = f"<|im_start|>system\nYou are an expert coding assistant.<|im_end|>\n<|im_start|>user\n{prompt}<|im_end|>\n<|im_start|>assistant\n"
|
| 125 |
|
| 126 |
output = llm(
|
|
|
|
| 166 |
yield history + [[message, "❌ Model not available."]]
|
| 167 |
return
|
| 168 |
|
|
|
|
| 169 |
conv = "<|im_start|>system\nYou are an expert coding assistant. Use markdown code blocks.<|im_end|>\n"
|
| 170 |
for u, a in history:
|
| 171 |
conv += f"<|im_start|>user\n{u}<|im_end|>\n"
|
|
|
|
| 400 |
gr.HTML("""
|
| 401 |
<div style="background: linear-gradient(135deg, #6366f1, #8b5cf6, #06b6d4); border-radius: 16px; padding: 24px; margin-bottom: 16px;">
|
| 402 |
<h1 style="color: white; margin: 0; font-size: 2rem;">🔥 Axon v6</h1>
|
| 403 |
+
<p style="color: rgba(255,255,255,0.9); margin: 4px 0 0 0;">llama.cpp Edition • 19 Tools • Community Wheels! 🛞</p>
|
| 404 |
<div style="display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap;">
|
| 405 |
<span style="background: rgba(255,255,255,0.2); padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; color: white;">🤖 3 Models</span>
|
| 406 |
<span style="background: rgba(255,255,255,0.2); padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; color: white;">🛠️ 19 Tools</span>
|
|
|
|
| 422 |
|
| 423 |
with gr.Tabs():
|
| 424 |
|
| 425 |
+
# Chat
|
| 426 |
with gr.TabItem("💬 Chat"):
|
| 427 |
chatbot = gr.Chatbot(height=400)
|
| 428 |
with gr.Row():
|
|
|
|
| 433 |
transcribe = gr.Button("🎤 Transcribe", scale=1)
|
| 434 |
clear = gr.Button("🗑️ Clear", scale=1)
|
| 435 |
|
| 436 |
+
# Generate
|
| 437 |
with gr.TabItem("⚡ Generate"):
|
| 438 |
with gr.Row():
|
| 439 |
with gr.Column():
|
|
|
|
| 445 |
with gr.Column():
|
| 446 |
gen_output = gr.Code(label="Code", language="python", lines=14)
|
| 447 |
|
| 448 |
+
# Explain
|
| 449 |
with gr.TabItem("🔍 Explain"):
|
| 450 |
with gr.Row():
|
| 451 |
with gr.Column():
|
|
|
|
| 455 |
with gr.Column():
|
| 456 |
explain_output = gr.Markdown()
|
| 457 |
|
| 458 |
+
# Debug
|
| 459 |
with gr.TabItem("🔧 Debug"):
|
| 460 |
with gr.Row():
|
| 461 |
with gr.Column():
|
|
|
|
| 465 |
with gr.Column():
|
| 466 |
fix_output = gr.Markdown()
|
| 467 |
|
| 468 |
+
# Review
|
| 469 |
with gr.TabItem("📋 Review"):
|
| 470 |
with gr.Row():
|
| 471 |
with gr.Column():
|
|
|
|
| 474 |
with gr.Column():
|
| 475 |
review_output = gr.Markdown()
|
| 476 |
|
| 477 |
+
# Security
|
| 478 |
with gr.TabItem("🔐 Security"):
|
| 479 |
with gr.Row():
|
| 480 |
with gr.Column():
|
|
|
|
| 483 |
with gr.Column():
|
| 484 |
security_output = gr.Markdown()
|
| 485 |
|
| 486 |
+
# Complexity
|
| 487 |
with gr.TabItem("📊 Complexity"):
|
| 488 |
with gr.Row():
|
| 489 |
with gr.Column():
|
|
|
|
| 492 |
with gr.Column():
|
| 493 |
complexity_output = gr.Markdown()
|
| 494 |
|
| 495 |
+
# Convert
|
| 496 |
with gr.TabItem("🔄 Convert"):
|
| 497 |
with gr.Row():
|
| 498 |
with gr.Column():
|
|
|
|
| 504 |
with gr.Column():
|
| 505 |
convert_output = gr.Code(label="Result", lines=10)
|
| 506 |
|
| 507 |
+
# Test
|
| 508 |
with gr.TabItem("🧪 Test"):
|
| 509 |
with gr.Row():
|
| 510 |
with gr.Column():
|
|
|
|
| 516 |
with gr.Column():
|
| 517 |
test_output = gr.Code(label="Tests", lines=10)
|
| 518 |
|
| 519 |
+
# Document
|
| 520 |
with gr.TabItem("📝 Document"):
|
| 521 |
with gr.Row():
|
| 522 |
with gr.Column():
|
|
|
|
| 528 |
with gr.Column():
|
| 529 |
doc_output = gr.Code(label="Documented", lines=10)
|
| 530 |
|
| 531 |
+
# Optimize
|
| 532 |
with gr.TabItem("🚀 Optimize"):
|
| 533 |
with gr.Row():
|
| 534 |
with gr.Column():
|
|
|
|
| 540 |
with gr.Column():
|
| 541 |
opt_output = gr.Markdown()
|
| 542 |
|
| 543 |
+
# Diff
|
| 544 |
with gr.TabItem("🔀 Diff"):
|
| 545 |
with gr.Row():
|
| 546 |
with gr.Column():
|
|
|
|
| 550 |
with gr.Column():
|
| 551 |
diff_output = gr.Markdown()
|
| 552 |
|
| 553 |
+
# Pseudocode
|
| 554 |
with gr.TabItem("📐 Pseudo"):
|
| 555 |
with gr.Row():
|
| 556 |
with gr.Column():
|
|
|
|
| 560 |
with gr.Column():
|
| 561 |
pseudo_output = gr.Markdown()
|
| 562 |
|
| 563 |
+
# Interview
|
| 564 |
with gr.TabItem("🎓 Interview"):
|
| 565 |
with gr.Row():
|
| 566 |
with gr.Column():
|
|
|
|
| 572 |
with gr.Column():
|
| 573 |
interview_output = gr.Markdown()
|
| 574 |
|
| 575 |
+
# Builders
|
| 576 |
with gr.TabItem("🛠️ Builders"):
|
| 577 |
gr.Markdown("### 🗄️ SQL")
|
| 578 |
with gr.Row():
|
|
|
|
| 581 |
sql_type = gr.Dropdown(["PostgreSQL", "MySQL", "SQLite"], value="PostgreSQL")
|
| 582 |
sql_btn = gr.Button("🗄️ Build", variant="primary")
|
| 583 |
with gr.Column():
|
| 584 |
+
sql_output = gr.Code(lines=6)
|
| 585 |
|
| 586 |
gr.Markdown("---\n### 🐚 Shell")
|
| 587 |
with gr.Row():
|
|
|
|
| 590 |
shell_type = gr.Dropdown(["Bash", "PowerShell", "Zsh"], value="Bash")
|
| 591 |
shell_btn = gr.Button("🐚 Build", variant="primary")
|
| 592 |
with gr.Column():
|
| 593 |
+
shell_output = gr.Code(lines=6)
|
| 594 |
|
| 595 |
gr.Markdown("---\n### ⏰ Cron")
|
| 596 |
with gr.Row():
|
|
|
|
| 617 |
with gr.Column():
|
| 618 |
api_output = gr.Code(lines=8)
|
| 619 |
|
| 620 |
+
# Data
|
| 621 |
with gr.TabItem("📦 Data"):
|
| 622 |
gr.Markdown("### 📦 Mock Data")
|
| 623 |
with gr.Row():
|
|
|
|
| 641 |
with gr.Column():
|
| 642 |
format_output = gr.Code(label="Output", lines=6)
|
| 643 |
|
| 644 |
+
gr.HTML("""
|
| 645 |
+
<div style="text-align:center;padding:16px;opacity:0.6;">
|
| 646 |
+
🔥 Axon v6 llama.cpp • Wheels: <a href="https://huggingface.co/datasets/AIencoder/llama-cpp-wheels" target="_blank" style="color:#8b5cf6;">AIencoder/llama-cpp-wheels</a>
|
| 647 |
+
</div>
|
| 648 |
+
""")
|
| 649 |
|
| 650 |
# ===== EVENTS =====
|
| 651 |
def respond(message, history, model, temp, tokens):
|