Text Generation
Transformers
Safetensors
GGUF
English
code
code-generation
multimodal
llama
conversational
Instructions to use mrsandip/Alfa-Code with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mrsandip/Alfa-Code with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mrsandip/Alfa-Code")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("mrsandip/Alfa-Code", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use mrsandip/Alfa-Code with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf mrsandip/Alfa-Code:Q4_0 # Run inference directly in the terminal: llama cli -hf mrsandip/Alfa-Code:Q4_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf mrsandip/Alfa-Code:Q4_0 # Run inference directly in the terminal: llama cli -hf mrsandip/Alfa-Code:Q4_0
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf mrsandip/Alfa-Code:Q4_0 # Run inference directly in the terminal: ./build/bin/llama cli -hf mrsandip/Alfa-Code:Q4_0
Use Docker
docker model run hf.co/mrsandip/Alfa-Code:Q4_0
- Llama new
- LM Studio
- Jan
- vLLM
How to use mrsandip/Alfa-Code with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mrsandip/Alfa-Code" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mrsandip/Alfa-Code", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mrsandip/Alfa-Code:Q4_0
- SGLang
How to use mrsandip/Alfa-Code with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "mrsandip/Alfa-Code" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mrsandip/Alfa-Code", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "mrsandip/Alfa-Code" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mrsandip/Alfa-Code", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use mrsandip/Alfa-Code with Ollama:
ollama run hf.co/mrsandip/Alfa-Code:Q4_0
- Unsloth Desktop
- Docker Model Runner
How to use mrsandip/Alfa-Code with Docker Model Runner:
docker model run hf.co/mrsandip/Alfa-Code:Q4_0
- Lemonade
How to use mrsandip/Alfa-Code with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull mrsandip/Alfa-Code:Q4_0
Run and chat with the model
lemonade run user.Alfa-Code-Q4_0
List all available models
lemonade list
- Atomic Chat
Enhance chat window UI
Browse files
app/ui.py
CHANGED
|
@@ -1,37 +1,70 @@
|
|
| 1 |
-
"""
|
| 2 |
-
import time
|
| 3 |
from pathlib import Path
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
ctx = []
|
| 8 |
-
if image: ctx.append(f"
|
| 9 |
-
if file:
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
yield
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
with gr.Row():
|
| 24 |
-
with gr.Column(scale=
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
with gr.Row():
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
vid = gr.Video(label="Video")
|
| 31 |
-
btn = gr.Button("Generate", variant="primary")
|
| 32 |
with gr.Column(scale=1):
|
| 33 |
-
status = gr.Label(value="Idle", label="Reasoning
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
if __name__ == "__main__":
|
| 37 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Alfa-Code chat window: ChatGPT-like + reasoning + image/file/video."""
|
| 2 |
+
import time
|
| 3 |
from pathlib import Path
|
| 4 |
+
import gradio as gr
|
| 5 |
|
| 6 |
+
CSS = """
|
| 7 |
+
#chatbot {height: 55vh !important;}
|
| 8 |
+
.message {font-size: 15px;}
|
| 9 |
+
#send {background: #ff6a00 !important; color: white !important;}
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
def stream_reply(message, history, image, file, video):
|
| 13 |
ctx = []
|
| 14 |
+
if image: ctx.append(f"🖼️ {Path(image).name}")
|
| 15 |
+
if file:
|
| 16 |
+
fp = file if isinstance(file, str) else getattr(file, "name", "file")
|
| 17 |
+
ctx.append(f"📄 {Path(fp).name}")
|
| 18 |
+
if video: ctx.append(f"🎬 {Path(video).name} (frames extracted)")
|
| 19 |
+
prefix = (" ".join(ctx) + "\n\n" if ctx else "")
|
| 20 |
+
|
| 21 |
+
history = history + [
|
| 22 |
+
{"role": "user", "content": prefix + (message or "(attachment only)")},
|
| 23 |
+
{"role": "assistant", "content": "⏳ *Thinking...*"},
|
| 24 |
+
]
|
| 25 |
+
yield history, "⏳ Thinking..."
|
| 26 |
+
time.sleep(0.5)
|
| 27 |
+
|
| 28 |
+
history[-1]["content"] = "🧠 *Planning...*\n- parse request\n- check attachments\n- generate code"
|
| 29 |
+
yield history, "🧠 Planning..."
|
| 30 |
+
time.sleep(0.5)
|
| 31 |
|
| 32 |
+
code = f"```python\n# task: {(message or 'multimodal')[:80]}\ndef solve():\n # TODO: wire outputs/tiny-50M.gguf\n return 'done'\n```"
|
| 33 |
+
final = (
|
| 34 |
+
"<details open><summary><b>Reasoning (3 steps)</b></summary>\n"
|
| 35 |
+
"1. Understand request + attachments<br>2. Plan: parse → generate → verify<br>"
|
| 36 |
+
"3. Code + self-check</details>\n\n" + prefix + code
|
| 37 |
+
)
|
| 38 |
+
history[-1]["content"] = final
|
| 39 |
+
yield history, "✅ Done"
|
| 40 |
+
return history, "✅ Done"
|
| 41 |
+
|
| 42 |
+
with gr.Blocks(title="Alfa-Code", css=CSS, theme=gr.themes.Soft()) as demo:
|
| 43 |
+
gr.Markdown("# 💬 Alfa-Code\n*Coding AI — reasoning + image + file + video*")
|
| 44 |
with gr.Row():
|
| 45 |
+
with gr.Column(scale=3):
|
| 46 |
+
chatbot = gr.Chatbot(label="Chat", elem_id="chatbot", type="messages", show_copy_button=True)
|
| 47 |
+
with gr.Row():
|
| 48 |
+
msg = gr.Textbox(placeholder="Ask to code... (Enter to send)", show_label=False, scale=4)
|
| 49 |
+
send = gr.Button("Send ➤", elem_id="send", scale=1)
|
| 50 |
+
with gr.Accordion("📎 Attachments", open=True):
|
| 51 |
+
with gr.Row():
|
| 52 |
+
img = gr.Image(label="Image", type="filepath")
|
| 53 |
+
fil = gr.File(label="File")
|
| 54 |
+
vid = gr.Video(label="Video")
|
| 55 |
with gr.Row():
|
| 56 |
+
clear = gr.ClearButton([msg, chatbot])
|
| 57 |
+
retry = gr.Button("↻ Retry")
|
|
|
|
|
|
|
| 58 |
with gr.Column(scale=1):
|
| 59 |
+
status = gr.Label(value="Idle", label="Reasoning")
|
| 60 |
+
gr.Examples(
|
| 61 |
+
["Write python quicksort", "Fix this CSS flex bug", "Explain this traceback"],
|
| 62 |
+
inputs=msg, label="Try",
|
| 63 |
+
)
|
| 64 |
+
msg.submit(stream_reply, [msg, chatbot, img, fil, vid], [chatbot, status]).then(lambda: "", None, msg)
|
| 65 |
+
send.click(stream_reply, [msg, chatbot, img, fil, vid], [chatbot, status]).then(lambda: "", None, msg)
|
| 66 |
|
| 67 |
if __name__ == "__main__":
|
| 68 |
+
import sys
|
| 69 |
+
port = int(sys.argv[1]) if len(sys.argv) > 1 else 7861
|
| 70 |
+
demo.launch(server_name="127.0.0.1", server_port=port)
|