pyfcstm.llm
LLM prompt resources for FCSTM model generation.
This module exposes the official FCSTM grammar guide prompt as a small Python
API. The guide is packaged with pyfcstm so downstream prompt builders can
use the same grammar reference that the project tests and releases validate.
Example:
>>> from pyfcstm.llm import get_grammar_guide_prompt_for_llm
>>> guide = get_grammar_guide_prompt_for_llm()
>>> "FCSTM" in guide
True
__all__
- pyfcstm.llm.__all__ = ['GrammarGuidePromptIntegrityError', 'GrammarGuidePromptPathUnavailableError', 'get_grammar_guide_prompt_for_llm', 'get_grammar_guide_prompt_path_for_llm', 'get_grammar_guide_prompt_metadata_for_llm']
Built-in mutable sequence.
If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.
GrammarGuidePromptIntegrityError
- class pyfcstm.llm.GrammarGuidePromptIntegrityError[source]
Error raised when the packaged grammar guide integrity check fails.
This indicates that the Markdown prompt and the packaged SHA-256 digest do not agree, or that the digest resource is missing or malformed. Source-tree users should run
make sha256after editing the guide and commit the guide and digest together. Installed-package users should reinstallpyfcstmfrom a clean wheel or source distribution.
get_grammar_guide_prompt_for_llm
- pyfcstm.llm.get_grammar_guide_prompt_for_llm(raise_on_integrity_error: bool = True) str[source]
Return the packaged FCSTM grammar guide prompt.
- Parameters:
raise_on_integrity_error (bool, optional) – Whether a missing, malformed, or mismatched
fcstm_grammar_guide.md.sha256resource should raise instead of returning the prompt with a warning, defaults toTrue.- Returns:
UTF-8 decoded Markdown prompt text with LF newlines.
- Return type:
str
- Raises:
FileNotFoundError – If the packaged Markdown resource is missing.
UnicodeDecodeError – If the resource is not valid UTF-8.
GrammarGuidePromptIntegrityError – If the checksum resource is missing, malformed, or does not match the normalized prompt text.
Example:
>>> guide = get_grammar_guide_prompt_for_llm() >>> guide.startswith("# FCSTM") True
get_grammar_guide_prompt_path_for_llm
- pyfcstm.llm.get_grammar_guide_prompt_path_for_llm(raise_on_integrity_error: bool = True) str[source]
Return the filesystem path to the packaged grammar guide prompt.
This helper is intended for source-tree and normal wheel installs where the Markdown resource exists as a real file. It intentionally does not materialize temporary files for zip import or other non-filesystem import modes; callers that only need prompt text should use
get_grammar_guide_prompt_for_llm().- Parameters:
raise_on_integrity_error (bool, optional) – Whether a missing, malformed, or mismatched
fcstm_grammar_guide.md.sha256resource should raise instead of returning the path with a warning, defaults toTrue.- Returns:
Filesystem path to
fcstm_grammar_guide.md.- Return type:
str
- Raises:
GrammarGuidePromptPathUnavailableError – If the resource cannot be represented as a real filesystem path.
GrammarGuidePromptIntegrityError – If the checksum resource is missing, malformed, or does not match the normalized prompt text.
Example:
>>> import os >>> path = get_grammar_guide_prompt_path_for_llm() >>> os.path.basename(path) 'fcstm_grammar_guide.md'
get_grammar_guide_prompt_metadata_for_llm
- pyfcstm.llm.get_grammar_guide_prompt_metadata_for_llm(raise_on_integrity_error: bool = True) Dict[str, str | int][source]
Return deterministic metadata for the packaged grammar guide prompt.
sha256,byte_size, andline_countare computed from the same LF-normalized prompt text returned byget_grammar_guide_prompt_for_llm().chapter_countis the number of Markdown level-two heading lines, i.e. lines starting with"## ".- Parameters:
raise_on_integrity_error (bool, optional) – Whether a missing, malformed, or mismatched
fcstm_grammar_guide.md.sha256resource should raise instead of returning metadata with a warning, defaults toTrue.- Returns:
Resource metadata for experiment snapshots.
- Return type:
Dict[str, Union[str, int]]
- Raises:
FileNotFoundError – If the packaged Markdown resource is missing.
UnicodeDecodeError – If the resource is not valid UTF-8.
GrammarGuidePromptIntegrityError – If the checksum resource is missing, malformed, or does not match the normalized prompt text.
Example:
>>> metadata = get_grammar_guide_prompt_metadata_for_llm() >>> metadata["resource_name"] 'fcstm_grammar_guide.md' >>> metadata["chapter_count"] > 0 True