File size: 1,447 Bytes
80174d0
 
 
 
 
 
0d234e9
 
80174d0
0d234e9
 
 
 
 
 
 
 
80174d0
 
0d234e9
80174d0
366ac6c
 
80174d0
 
0d234e9
 
80174d0
0d234e9
 
366ac6c
80174d0
0d234e9
76a525b
0d234e9
 
76a525b
366ac6c
76a525b
366ac6c
76a525b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Raller Magnium AI - Powered by raller.pro
# Copyright (C) 2026
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License v3.

import gradio as gr
from huggingface_hub import hf_hub_download
from llama_cpp import Llama

# 1. Download the ultra-fast CPU version of SmolLM 1.7B (GGUF format)
model_path = hf_hub_download(
    repo_id="second-state/SmolLM-1.7B-Instruct-GGUF",
    filename="SmolLM-1.7B-Instruct-Q4_K_M.gguf"
)

# 2. Boot up the high-speed CPU inference engine
llm = Llama(model_path=model_path, n_ctx=2048, n_threads=2)

def chat_respond(message, history):
    # Format a fast prompt string for the engine
    prompt = ""
    for user_msg, ai_msg in history:
        prompt += f"User: {user_msg}\nAssistant: {ai_msg}\n"
    prompt += f"User: {message}\nAssistant:"
    
    # Generate tokens instantly using your free CPU cores
    output = llm(prompt, max_tokens=120, temperature=0.7, stop=["User:"])
    
    # Clean up and extract the text
    response = output["choices"][0]["text"].strip()
    return response

# Build the layout block
with gr.Blocks() as demo:
    gr.Markdown("# 🐨 Raller Magnium AI (High-Speed Engine)")
    gr.Markdown("Optimized for lightning-fast responses on free cloud hardware. Powered by raller.pro.")
    
    gr.ChatInterface(fn=chat_respond)

# Launch with the soft UI theme cleanly applied
demo.launch(theme=gr.themes.Soft())