ai-prompter 0.2.1__py3-none-any.whl → 0.2.2__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.
- ai_prompter/__init__.py +20 -8
- {ai_prompter-0.2.1.dist-info → ai_prompter-0.2.2.dist-info}/METADATA +1 -1
- ai_prompter-0.2.2.dist-info/RECORD +6 -0
- ai_prompter-0.2.1.dist-info/RECORD +0 -6
- {ai_prompter-0.2.1.dist-info → ai_prompter-0.2.2.dist-info}/WHEEL +0 -0
- {ai_prompter-0.2.1.dist-info → ai_prompter-0.2.2.dist-info}/licenses/LICENSE +0 -0
ai_prompter/__init__.py
CHANGED
@@ -5,7 +5,7 @@ A prompt management module using Jinja to generate complex prompts with simple t
|
|
5
5
|
import os
|
6
6
|
from dataclasses import dataclass
|
7
7
|
from datetime import datetime
|
8
|
-
from typing import Any, Dict, Optional, Union
|
8
|
+
from typing import Any, Dict, Optional, Union, Callable
|
9
9
|
|
10
10
|
from jinja2 import Environment, FileSystemLoader, Template
|
11
11
|
from pydantic import BaseModel
|
@@ -39,24 +39,36 @@ class Prompter:
|
|
39
39
|
|
40
40
|
def __init__(
|
41
41
|
self,
|
42
|
-
prompt_template:
|
43
|
-
model:
|
44
|
-
|
45
|
-
prompt_dir:
|
42
|
+
prompt_template: str | None = None,
|
43
|
+
model: str | Any | None = None,
|
44
|
+
prompt_variation: str = "default",
|
45
|
+
prompt_dir: str | None = None,
|
46
|
+
template_text: str | None = None,
|
47
|
+
parser: Callable[[str], dict[str, Any]] | None = None,
|
48
|
+
*args,
|
49
|
+
**kwargs,
|
46
50
|
) -> None:
|
47
51
|
"""Initialize the Prompter with a template name, model, and optional custom directory.
|
48
52
|
|
49
53
|
Args:
|
50
54
|
prompt_template (str, optional): The name of the prompt template (without .jinja extension).
|
51
55
|
model (Union[str, Any], optional): The model to use for generation.
|
52
|
-
|
56
|
+
prompt_variation (str, optional): The variation of the prompt template.
|
53
57
|
prompt_dir (str, optional): Custom directory to search for templates.
|
58
|
+
template_text (str, optional): The raw text of the template.
|
59
|
+
parser (Callable[[str], dict[str, Any]], optional): The parser to use for generation.
|
54
60
|
"""
|
61
|
+
if template_text is not None and prompt_template is not None:
|
62
|
+
raise ValueError(
|
63
|
+
"Cannot provide both template_text and prompt_template. Choose one or the other."
|
64
|
+
)
|
55
65
|
self.prompt_template = prompt_template
|
56
|
-
self.
|
66
|
+
self.prompt_variation = prompt_variation
|
67
|
+
self.prompt_dir = prompt_dir
|
57
68
|
self.template_text = template_text
|
69
|
+
self.parser = parser
|
70
|
+
self.template: Template | None = None
|
58
71
|
self.model = model or os.getenv("OPENAI_MODEL", "gpt-4-turbo")
|
59
|
-
self.prompt_dir = prompt_dir
|
60
72
|
self._setup_template(template_text, prompt_dir)
|
61
73
|
|
62
74
|
def _setup_template(
|
@@ -0,0 +1,6 @@
|
|
1
|
+
ai_prompter/__init__.py,sha256=p3AyJ9R3C3c8BL2DdMxwYFEv0UMcH-Bz_d6nQ-YjKKA,10744
|
2
|
+
ai_prompter/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
3
|
+
ai_prompter-0.2.2.dist-info/METADATA,sha256=wKeWaoaiYixNYEAjEmkhZYp8FfO68hwjtfjApHgtvIQ,6950
|
4
|
+
ai_prompter-0.2.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
5
|
+
ai_prompter-0.2.2.dist-info/licenses/LICENSE,sha256=cS0_fa_8BoP0PvVG8D19pn_HDJrG96hd4PyEm9nkRo8,1066
|
6
|
+
ai_prompter-0.2.2.dist-info/RECORD,,
|
@@ -1,6 +0,0 @@
|
|
1
|
-
ai_prompter/__init__.py,sha256=ehtuhOKP0ze3sW1cYO4OyNhoB8CY926TmkPqvzz4ilA,10124
|
2
|
-
ai_prompter/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
3
|
-
ai_prompter-0.2.1.dist-info/METADATA,sha256=c4Wh6qs7JVcBwWf1FCe2MZtsw5HjygYuXyJzhuKFTUc,6950
|
4
|
-
ai_prompter-0.2.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
5
|
-
ai_prompter-0.2.1.dist-info/licenses/LICENSE,sha256=cS0_fa_8BoP0PvVG8D19pn_HDJrG96hd4PyEm9nkRo8,1066
|
6
|
-
ai_prompter-0.2.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|