prompty 0.1.9__tar.gz → 0.1.10__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {prompty-0.1.9 → prompty-0.1.10}/PKG-INFO +1 -1
- {prompty-0.1.9 → prompty-0.1.10}/prompty/core.py +31 -1
- {prompty-0.1.9 → prompty-0.1.10}/prompty/tracer.py +2 -0
- {prompty-0.1.9 → prompty-0.1.10}/pyproject.toml +1 -1
- {prompty-0.1.9 → prompty-0.1.10}/LICENSE +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/README.md +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/prompty/__init__.py +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/prompty/cli.py +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/prompty/executors.py +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/prompty/parsers.py +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/prompty/processors.py +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/prompty/renderers.py +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/__init__.py +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/generated/1contoso.md +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/generated/2contoso.md +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/generated/3contoso.md +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/generated/4contoso.md +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/generated/basic.prompty.md +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/generated/camping.jpg +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/generated/context.prompty.md +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/generated/contoso_multi.md +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/generated/faithfulness.prompty.md +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/generated/groundedness.prompty.md +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/hello_world-goodbye_world-hello_again.embedding.json +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/hello_world.embedding.json +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/__init__.py +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/basic.prompty +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/basic.prompty.execution.json +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/basic_json_output.prompty +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/camping.jpg +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/chat.prompty +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/context.json +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/context.prompty +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/context.prompty.execution.json +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/embedding.prompty +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/embedding.prompty.execution.json +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/evaluation.prompty +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/faithfulness.prompty +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/faithfulness.prompty.execution.json +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/fake.prompty +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/funcfile.json +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/funcfile.prompty +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/functions.prompty +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/functions.prompty.execution.json +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/groundedness.prompty +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/groundedness.prompty.execution.json +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/prompty.json +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/streaming.prompty +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/streaming.prompty.execution.json +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/sub/__init__.py +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/sub/basic.prompty +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/sub/sub/__init__.py +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/sub/sub/basic.prompty +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/sub/sub/prompty.json +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/sub/sub/test.py +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/test.py +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/prompty.json +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/test_common.py +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/test_execute.py +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/test_factory_invoker.py +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/tests/test_path_exec.py +0 -0
- {prompty-0.1.9 → prompty-0.1.10}/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.10
|
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
|
@@ -8,7 +8,7 @@ import abc
|
|
8
8
|
from pathlib import Path
|
9
9
|
from .tracer import Tracer, trace, to_dict
|
10
10
|
from pydantic import BaseModel, Field, FilePath
|
11
|
-
from typing import Iterator, List, Literal, Dict, Callable, Set
|
11
|
+
from typing import AsyncIterator, Iterator, List, Literal, Dict, Callable, Set
|
12
12
|
|
13
13
|
|
14
14
|
class PropertySettings(BaseModel):
|
@@ -479,3 +479,33 @@ class PromptyStream(Iterator):
|
|
479
479
|
trace("items", [to_dict(s) for s in self.items])
|
480
480
|
|
481
481
|
raise StopIteration
|
482
|
+
|
483
|
+
|
484
|
+
class AsyncPromptyStream(AsyncIterator):
|
485
|
+
"""AsyncPromptyStream class to iterate over LLM stream.
|
486
|
+
Necessary for Prompty to handle streaming data when tracing."""
|
487
|
+
|
488
|
+
def __init__(self, name: str, iterator: AsyncIterator):
|
489
|
+
self.name = name
|
490
|
+
self.iterator = iterator
|
491
|
+
self.items: List[any] = []
|
492
|
+
self.__name__ = "AsyncPromptyStream"
|
493
|
+
|
494
|
+
def __aiter__(self):
|
495
|
+
return self
|
496
|
+
|
497
|
+
async def __anext__(self):
|
498
|
+
try:
|
499
|
+
# enumerate but add to list
|
500
|
+
o = await self.iterator.__anext__()
|
501
|
+
self.items.append(o)
|
502
|
+
return o
|
503
|
+
|
504
|
+
except StopIteration:
|
505
|
+
# StopIteration is raised
|
506
|
+
# contents are exhausted
|
507
|
+
if len(self.items) > 0:
|
508
|
+
with Tracer.start(f"{self.name}.AsyncPromptyStream") as trace:
|
509
|
+
trace("items", [to_dict(s) for s in self.items])
|
510
|
+
|
511
|
+
raise StopIteration
|
@@ -46,6 +46,8 @@ def to_dict(obj: Any) -> Dict[str, Any]:
|
|
46
46
|
# safe PromptyStream obj serialization
|
47
47
|
elif type(obj).__name__ == "PromptyStream":
|
48
48
|
return "PromptyStream"
|
49
|
+
elif type(obj).__name__ == "AsyncPromptyStream":
|
50
|
+
return "AsyncPromptyStream"
|
49
51
|
# pydantic models have their own json serialization
|
50
52
|
elif isinstance(obj, BaseModel):
|
51
53
|
return obj.model_dump()
|
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
|
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
|