hbllmutils.meta.datamodel.sample

This module provides functionality for matching and pairing Python code samples with their corresponding prompts.

It defines matchers for Python files and prompt files, and provides a mechanism to pair them together for use in prompt engineering and testing scenarios. The module uses pattern matching to identify related files and organize them into structured pairs.

Classes:

PyMatcher: Matcher for Python sample files with .py.txt extension PromptMatcher: Matcher for prompt files with .prompt.txt extension PromptSamplePair: Pairs Python samples with their corresponding prompts

Functions:

get_prompt_samples: Retrieves all matched prompt-sample pairs from the current directory

PyMatcher

class hbllmutils.meta.datamodel.sample.PyMatcher(full_path: str, **kwargs: Any)[source]

Matcher for Python sample files.

This matcher identifies files with the pattern ‘<name>.py.txt’ and extracts the name component for pairing with corresponding prompt files.

Variables:
  • __pattern__ (str) – The file pattern to match Python sample files

  • name (str) – The extracted name from the matched file

PromptMatcher

class hbllmutils.meta.datamodel.sample.PromptMatcher(full_path: str, **kwargs: Any)[source]

Matcher for prompt files.

This matcher identifies files with the pattern ‘<name>.prompt.txt’ and extracts the name component for pairing with corresponding Python sample files.

Variables:
  • __pattern__ (str) – The file pattern to match prompt files

  • name (str) – The extracted name from the matched file

PromptSamplePair

class hbllmutils.meta.datamodel.sample.PromptSamplePair(values: Dict[str, Any], instances: Dict[str, BaseMatcher])[source]

Pairs Python sample files with their corresponding prompt files.

This class creates pairs of Python samples and prompts that share the same name, enabling structured access to related prompt engineering materials.

Variables:

get_prompt_samples

hbllmutils.meta.datamodel.sample.get_prompt_samples()[source]

Retrieve all prompt-sample pairs from the current module’s directory.

This function scans the directory containing this module and matches all Python sample files (.py.txt) with their corresponding prompt files (.prompt.txt) that share the same base name.

Returns:

A collection of matched prompt-sample pairs found in the directory

Return type:

list[PromptSamplePair]

Example::
>>> pairs = get_prompt_samples()
>>> for pair in pairs:
...     print(f"Sample: {pair.py.name}, Prompt: {pair.prompt.name}")
Sample: example, Prompt: example