prompty 0.1.48__py3-none-any.whl → 0.1.50__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.
- prompty/__init__.py +4 -3
- prompty/utils.py +23 -12
- {prompty-0.1.48.dist-info → prompty-0.1.50.dist-info}/METADATA +5 -4
- {prompty-0.1.48.dist-info → prompty-0.1.50.dist-info}/RECORD +7 -7
- {prompty-0.1.48.dist-info → prompty-0.1.50.dist-info}/WHEEL +0 -0
- {prompty-0.1.48.dist-info → prompty-0.1.50.dist-info}/entry_points.txt +0 -0
- {prompty-0.1.48.dist-info → prompty-0.1.50.dist-info}/licenses/LICENSE +0 -0
prompty/__init__.py
CHANGED
@@ -12,7 +12,7 @@ from .core import (
|
|
12
12
|
)
|
13
13
|
from .invoker import InvokerFactory
|
14
14
|
from .parsers import PromptyChatParser
|
15
|
-
from .renderers import Jinja2Renderer
|
15
|
+
from .renderers import Jinja2Renderer, MustacheRenderer
|
16
16
|
from .tracer import trace
|
17
17
|
from .utils import (
|
18
18
|
load_global_config,
|
@@ -22,6 +22,7 @@ from .utils import (
|
|
22
22
|
)
|
23
23
|
|
24
24
|
InvokerFactory.add_renderer("jinja2", Jinja2Renderer)
|
25
|
+
InvokerFactory.add_renderer("mustache", MustacheRenderer)
|
25
26
|
InvokerFactory.add_parser("prompty.chat", PromptyChatParser)
|
26
27
|
|
27
28
|
|
@@ -66,7 +67,7 @@ def headless(
|
|
66
67
|
"""
|
67
68
|
|
68
69
|
# get caller's path (to get relative path for prompty.json)
|
69
|
-
caller = Path(traceback.extract_stack()[-
|
70
|
+
caller = Path(traceback.extract_stack()[-3].filename)
|
70
71
|
templateSettings = TemplateSettings(type="NOOP", parser="NOOP")
|
71
72
|
modelSettings = ModelSettings(
|
72
73
|
api=api,
|
@@ -123,7 +124,7 @@ async def headless_async(
|
|
123
124
|
"""
|
124
125
|
|
125
126
|
# get caller's path (to get relative path for prompty.json)
|
126
|
-
caller = Path(traceback.extract_stack()[-
|
127
|
+
caller = Path(traceback.extract_stack()[-3].filename)
|
127
128
|
templateSettings = TemplateSettings(type="NOOP", parser="NOOP")
|
128
129
|
|
129
130
|
global_config = await load_global_config_async(caller.parent, connection)
|
prompty/utils.py
CHANGED
@@ -33,20 +33,31 @@ async def load_json_async(file_path, encoding="utf-8"):
|
|
33
33
|
return json.loads(content)
|
34
34
|
|
35
35
|
|
36
|
+
def _walk_up_path(path: Path) -> typing.Union[Path, None]:
|
37
|
+
"""Walk up the path to find a prompty.json file.
|
38
|
+
|
39
|
+
Args:
|
40
|
+
path (Path): The path to start searching from.
|
41
|
+
"""
|
42
|
+
while path != path.parent:
|
43
|
+
# Check if the prompty.json file exists in the current directory
|
44
|
+
prompty_config = path / "prompty.json"
|
45
|
+
if prompty_config.exists():
|
46
|
+
return prompty_config
|
47
|
+
# Move up to the parent directory
|
48
|
+
path = path.parent
|
49
|
+
return None
|
50
|
+
|
51
|
+
|
36
52
|
def _find_global_config(prompty_path: Path = Path.cwd()) -> typing.Union[Path, None]:
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
for c in prompty_config
|
44
|
-
if len(c.parent.parts) <= len(prompty_path.parts)
|
45
|
-
],
|
46
|
-
key=lambda p: len(p.parts),
|
47
|
-
)[-1]
|
53
|
+
"""Find the prompty.json file in the current directory or any parent directory.
|
54
|
+
Args:
|
55
|
+
prompty_path (Path): The path to start searching from.
|
56
|
+
"""
|
57
|
+
if Path(prompty_path / "prompty.json").exists():
|
58
|
+
return Path(prompty_path / "prompty.json")
|
48
59
|
else:
|
49
|
-
return
|
60
|
+
return _walk_up_path(prompty_path)
|
50
61
|
|
51
62
|
|
52
63
|
def load_global_config(
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: prompty
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.50
|
4
4
|
Summary: Prompty is a new asset class and format for LLM prompts that aims to provide observability, understandability, and portability for developers. It includes spec, tooling, and a runtime. This Prompty runtime supports Python
|
5
5
|
Author-Email: Seth Juarez <seth.juarez@microsoft.com>
|
6
6
|
License: MIT
|
@@ -37,16 +37,17 @@ Examples prompty file:
|
|
37
37
|
```markdown
|
38
38
|
---
|
39
39
|
name: Basic Prompt
|
40
|
-
description: A basic prompt that uses the
|
40
|
+
description: A basic prompt that uses the gpt-3.5-turbo chat API to answer questions
|
41
41
|
authors:
|
42
42
|
- sethjuarez
|
43
43
|
- jietong
|
44
44
|
model:
|
45
45
|
api: chat
|
46
46
|
configuration:
|
47
|
-
api_version:
|
47
|
+
api_version: 2024-10-21
|
48
48
|
azure_endpoint: ${env:AZURE_OPENAI_ENDPOINT}
|
49
49
|
azure_deployment: ${env:AZURE_OPENAI_DEPLOYMENT:gpt-35-turbo}
|
50
|
+
type: azure_openai
|
50
51
|
sample:
|
51
52
|
firstName: Jane
|
52
53
|
lastName: Doe
|
@@ -76,7 +77,7 @@ Download the [VS Code extension here](https://marketplace.visualstudio.com/items
|
|
76
77
|
The Python runtime is a simple way to run your prompts in Python. The runtime is available as a Python package and can be installed using pip. Depending on the type of prompt you are running, you may need to install additional dependencies. The runtime is designed to be extensible and can be customized to fit your needs.
|
77
78
|
|
78
79
|
```bash
|
79
|
-
pip install prompty[azure]
|
80
|
+
pip install "prompty[azure]"
|
80
81
|
```
|
81
82
|
|
82
83
|
Simple usage example:
|
@@ -1,8 +1,8 @@
|
|
1
|
-
prompty-0.1.
|
2
|
-
prompty-0.1.
|
3
|
-
prompty-0.1.
|
4
|
-
prompty-0.1.
|
5
|
-
prompty/__init__.py,sha256=
|
1
|
+
prompty-0.1.50.dist-info/METADATA,sha256=uUwJ0AWc1dYLhqViFy69hmlMcFvPTXZEABUzLgaJDnc,9337
|
2
|
+
prompty-0.1.50.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
3
|
+
prompty-0.1.50.dist-info/entry_points.txt,sha256=a3i7Kvf--3DOkkv9VQpstwaNKgsnXwDGaPL18lPpKeI,60
|
4
|
+
prompty-0.1.50.dist-info/licenses/LICENSE,sha256=KWSC4z9cfML_t0xThoQYjzTdcZQj86Y_mhXdatzU-KM,1052
|
5
|
+
prompty/__init__.py,sha256=uxK7vPvI_ASJoAWwo_P4eHkTV3GttHr4UvHFnyHDdaQ,16937
|
6
6
|
prompty/azure/__init__.py,sha256=zBxzOMQCwtiz2CsI8gNWzr7T2ZJHF3TZNIUtvfuaEQI,309
|
7
7
|
prompty/azure/executor.py,sha256=MWeBwprLY2NmPySoOq-K3qMui5lPlMYMh5ktb3S7mgo,9367
|
8
8
|
prompty/azure/processor.py,sha256=gNmUkPBoSLPE0t7IVJUxGdwZ2otiycDE4Fu6L1vurZI,5330
|
@@ -22,5 +22,5 @@ prompty/serverless/__init__.py,sha256=ILtbqhy6E-wWodbnq-_aftruTGk1Z0EI9zURFH4FEC
|
|
22
22
|
prompty/serverless/executor.py,sha256=QZXeFTXv_aT22rbBBgBFLtdAJqGp4W8GS3H3Rtoy8bE,8936
|
23
23
|
prompty/serverless/processor.py,sha256=d42MalWRf8RUpHRiueqAPAj_nGmJSMUE2yL-Tgxrss4,3754
|
24
24
|
prompty/tracer.py,sha256=GYJsFfsF5uexv1RANENX_Xm5sOnIcQHT_LLAtr6JocU,12158
|
25
|
-
prompty/utils.py,sha256=
|
26
|
-
prompty-0.1.
|
25
|
+
prompty/utils.py,sha256=ZhiGY2BKe26LQmzUgeoz5i9s52-tlvOzh61ui3y0tIg,3297
|
26
|
+
prompty-0.1.50.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|