Spaces:
Sleeping
Sleeping
| 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() | |