weakincentives 0.2.0__py3-none-any.whl → 0.3.0__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.

Potentially problematic release.


This version of weakincentives might be problematic. Click here for more details.

Files changed (36) hide show
  1. weakincentives/__init__.py +26 -2
  2. weakincentives/adapters/__init__.py +6 -5
  3. weakincentives/adapters/core.py +7 -17
  4. weakincentives/adapters/litellm.py +594 -0
  5. weakincentives/adapters/openai.py +286 -57
  6. weakincentives/events.py +103 -0
  7. weakincentives/examples/__init__.py +67 -0
  8. weakincentives/examples/code_review_prompt.py +118 -0
  9. weakincentives/examples/code_review_session.py +171 -0
  10. weakincentives/examples/code_review_tools.py +376 -0
  11. weakincentives/{prompts → prompt}/__init__.py +6 -8
  12. weakincentives/{prompts → prompt}/_types.py +1 -1
  13. weakincentives/{prompts/text.py → prompt/markdown.py} +19 -9
  14. weakincentives/{prompts → prompt}/prompt.py +216 -66
  15. weakincentives/{prompts → prompt}/response_format.py +9 -6
  16. weakincentives/{prompts → prompt}/section.py +25 -4
  17. weakincentives/{prompts/structured.py → prompt/structured_output.py} +16 -5
  18. weakincentives/{prompts → prompt}/tool.py +6 -6
  19. weakincentives/prompt/versioning.py +144 -0
  20. weakincentives/serde/__init__.py +0 -14
  21. weakincentives/serde/dataclass_serde.py +3 -17
  22. weakincentives/session/__init__.py +31 -0
  23. weakincentives/session/reducers.py +60 -0
  24. weakincentives/session/selectors.py +45 -0
  25. weakincentives/session/session.py +168 -0
  26. weakincentives/tools/__init__.py +69 -0
  27. weakincentives/tools/errors.py +22 -0
  28. weakincentives/tools/planning.py +538 -0
  29. weakincentives/tools/vfs.py +590 -0
  30. weakincentives-0.3.0.dist-info/METADATA +231 -0
  31. weakincentives-0.3.0.dist-info/RECORD +35 -0
  32. weakincentives-0.2.0.dist-info/METADATA +0 -173
  33. weakincentives-0.2.0.dist-info/RECORD +0 -20
  34. /weakincentives/{prompts → prompt}/errors.py +0 -0
  35. {weakincentives-0.2.0.dist-info → weakincentives-0.3.0.dist-info}/WHEEL +0 -0
  36. {weakincentives-0.2.0.dist-info → weakincentives-0.3.0.dist-info}/licenses/LICENSE +0 -0
@@ -10,6 +10,30 @@
10
10
  # See the License for the specific language governing permissions and
11
11
  # limitations under the License.
12
12
 
13
- """Top-level package for the weakincentives library."""
13
+ """Curated public surface for :mod:`weakincentives`."""
14
14
 
15
- __all__ = []
15
+ from __future__ import annotations
16
+
17
+ from .adapters import PromptResponse
18
+ from .prompt import (
19
+ MarkdownSection,
20
+ Prompt,
21
+ SupportsDataclass,
22
+ Tool,
23
+ ToolResult,
24
+ parse_structured_output,
25
+ )
26
+
27
+ __all__ = [
28
+ "Prompt",
29
+ "MarkdownSection",
30
+ "Tool",
31
+ "ToolResult",
32
+ "PromptResponse",
33
+ "SupportsDataclass",
34
+ "parse_structured_output",
35
+ ]
36
+
37
+
38
+ def __dir__() -> list[str]: # pragma: no cover - convenience for REPL
39
+ return sorted({*globals().keys(), *__all__})
@@ -12,19 +12,20 @@
12
12
 
13
13
  """Integration adapters for optional third-party providers."""
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  from .core import (
16
18
  PromptEvaluationError,
17
19
  PromptResponse,
18
20
  ProviderAdapter,
19
- ToolCallRecord,
20
21
  )
21
- from .openai import OpenAIAdapter, OpenAIProtocol
22
22
 
23
23
  __all__ = [
24
24
  "ProviderAdapter",
25
25
  "PromptResponse",
26
26
  "PromptEvaluationError",
27
- "ToolCallRecord",
28
- "OpenAIAdapter",
29
- "OpenAIProtocol",
30
27
  ]
28
+
29
+
30
+ def __dir__() -> list[str]: # pragma: no cover - convenience for REPL
31
+ return sorted({*globals().keys(), *(__all__)})
@@ -17,9 +17,9 @@ from __future__ import annotations
17
17
  from dataclasses import dataclass
18
18
  from typing import Any, Protocol, TypeVar
19
19
 
20
- from ..prompts._types import SupportsDataclass
21
- from ..prompts.prompt import Prompt
22
- from ..prompts.tool import ToolResult
20
+ from ..events import EventBus, ToolInvoked
21
+ from ..prompt._types import SupportsDataclass
22
+ from ..prompt.prompt import Prompt
23
23
 
24
24
  OutputT = TypeVar("OutputT")
25
25
 
@@ -32,22 +32,13 @@ class ProviderAdapter(Protocol[OutputT]):
32
32
  prompt: Prompt[OutputT],
33
33
  *params: SupportsDataclass,
34
34
  parse_output: bool = True,
35
+ bus: EventBus,
35
36
  ) -> PromptResponse[OutputT]:
36
37
  """Evaluate the prompt and return a structured response."""
37
38
 
38
39
  ...
39
40
 
40
41
 
41
- @dataclass(slots=True)
42
- class ToolCallRecord[ParamsT, ResultT]:
43
- """Record describing a single tool invocation during evaluation."""
44
-
45
- name: str
46
- params: ParamsT
47
- result: ToolResult[ResultT]
48
- call_id: str | None = None
49
-
50
-
51
42
  @dataclass(slots=True)
52
43
  class PromptResponse[OutputT]:
53
44
  """Structured result emitted by an adapter evaluation."""
@@ -55,7 +46,7 @@ class PromptResponse[OutputT]:
55
46
  prompt_name: str
56
47
  text: str | None
57
48
  output: OutputT | None
58
- tool_results: tuple[ToolCallRecord[Any, Any], ...]
49
+ tool_results: tuple[ToolInvoked, ...]
59
50
  provider_payload: dict[str, Any] | None = None
60
51
 
61
52
 
@@ -67,13 +58,13 @@ class PromptEvaluationError(RuntimeError):
67
58
  message: str,
68
59
  *,
69
60
  prompt_name: str,
70
- stage: str,
61
+ phase: str,
71
62
  provider_payload: dict[str, Any] | None = None,
72
63
  ) -> None:
73
64
  super().__init__(message)
74
65
  self.message = message
75
66
  self.prompt_name = prompt_name
76
- self.stage = stage
67
+ self.phase = phase
77
68
  self.provider_payload = provider_payload
78
69
 
79
70
 
@@ -81,5 +72,4 @@ __all__ = [
81
72
  "ProviderAdapter",
82
73
  "PromptEvaluationError",
83
74
  "PromptResponse",
84
- "ToolCallRecord",
85
75
  ]