prompty 0.1.36__tar.gz → 0.1.38__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {prompty-0.1.36 → prompty-0.1.38}/PKG-INFO +1 -1
- {prompty-0.1.36 → prompty-0.1.38}/prompty/tracer.py +32 -2
- {prompty-0.1.36 → prompty-0.1.38}/pyproject.toml +1 -1
- {prompty-0.1.36 → prompty-0.1.38}/tests/test_tracing.py +27 -0
- {prompty-0.1.36 → prompty-0.1.38}/LICENSE +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/README.md +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/prompty/__init__.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/prompty/azure/__init__.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/prompty/azure/executor.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/prompty/azure/processor.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/prompty/azure_beta/__init__.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/prompty/azure_beta/executor.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/prompty/cli.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/prompty/core.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/prompty/invoker.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/prompty/openai/__init__.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/prompty/openai/executor.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/prompty/openai/processor.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/prompty/parsers.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/prompty/renderers.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/prompty/serverless/__init__.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/prompty/serverless/executor.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/prompty/serverless/processor.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/prompty/utils.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/__init__.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/fake_azure_executor.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/fake_serverless_executor.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/generated/1contoso.md +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/generated/2contoso.md +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/generated/3contoso.md +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/generated/4contoso.md +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/generated/basic.prompty.md +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/generated/camping.jpg +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/generated/context.prompty.md +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/generated/contoso_multi.md +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/generated/faithfulness.prompty.md +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/generated/groundedness.prompty.md +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/hello_world-goodbye_world-hello_again.embedding.json +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/hello_world.embedding.json +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/__init__.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/basic.prompty +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/basic.prompty.execution.json +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/basic_json_output.prompty +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/camping.jpg +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/chat.prompty +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/context.json +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/context.prompty +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/context.prompty.execution.json +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/embedding.prompty +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/embedding.prompty.execution.json +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/evaluation.prompty +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/faithfulness.prompty +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/faithfulness.prompty.execution.json +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/fake.prompty +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/funcfile.json +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/funcfile.prompty +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/functions.prompty +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/functions.prompty.execution.json +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/groundedness.prompty +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/groundedness.prompty.execution.json +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/prompty.json +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/serverless.prompty +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/serverless.prompty.execution.json +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/serverless_stream.prompty +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/serverless_stream.prompty.execution.json +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/streaming.prompty +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/streaming.prompty.execution.json +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/structured_output.prompty +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/structured_output.prompty.execution.json +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/structured_output_schema.json +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/sub/__init__.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/sub/basic.prompty +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/sub/sub/__init__.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/sub/sub/basic.prompty +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/sub/sub/prompty.json +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/sub/sub/test.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompts/test.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/prompty.json +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/test_common.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/test_execute.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/test_factory_invoker.py +0 -0
- {prompty-0.1.36 → prompty-0.1.38}/tests/test_path_exec.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.38
|
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
|
@@ -28,6 +28,10 @@ def sanitize(key: str, value: Any) -> Any:
|
|
28
28
|
class Tracer:
|
29
29
|
_tracers: Dict[str, Callable[[str], Iterator[Callable[[str, Any], None]]]] = {}
|
30
30
|
|
31
|
+
SIGNATURE = "signature"
|
32
|
+
INPUTS = "inputs"
|
33
|
+
RESULT = "result"
|
34
|
+
|
31
35
|
@classmethod
|
32
36
|
def add(
|
33
37
|
cls, name: str, tracer: Callable[[str], Iterator[Callable[[str, Any], None]]]
|
@@ -40,11 +44,17 @@ class Tracer:
|
|
40
44
|
|
41
45
|
@classmethod
|
42
46
|
@contextlib.contextmanager
|
43
|
-
def start(cls, name: str) -> Iterator[Callable[[str, Any], None]]:
|
47
|
+
def start(cls, name: str, attributes: Dict[str, Any] = None) -> Iterator[Callable[[str, Any], None]]:
|
44
48
|
with contextlib.ExitStack() as stack:
|
45
49
|
traces = [
|
46
50
|
stack.enter_context(tracer(name)) for tracer in cls._tracers.values()
|
47
51
|
]
|
52
|
+
|
53
|
+
if attributes:
|
54
|
+
for trace in traces:
|
55
|
+
for key, value in attributes.items():
|
56
|
+
trace(key, value)
|
57
|
+
|
48
58
|
yield lambda key, value: [
|
49
59
|
# normalize and sanitize any trace values
|
50
60
|
trace(key, sanitize(key, to_dict(value)))
|
@@ -124,7 +134,17 @@ def _trace_sync(
|
|
124
134
|
@wraps(func)
|
125
135
|
def wrapper(*args, **kwargs):
|
126
136
|
name, signature = _name(func, args)
|
137
|
+
altname: str = None
|
138
|
+
# special case
|
139
|
+
if "name" in okwargs:
|
140
|
+
altname = name
|
141
|
+
name = okwargs["name"]
|
142
|
+
del okwargs["name"]
|
143
|
+
|
127
144
|
with Tracer.start(name) as trace:
|
145
|
+
if altname != None:
|
146
|
+
trace("function", altname)
|
147
|
+
|
128
148
|
trace("signature", signature)
|
129
149
|
|
130
150
|
# support arbitrary keyword
|
@@ -168,10 +188,20 @@ def _trace_async(
|
|
168
188
|
@wraps(func)
|
169
189
|
async def wrapper(*args, **kwargs):
|
170
190
|
name, signature = _name(func, args)
|
191
|
+
altname: str = None
|
192
|
+
# special case
|
193
|
+
if "name" in okwargs:
|
194
|
+
altname = name
|
195
|
+
name = okwargs["name"]
|
196
|
+
del okwargs["name"]
|
197
|
+
|
171
198
|
with Tracer.start(name) as trace:
|
199
|
+
if altname != None:
|
200
|
+
trace("function", altname)
|
201
|
+
|
172
202
|
trace("signature", signature)
|
173
203
|
|
174
|
-
# support arbitrary keyword
|
204
|
+
# support arbitrary keyword
|
175
205
|
# arguments for trace decorator
|
176
206
|
for k, v in okwargs.items():
|
177
207
|
trace(k, to_dict(v))
|
@@ -296,3 +296,30 @@ async def test_streaming_async():
|
|
296
296
|
if isinstance(result, AsyncIterator):
|
297
297
|
async for item in result:
|
298
298
|
print(item)
|
299
|
+
|
300
|
+
@trace
|
301
|
+
def test_tracing_attributes():
|
302
|
+
with Tracer.start("Test1", {Tracer.SIGNATURE: "test1", "two": 2}) as trace:
|
303
|
+
trace(Tracer.INPUTS, 3)
|
304
|
+
trace(Tracer.INPUTS, 4)
|
305
|
+
with Tracer.start("Test2", {"signature": "5", "six": 6}) as trace:
|
306
|
+
trace("inputs", 7)
|
307
|
+
trace(Tracer.RESULT, 8)
|
308
|
+
with Tracer.start("Test3", {"signature": "9", "ten": 10}) as trace:
|
309
|
+
trace("inputs", 11)
|
310
|
+
trace(Tracer.RESULT, 12)
|
311
|
+
|
312
|
+
|
313
|
+
@trace(name="OTHER")
|
314
|
+
def test_named_tracer():
|
315
|
+
with Tracer.start("Test1", {Tracer.SIGNATURE: "test1", "two": 2}) as trace:
|
316
|
+
trace(Tracer.INPUTS, 3)
|
317
|
+
trace(Tracer.RESULT, 4)
|
318
|
+
|
319
|
+
|
320
|
+
@pytest.mark.asyncio
|
321
|
+
@trace(name="OTHER")
|
322
|
+
async def test_named_tracer_async():
|
323
|
+
with Tracer.start("Test1", {Tracer.SIGNATURE: "test1", "two": 2}) as trace:
|
324
|
+
trace(Tracer.INPUTS, 3)
|
325
|
+
trace(Tracer.RESULT, 4)
|
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
|
{prompty-0.1.36 → prompty-0.1.38}/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
|
File without changes
|
File without changes
|