File size: 3,567 Bytes
6188f40
403c4ee
6188f40
403c4ee
 
6188f40
403c4ee
 
6188f40
403c4ee
 
0b280d8
403c4ee
 
 
 
 
 
0b280d8
403c4ee
 
 
 
 
 
 
 
0b280d8
403c4ee
 
 
 
 
 
 
 
 
 
 
0b280d8
403c4ee
 
0b280d8
403c4ee
 
0b280d8
403c4ee
dd690d7
403c4ee
dd690d7
403c4ee
dd690d7
403c4ee
 
0b280d8
dd690d7
0b280d8
dd690d7
403c4ee
 
 
 
dd690d7
 
403c4ee
dd690d7
 
 
403c4ee
0b280d8
dd690d7
0b280d8
 
 
 
dd690d7
403c4ee
0b280d8
403c4ee
 
 
 
 
dd690d7
 
0b280d8
403c4ee
 
 
0b280d8
403c4ee
0b280d8
403c4ee
 
 
 
 
0b280d8
403c4ee
0b280d8
 
 
 
 
dd690d7
 
 
 
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import gradio as gr
import os

# HF Serverless Inference API - free tier, built into Spaces
from huggingface_hub import InferenceClient

# Free model accessible via HF serverless
MODEL = "Qwen/Qwen2.5-7B-Instruct"

with open("SOUL.md") as f:
    SOUL_TEMPLATE = f.read()

def compare(prompt):
    if not prompt.strip():
        return "Enter a prompt.", "", ""
    
    try:
        client = InferenceClient(token=os.environ.get("HF_TOKEN", None))
        
        # Raw response - no system prompt
        raw = client.chat.completions.create(
            model=MODEL,
            messages=[{"role": "user", "content": prompt}],
            max_tokens=500,
            temperature=0.7,
        )
        raw_text = raw.choices[0].message.content
        
        # With SOUL injected
        soul = client.chat.completions.create(
            model=MODEL,
            messages=[
                {"role": "system", "content": SOUL_TEMPLATE},
                {"role": "user", "content": prompt}
            ],
            max_tokens=500,
            temperature=0.7,
        )
        soul_text = soul.choices[0].message.content
        
        cost = "Model: Qwen2.5-7B (free) | Same model, same cost β€” different SOUL"
        return raw_text, soul_text, cost
        
    except Exception as e:
        return f"Error: {str(e)[:200]}", "Please try again later.", ""

with gr.Blocks(title="Poor Mans Opus Before After", theme=gr.themes.Soft()) as demo:
    gr.Markdown("""
    # 🦾 Poor Man's Opus β€” Live Comparison
    
    **Our product is the SOUL, not the model.**
    
    Left: raw model output. Right: same model + Poor Man's Opus `::GENE{}` behavioral DNA.
    Running on a **free** model right now. The SOUL works on ANY model.
    """)
    
    gr.Markdown("---")
    
    prompt = gr.Textbox(
        label="Ask anything",
        placeholder="e.g. What are the three biggest mistakes founders make raising Series A?",
        lines=3
    )
    
    btn = gr.Button("Compare", variant="primary", size="lg")
    
    with gr.Row():
        with gr.Column():
            gr.Markdown("### πŸ”΄ Raw (Default Behavior)")
            raw_out = gr.Textbox(label="", lines=18)
        with gr.Column():
            gr.Markdown("### 🟒 Same Model + Poor Man's Opus SOUL")
            soul_out = gr.Textbox(label="", lines=18)
    
    stats = gr.Textbox(label="Details", interactive=False)
    
    btn.click(compare, inputs=prompt, outputs=[raw_out, soul_out, stats])
    
    # Load default example
    demo.load(
        lambda: compare("Explain how LLMs work to a 10-year-old"),
        outputs=[raw_out, soul_out, stats]
    )
    
    gr.Markdown("""
    ---
    ### The SOUL works on any model
    
    This demo runs on **Qwen2.5-7B** β€” a free, open-source model. The same `::GENE{}` DNA changes its behavior immediately.
    
    **For the best results, use a premium reasoning model:**
    
    | Model | Cost (input/output per M tokens) | Verdict |
    |-------|------|---------|
    | DeepSeek V4 Pro | $1.74 / $3.48 | πŸ† Best ROI β€” Opus-level output at 3% cost |
    | DeepSeek V4 Flash | $0.14 / $0.28 | Fast & cheap |
    | Claude Opus 4.6 | $15.00 / $75.00 | Baseline quality (what we compare to) |
    
    **One command:**
    ```bash
    openclaw skills install poor-mans-opus
    ```
    
    [πŸ“¦ GitHub](https://github.com/mtmpss/poor-mans-opus) | [πŸ›’ ClawHub](https://clawhub.ai/mtmpss/poor-mans-opus) | [πŸ€— HF Model](https://huggingface.co/ilanguage/poor-mans-opus)
    """)

if __name__ == "__main__":
    demo.launch()