prompty 0.1.16__tar.gz → 0.1.18__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {prompty-0.1.16 → prompty-0.1.18}/PKG-INFO +1 -1
- {prompty-0.1.16 → prompty-0.1.18}/prompty/cli.py +19 -5
- {prompty-0.1.16 → prompty-0.1.18}/prompty/core.py +3 -1
- {prompty-0.1.16 → prompty-0.1.18}/prompty/tracer.py +30 -5
- {prompty-0.1.16 → prompty-0.1.18}/pyproject.toml +1 -1
- prompty-0.1.16/prompty/azure_openai/__init__.py +0 -10
- {prompty-0.1.16 → prompty-0.1.18}/LICENSE +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/README.md +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/prompty/__init__.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/prompty/azure/__init__.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/prompty/azure/executor.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/prompty/azure/processor.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/prompty/openai/__init__.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/prompty/openai/executor.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/prompty/openai/processor.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/prompty/parsers.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/prompty/renderers.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/prompty/serverless/__init__.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/prompty/serverless/executor.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/prompty/serverless/processor.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/fake_azure_executor.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/fake_serverless_executor.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/generated/1contoso.md +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/generated/2contoso.md +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/generated/3contoso.md +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/generated/4contoso.md +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/generated/basic.prompty.md +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/generated/camping.jpg +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/generated/context.prompty.md +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/generated/contoso_multi.md +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/generated/faithfulness.prompty.md +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/generated/groundedness.prompty.md +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/hello_world-goodbye_world-hello_again.embedding.json +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/hello_world.embedding.json +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/__init__.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/basic.prompty +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/basic.prompty.execution.json +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/basic_json_output.prompty +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/camping.jpg +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/chat.prompty +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/context.json +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/context.prompty +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/context.prompty.execution.json +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/embedding.prompty +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/embedding.prompty.execution.json +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/evaluation.prompty +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/faithfulness.prompty +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/faithfulness.prompty.execution.json +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/fake.prompty +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/funcfile.json +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/funcfile.prompty +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/functions.prompty +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/functions.prompty.execution.json +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/groundedness.prompty +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/groundedness.prompty.execution.json +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/prompty.json +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/serverless.prompty +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/serverless.prompty.execution.json +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/serverless_stream.prompty +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/serverless_stream.prompty.execution.json +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/streaming.prompty +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/streaming.prompty.execution.json +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/sub/__init__.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/sub/basic.prompty +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/sub/sub/__init__.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/sub/sub/basic.prompty +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/sub/sub/prompty.json +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/sub/sub/test.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompts/test.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/prompty.json +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/test_common.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/test_execute.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/test_factory_invoker.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/test_path_exec.py +0 -0
- {prompty-0.1.16 → prompty-0.1.18}/tests/test_tracing.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: prompty
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.18
|
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
|
Requires-Dist: pyyaml>=6.0.1
|
@@ -10,8 +10,6 @@ import prompty
|
|
10
10
|
from prompty.tracer import trace, PromptyTracer, console_tracer, Tracer
|
11
11
|
from dotenv import load_dotenv
|
12
12
|
|
13
|
-
load_dotenv()
|
14
|
-
|
15
13
|
|
16
14
|
def normalize_path(p, create_dir=False) -> Path:
|
17
15
|
path = Path(p)
|
@@ -27,8 +25,16 @@ def normalize_path(p, create_dir=False) -> Path:
|
|
27
25
|
|
28
26
|
return path
|
29
27
|
|
28
|
+
|
30
29
|
def dynamic_import(module: str):
|
31
|
-
|
30
|
+
# built in modules
|
31
|
+
if module == "azure" or module == "azure_openai":
|
32
|
+
t = "prompty.azure"
|
33
|
+
elif module == "serverless":
|
34
|
+
t = "prompty.serverless"
|
35
|
+
else:
|
36
|
+
t = module
|
37
|
+
|
32
38
|
print(f"Loading invokers from {t}")
|
33
39
|
importlib.import_module(t)
|
34
40
|
|
@@ -60,7 +66,9 @@ def chat_mode(prompt_path: str):
|
|
60
66
|
break
|
61
67
|
# reloadable prompty file
|
62
68
|
chat_history.append({"role": "user", "content": user_input})
|
63
|
-
result = prompty.execute(
|
69
|
+
result = prompty.execute(
|
70
|
+
prompt_path, inputs={"chat_history": chat_history}
|
71
|
+
)
|
64
72
|
print(f"\n{G}Assistant:{W} {result}")
|
65
73
|
chat_history.append({"role": "assistant", "content": result})
|
66
74
|
except Exception as e:
|
@@ -92,10 +100,16 @@ def execute(prompt_path: str, raw=False):
|
|
92
100
|
|
93
101
|
@click.command()
|
94
102
|
@click.option("--source", "-s", required=True)
|
103
|
+
@click.option("--env", "-e", required=False)
|
95
104
|
@click.option("--verbose", "-v", is_flag=True)
|
96
105
|
@click.option("--chat", "-c", is_flag=True)
|
97
106
|
@click.version_option()
|
98
|
-
def run(source, verbose, chat):
|
107
|
+
def run(source, env, verbose, chat):
|
108
|
+
# load external env file
|
109
|
+
if env:
|
110
|
+
print(f"Loading environment variables from {env}")
|
111
|
+
load_dotenv(env)
|
112
|
+
|
99
113
|
prompt_path = normalize_path(source)
|
100
114
|
if not prompt_path.exists():
|
101
115
|
print(f"{str(prompt_path)} does not exist")
|
@@ -529,7 +529,9 @@ class PromptyStream(Iterator):
|
|
529
529
|
# StopIteration is raised
|
530
530
|
# contents are exhausted
|
531
531
|
if len(self.items) > 0:
|
532
|
-
with Tracer.start(
|
532
|
+
with Tracer.start("PromptyStream") as trace:
|
533
|
+
trace("signature", f"{self.name}.PromptyStream")
|
534
|
+
trace("inputs", "None")
|
533
535
|
trace("result", [to_dict(s) for s in self.items])
|
534
536
|
|
535
537
|
raise StopIteration
|
@@ -108,8 +108,21 @@ def _trace_sync(func: Callable = None, *, description: str = None) -> Callable:
|
|
108
108
|
inputs = _inputs(func, args, kwargs)
|
109
109
|
trace("inputs", inputs)
|
110
110
|
|
111
|
-
|
112
|
-
|
111
|
+
try:
|
112
|
+
result = func(*args, **kwargs)
|
113
|
+
trace("result", _results(result))
|
114
|
+
except Exception as e:
|
115
|
+
trace(
|
116
|
+
"result",
|
117
|
+
{
|
118
|
+
"exception": {
|
119
|
+
"type": type(e).__name__,
|
120
|
+
"message": str(e),
|
121
|
+
"args": e.args,
|
122
|
+
}
|
123
|
+
},
|
124
|
+
)
|
125
|
+
raise e
|
113
126
|
|
114
127
|
return result
|
115
128
|
|
@@ -129,9 +142,21 @@ def _trace_async(func: Callable = None, *, description: str = None) -> Callable:
|
|
129
142
|
|
130
143
|
inputs = _inputs(func, args, kwargs)
|
131
144
|
trace("inputs", inputs)
|
132
|
-
|
133
|
-
|
134
|
-
|
145
|
+
try:
|
146
|
+
result = await func(*args, **kwargs)
|
147
|
+
trace("result", _results(result))
|
148
|
+
except Exception as e:
|
149
|
+
trace(
|
150
|
+
"result",
|
151
|
+
{
|
152
|
+
"exception": {
|
153
|
+
"type": type(e).__name__,
|
154
|
+
"message": str(e),
|
155
|
+
"args": e.args,
|
156
|
+
}
|
157
|
+
},
|
158
|
+
)
|
159
|
+
raise e
|
135
160
|
|
136
161
|
return result
|
137
162
|
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# __init__.py
|
2
|
-
from prompty.core import InvokerException
|
3
|
-
|
4
|
-
try:
|
5
|
-
from ..azure.executor import AzureOpenAIExecutor
|
6
|
-
from ..azure.processor import AzureOpenAIProcessor
|
7
|
-
except ImportError:
|
8
|
-
raise InvokerException(
|
9
|
-
"Error registering AzureOpenAIExecutor and AzureOpenAIProcessor", "azure"
|
10
|
-
)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{prompty-0.1.16 → prompty-0.1.18}/tests/hello_world-goodbye_world-hello_again.embedding.json
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|