hamtaa-texttools 1.1.16__py3-none-any.whl → 1.1.18__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hamtaa_texttools-1.1.16.dist-info → hamtaa_texttools-1.1.18.dist-info}/METADATA +3 -2
- {hamtaa_texttools-1.1.16.dist-info → hamtaa_texttools-1.1.18.dist-info}/RECORD +17 -15
- texttools/__init__.py +1 -1
- texttools/batch/batch_runner.py +75 -64
- texttools/{tools/internals → internals}/async_operator.py +96 -48
- texttools/internals/exceptions.py +28 -0
- texttools/{tools/internals → internals}/models.py +63 -56
- texttools/internals/prompt_loader.py +80 -0
- texttools/{tools/internals → internals}/sync_operator.py +92 -47
- texttools/prompts/propositionize.yaml +15 -0
- texttools/tools/async_tools.py +627 -321
- texttools/tools/sync_tools.py +625 -319
- texttools/tools/internals/prompt_loader.py +0 -56
- {hamtaa_texttools-1.1.16.dist-info → hamtaa_texttools-1.1.18.dist-info}/WHEEL +0 -0
- {hamtaa_texttools-1.1.16.dist-info → hamtaa_texttools-1.1.18.dist-info}/licenses/LICENSE +0 -0
- {hamtaa_texttools-1.1.16.dist-info → hamtaa_texttools-1.1.18.dist-info}/top_level.txt +0 -0
- /texttools/{tools/internals → internals}/formatters.py +0 -0
- /texttools/{tools/internals → internals}/operator_utils.py +0 -0
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
from functools import lru_cache
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
import yaml
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class PromptLoader:
|
|
7
|
-
"""
|
|
8
|
-
Utility for loading and formatting YAML prompt templates.
|
|
9
|
-
|
|
10
|
-
Responsibilities:
|
|
11
|
-
- Load and parse YAML prompt definitions.
|
|
12
|
-
- Select the right template (by mode, if applicable).
|
|
13
|
-
- Inject variables (`{input}`, plus any extra kwargs) into the templates.
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
MAIN_TEMPLATE = "main_template"
|
|
17
|
-
ANALYZE_TEMPLATE = "analyze_template"
|
|
18
|
-
|
|
19
|
-
@staticmethod
|
|
20
|
-
def _build_format_args(text: str, **extra_kwargs) -> dict[str, str]:
|
|
21
|
-
# Base formatting args
|
|
22
|
-
format_args = {"input": text}
|
|
23
|
-
# Merge extras
|
|
24
|
-
format_args.update(extra_kwargs)
|
|
25
|
-
return format_args
|
|
26
|
-
|
|
27
|
-
# Use lru_cache to load each file once
|
|
28
|
-
@lru_cache(maxsize=32)
|
|
29
|
-
def _load_templates(self, prompt_file: str, mode: str | None) -> dict[str, str]:
|
|
30
|
-
"""
|
|
31
|
-
Loads prompt templates from YAML file with optional mode selection.
|
|
32
|
-
"""
|
|
33
|
-
base_dir = Path(__file__).parent.parent.parent / Path("prompts")
|
|
34
|
-
prompt_path = base_dir / prompt_file
|
|
35
|
-
data = yaml.safe_load(prompt_path.read_text(encoding="utf-8"))
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
self.MAIN_TEMPLATE: data[self.MAIN_TEMPLATE][mode]
|
|
39
|
-
if mode
|
|
40
|
-
else data[self.MAIN_TEMPLATE],
|
|
41
|
-
self.ANALYZE_TEMPLATE: data.get(self.ANALYZE_TEMPLATE)[mode]
|
|
42
|
-
if mode
|
|
43
|
-
else data.get(self.ANALYZE_TEMPLATE),
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
def load(
|
|
47
|
-
self, prompt_file: str, text: str, mode: str, **extra_kwargs
|
|
48
|
-
) -> dict[str, str]:
|
|
49
|
-
template_configs = self._load_templates(prompt_file, mode)
|
|
50
|
-
format_args = self._build_format_args(text, **extra_kwargs)
|
|
51
|
-
|
|
52
|
-
# Inject variables inside each template
|
|
53
|
-
for key in template_configs.keys():
|
|
54
|
-
template_configs[key] = template_configs[key].format(**format_args)
|
|
55
|
-
|
|
56
|
-
return template_configs
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|