File size: 2,928 Bytes
05caadb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from openai import OpenAI

# Modal endpoint — keep deployed: modal deploy philosopher_modal.py
MODAL_URL = "https://mark-gentry--qwen3-philosopher-serve.modal.run/v1"
MODEL_ID  = "qwen3-philosopher"

client = OpenAI(base_url=MODAL_URL, api_key="unused")

SYSTEM_PROMPT = (
    "You are a philosopher trained to reason carefully and rigorously. "
    "When given a question or position, construct a structured argument — "
    "identify the key claims, examine the assumptions, consider serious objections, "
    "and defend or revise your position in light of them. "
    "Do not merely summarise what philosophers have said. Reason."
)

def chat(message, history):
    messages = [{"role": "system", "content": SYSTEM_PROMPT}]
    for human, assistant in history:
        messages.append({"role": "user",      "content": human})
        messages.append({"role": "assistant", "content": assistant})
    messages.append({"role": "user", "content": message})

    response = ""
    try:
        stream = client.chat.completions.create(
            model=MODEL_ID,
            messages=messages,
            max_tokens=1500,
            temperature=0.7,
            stream=True,
        )
        for chunk in stream:
            delta = chunk.choices[0].delta.content or ""
            response += delta
            yield response
    except Exception as e:
        yield f"Model unavailable — the philosopher is thinking elsewhere. ({e})"


with gr.Blocks(
    theme=gr.themes.Base(
        primary_hue="indigo",
        font=[gr.themes.GoogleFont("Georgia"), "serif"],
    ),
    title="The Philosopher — TunedAI Labs",
    css="""
        .gradio-container { max-width: 800px; margin: auto; }
        .chat-message { font-size: 15px; line-height: 1.7; }
        footer { display: none; }
    """
) as demo:

    gr.Markdown("""
# The Philosopher

A 27B model fine-tuned to reason philosophically — not retrieve positions.
Ask it anything in philosophy of mind, ethics, metaphysics, or epistemology.
It will construct an argument, not a summary.

*Built on Qwen3.6-27B · DPO fine-tuned · [TunedAI Labs](https://tunedailabs.com)*
    """)

    chatbot = gr.ChatInterface(
        fn=chat,
        chatbot=gr.Chatbot(height=500, elem_classes=["chat-message"]),
        textbox=gr.Textbox(
            placeholder="Ask a philosophical question or state a position to argue against...",
            container=False,
        ),
        examples=[
            "Is consciousness reducible to physical processes?",
            "Does personal identity persist through radical change?",
            "Can free will exist in a deterministic universe?",
            "What is the strongest argument against moral realism?",
            "Argue against Chalmers' hard problem of consciousness.",
        ],
        retry_btn=None,
        undo_btn="↩ Undo",
        clear_btn="✕ Clear",
    )

demo.launch()