|
1 | | -"""L2 Epistemic Synthesis Engine: Hegelian Dialectic.""" |
| 1 | +"""Hegelian Synthesis Expert Implementation.""" |
| 2 | + |
| 3 | +from typing import Dict, Any |
| 4 | +from pydantic import BaseModel |
| 5 | + |
| 6 | +from epistemic_forge.experts.base import EpistemicExpert |
2 | 7 | from epistemic_forge.models import ProjectSpec, HegelianDialecticOutput |
3 | 8 | from epistemic_forge.llm import generate_structured |
4 | | -from typing import Dict, Any |
5 | 9 |
|
6 | | -def run_dialectic(spec: ProjectSpec, claims_bundle: Dict[str, Any]) -> Dict[str, Any]: |
7 | | - """Execute Hegelian Synthesis to destroy weak assumptions.""" |
8 | | - thesis = spec.question |
9 | | - |
10 | | - messages = [ |
11 | | - {"role": "system", "content": "You are a ruthless Hegelian philosopher and logician. Your goal is to take a premise, construct the most devastating 'Steelman' antithesis possible, and forge a synthesis that represents the nuanced truth."}, |
12 | | - {"role": "user", "content": f"Core Premise/Thesis: {thesis}\nProject Domain: {spec.domain.value}\nDestroy this premise with logic, then synthesize."} |
13 | | - ] |
14 | | - |
15 | | - # Neuro-Symbolic Call: Forcing GPT to return the strict Hegelian schema |
16 | | - result: HegelianDialecticOutput = generate_structured( |
17 | | - messages=messages, |
18 | | - response_model=HegelianDialecticOutput, |
19 | | - model="gpt-4o-mini" # Cost-aware baseline |
20 | | - ) |
21 | | - |
22 | | - return { |
23 | | - "thesis": thesis, |
24 | | - "antithesis": result.steelmanned_antithesis, |
25 | | - "synthesis": result.synthesis_resolution, |
26 | | - "open_questions": result.remaining_uncertainties, |
27 | | - } |
| 10 | + |
| 11 | +class HegelianExpert(EpistemicExpert): |
| 12 | + """Applies Hegelian dialectic (Thesis -> Antithesis -> Synthesis) to premises.""" |
| 13 | + |
| 14 | + @property |
| 15 | + def expert_name(self) -> str: |
| 16 | + return "Hegelian_Dialectic_Engine" |
| 17 | + |
| 18 | + def analyze( |
| 19 | + self, spec: ProjectSpec, context: Dict[str, Any] |
| 20 | + ) -> HegelianDialecticOutput: |
| 21 | + """Synthesizes the core question by forcing a steelmanned antithesis.""" |
| 22 | + messages = [ |
| 23 | + { |
| 24 | + "role": "system", |
| 25 | + "content": ( |
| 26 | + "You are a ruthless Hegelian philosopher. Take the user's premise, " |
| 27 | + "construct the most devastating 'Steelman' antithesis possible, " |
| 28 | + "and forge a synthesis that represents the nuanced truth." |
| 29 | + ), |
| 30 | + }, |
| 31 | + { |
| 32 | + "role": "user", |
| 33 | + "content": f"Core Thesis: {spec.question}\nDomain: {spec.domain}\nDestroy and synthesize.", |
| 34 | + }, |
| 35 | + ] |
| 36 | + |
| 37 | + # The universal Hermes router handles the LLM complexity internally |
| 38 | + return generate_structured( |
| 39 | + messages=messages, |
| 40 | + response_model=HegelianDialecticOutput, |
| 41 | + model=spec.target_model, |
| 42 | + api_base=spec.api_base, |
| 43 | + ) |
0 commit comments