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.
Files changed (62) hide show
  1. {prompty-0.1.9 → prompty-0.1.10}/PKG-INFO +1 -1
  2. {prompty-0.1.9 → prompty-0.1.10}/prompty/core.py +31 -1
  3. {prompty-0.1.9 → prompty-0.1.10}/prompty/tracer.py +2 -0
  4. {prompty-0.1.9 → prompty-0.1.10}/pyproject.toml +1 -1
  5. {prompty-0.1.9 → prompty-0.1.10}/LICENSE +0 -0
  6. {prompty-0.1.9 → prompty-0.1.10}/README.md +0 -0
  7. {prompty-0.1.9 → prompty-0.1.10}/prompty/__init__.py +0 -0
  8. {prompty-0.1.9 → prompty-0.1.10}/prompty/cli.py +0 -0
  9. {prompty-0.1.9 → prompty-0.1.10}/prompty/executors.py +0 -0
  10. {prompty-0.1.9 → prompty-0.1.10}/prompty/parsers.py +0 -0
  11. {prompty-0.1.9 → prompty-0.1.10}/prompty/processors.py +0 -0
  12. {prompty-0.1.9 → prompty-0.1.10}/prompty/renderers.py +0 -0
  13. {prompty-0.1.9 → prompty-0.1.10}/tests/__init__.py +0 -0
  14. {prompty-0.1.9 → prompty-0.1.10}/tests/generated/1contoso.md +0 -0
  15. {prompty-0.1.9 → prompty-0.1.10}/tests/generated/2contoso.md +0 -0
  16. {prompty-0.1.9 → prompty-0.1.10}/tests/generated/3contoso.md +0 -0
  17. {prompty-0.1.9 → prompty-0.1.10}/tests/generated/4contoso.md +0 -0
  18. {prompty-0.1.9 → prompty-0.1.10}/tests/generated/basic.prompty.md +0 -0
  19. {prompty-0.1.9 → prompty-0.1.10}/tests/generated/camping.jpg +0 -0
  20. {prompty-0.1.9 → prompty-0.1.10}/tests/generated/context.prompty.md +0 -0
  21. {prompty-0.1.9 → prompty-0.1.10}/tests/generated/contoso_multi.md +0 -0
  22. {prompty-0.1.9 → prompty-0.1.10}/tests/generated/faithfulness.prompty.md +0 -0
  23. {prompty-0.1.9 → prompty-0.1.10}/tests/generated/groundedness.prompty.md +0 -0
  24. {prompty-0.1.9 → prompty-0.1.10}/tests/hello_world-goodbye_world-hello_again.embedding.json +0 -0
  25. {prompty-0.1.9 → prompty-0.1.10}/tests/hello_world.embedding.json +0 -0
  26. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/__init__.py +0 -0
  27. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/basic.prompty +0 -0
  28. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/basic.prompty.execution.json +0 -0
  29. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/basic_json_output.prompty +0 -0
  30. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/camping.jpg +0 -0
  31. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/chat.prompty +0 -0
  32. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/context.json +0 -0
  33. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/context.prompty +0 -0
  34. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/context.prompty.execution.json +0 -0
  35. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/embedding.prompty +0 -0
  36. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/embedding.prompty.execution.json +0 -0
  37. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/evaluation.prompty +0 -0
  38. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/faithfulness.prompty +0 -0
  39. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/faithfulness.prompty.execution.json +0 -0
  40. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/fake.prompty +0 -0
  41. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/funcfile.json +0 -0
  42. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/funcfile.prompty +0 -0
  43. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/functions.prompty +0 -0
  44. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/functions.prompty.execution.json +0 -0
  45. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/groundedness.prompty +0 -0
  46. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/groundedness.prompty.execution.json +0 -0
  47. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/prompty.json +0 -0
  48. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/streaming.prompty +0 -0
  49. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/streaming.prompty.execution.json +0 -0
  50. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/sub/__init__.py +0 -0
  51. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/sub/basic.prompty +0 -0
  52. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/sub/sub/__init__.py +0 -0
  53. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/sub/sub/basic.prompty +0 -0
  54. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/sub/sub/prompty.json +0 -0
  55. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/sub/sub/test.py +0 -0
  56. {prompty-0.1.9 → prompty-0.1.10}/tests/prompts/test.py +0 -0
  57. {prompty-0.1.9 → prompty-0.1.10}/tests/prompty.json +0 -0
  58. {prompty-0.1.9 → prompty-0.1.10}/tests/test_common.py +0 -0
  59. {prompty-0.1.9 → prompty-0.1.10}/tests/test_execute.py +0 -0
  60. {prompty-0.1.9 → prompty-0.1.10}/tests/test_factory_invoker.py +0 -0
  61. {prompty-0.1.9 → prompty-0.1.10}/tests/test_path_exec.py +0 -0
  62. {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.9
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()
@@ -16,7 +16,7 @@ dependencies = [
16
16
  ]
17
17
  requires-python = ">=3.9"
18
18
  readme = "README.md"
19
- version = "0.1.9"
19
+ version = "0.1.10"
20
20
 
21
21
  [project.license]
22
22
  text = "MIT"
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