mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 00:59:48 +08:00
PromptManager.clear_cache() and reload_prompts() dropped cached packs but
the fragment lru_cache kept serving the old fragments/*.yaml, so a
reloaded pack still carried the previous rule text. Both now clear it.
Fragments are checked for "{" and "}" when loaded (the expanded text can
pass through str.format()), with a test over every fragment in en and
zh. The notes capability gets a test that its en and zh instructions
include the shared maths rule.
Refs #2975
23 lines
803 B
Python
23 lines
803 B
Python
"""The notes capability states the shared maths rule in both languages."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from types import SimpleNamespace
|
|
|
|
import pytest
|
|
|
|
from deeptutor.capabilities.notes import capability
|
|
from deeptutor.services.prompt import shared_fragment
|
|
|
|
|
|
@pytest.mark.parametrize("language", ["en", "zh"])
|
|
def test_notes_instruction_uses_the_shared_math_rule(language: str) -> None:
|
|
# The system block is static text read from prompts/<lang>/system.md.
|
|
context = SimpleNamespace(metadata={"note_document_id": "page"}, session_id="s")
|
|
|
|
block = capability.NotesCapability().system_block(context, language=language, prompts={})
|
|
|
|
assert shared_fragment("math_latex", language) in block.content
|
|
assert "mermaid" in block.content
|
|
assert "{{shared:" not in block.content
|