Skip to content

Commit a754767

Browse files
committed
�[?25hback to previous enginge logic, all test passed
1 parent 515f697 commit a754767

2 files changed

Lines changed: 38 additions & 23 deletions

File tree

src/model_engine.py

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -118,28 +118,43 @@ def process_resource(self, resource: UniversalResource, on_token=None) -> str:
118118

119119
def _build_system_prompt(self, raw_content: str, is_image: bool = False) -> str:
120120
"""
121-
Constructs a concise Knowledge Architect prompt for S T A R R Y N O T E v2.0.
122-
Optimized to minimize input tokens while preserving output quality.
121+
Constructs the high-fidelity Knowledge Architect prompt for S T A R R Y N O T E v2.0.
122+
Forces synthesis over summary, visual reasoning via Mermaid, and strict authorship.
123123
"""
124-
context_label = "visual" if is_image else "text"
124+
context_label = "visual architecture" if is_image else "structured data"
125125

126126
knowledge_architect_prompt = (
127-
f"You are the S T A R R Y N O T E Knowledge Architect. "
128-
f"Synthesize this {context_label} input into a structured study guide.\n"
129-
f"RULES: Author='S T A R R Y N O T E'. Synthesize, don't summarize. "
130-
f"Fill every template section with dense content. Use original examples. "
131-
f"Include one Mermaid diagram (cyberpunk style: purple #bc13fe, cyan #00f3ff). "
132-
f"Academic tone. No HTML comments in output.\n\n"
127+
f"Act as the S T A R R Y N O T E Knowledge Architect. Your purpose is to ingest "
128+
f"raw, fragmented academic data ({context_label}) and synthesize it into a "
129+
f"high-density, structured study guide.\n\n"
130+
f"CORE DIRECTIVES:\n"
131+
f"1. AUTHORSHIP: Set the Author field to 'S T A R R Y N O T E' for every document generated.\n"
132+
f"2. SYNTHESIS > SUMMARY: Do not repeat the input. Identify the underlying logic. "
133+
f"Create original, advanced coding examples and mathematical proofs that aren't in "
134+
f"the source but explain the source perfectly.\n"
135+
f"3. FORMATTING: Use the provided MASTER TEMPLATE exactly. Do not skip sections. "
136+
f"If a section is irrelevant, mark it with \"\".\n"
137+
f"4. VISUAL REASONING: Select the most logical Mermaid diagram type "
138+
f"(Flowchart for logic, Mindmap for concepts, Sequence for protocols). "
139+
f"Apply cyberpunk styling (Neon Purple/Cyan) via class definitions.\n"
140+
f"5. ACADEMIC TONE: Use a scholarly, precise, and human-centric tone. "
141+
f"No conversational filler.\n\n"
142+
f"OUTPUT STRUCTURE:\n"
143+
f"- metadata block (Title, Date, Topic, Difficulty)\n"
144+
f"- Executive Abstract (Intellectual core)\n"
145+
f"- Concept Register (Definitions + Common Pitfalls)\n"
146+
f"- Technical Deep Dive (Code Trace or LaTeX Formulation)\n"
147+
f"- Exam Prep (3-tier questions: Application, Analysis, Synthesis)\n\n"
148+
f"Strictly avoid HTML comments or instruction markers in the final Markdown output.\n\n"
133149
)
134150

135151
return (
136152
f"{knowledge_architect_prompt}"
137-
f"--- TEMPLATE ---\n"
153+
f"--- MASTER TEMPLATE START ---\n"
138154
f"{self._prompt_template}\n"
139-
f"--- END TEMPLATE ---\n\n"
140-
f"--- SOURCE ---\n"
141-
f"{raw_content}\n"
142-
f"--- END SOURCE ---"
155+
f"--- MASTER TEMPLATE END ---\n\n"
156+
f"SOURCE INPUT TO SYNTHESIZE:\n"
157+
f"{raw_content}"
143158
)
144159

145160
# ── Analyzers ─────────────────────────────────────────────────────────

tests/test_engine.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ def test_prompt_contains_directives(self, mock_load):
103103
engine._prompt_template = "# Template"
104104

105105
prompt = engine._build_system_prompt("content", is_image=False)
106-
assert "Author='S T A R R Y N O T E'" in prompt
107-
assert "Synthesize" in prompt
108-
assert "template" in prompt.lower()
109-
assert "Mermaid" in prompt
110-
assert "Academic tone" in prompt
106+
assert "AUTHORSHIP" in prompt
107+
assert "SYNTHESIS" in prompt
108+
assert "FORMATTING" in prompt
109+
assert "VISUAL REASONING" in prompt
110+
assert "ACADEMIC TONE" in prompt
111111

112112
@patch("src.model_engine.load")
113113
def test_prompt_contains_template(self, mock_load):
@@ -119,9 +119,9 @@ def test_prompt_contains_template(self, mock_load):
119119
engine._prompt_template = "# My Template Content"
120120

121121
prompt = engine._build_system_prompt("input data")
122-
assert "--- TEMPLATE ---" in prompt
122+
assert "MASTER TEMPLATE START" in prompt
123123
assert "# My Template Content" in prompt
124-
assert "--- END TEMPLATE ---" in prompt
124+
assert "MASTER TEMPLATE END" in prompt
125125

126126
@patch("src.model_engine.load")
127127
def test_prompt_contains_source_input(self, mock_load):
@@ -145,7 +145,7 @@ def test_image_prompt_uses_visual_label(self, mock_load):
145145
engine._prompt_template = "# T"
146146

147147
prompt = engine._build_system_prompt("image data", is_image=True)
148-
assert "visual" in prompt
148+
assert "visual architecture" in prompt
149149

150150
@patch("src.model_engine.load")
151151
def test_text_prompt_uses_structured_data_label(self, mock_load):
@@ -157,7 +157,7 @@ def test_text_prompt_uses_structured_data_label(self, mock_load):
157157
engine._prompt_template = "# T"
158158

159159
prompt = engine._build_system_prompt("text data", is_image=False)
160-
assert "text" in prompt
160+
assert "structured data" in prompt
161161

162162

163163
class TestProcessRouting:

0 commit comments

Comments
 (0)