pydantic-ai-slim 0.0.13__tar.gz → 0.0.15__tar.gz

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 pydantic-ai-slim might be problematic. Click here for more details.

Files changed (29) hide show
  1. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/.gitignore +1 -1
  2. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/PKG-INFO +1 -2
  3. pydantic_ai_slim-0.0.15/pydantic_ai/__init__.py +19 -0
  4. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/_result.py +6 -9
  5. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/_system_prompt.py +2 -2
  6. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/agent.py +154 -90
  7. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/exceptions.py +20 -2
  8. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/messages.py +29 -7
  9. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/models/__init__.py +10 -9
  10. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/models/anthropic.py +12 -12
  11. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/models/function.py +16 -22
  12. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/models/gemini.py +16 -18
  13. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/models/groq.py +21 -23
  14. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/models/mistral.py +34 -51
  15. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/models/openai.py +21 -23
  16. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/models/test.py +23 -17
  17. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/result.py +82 -35
  18. pydantic_ai_slim-0.0.15/pydantic_ai/settings.py +141 -0
  19. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/tools.py +22 -28
  20. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pyproject.toml +2 -2
  21. pydantic_ai_slim-0.0.13/pydantic_ai/__init__.py +0 -8
  22. pydantic_ai_slim-0.0.13/pydantic_ai/settings.py +0 -72
  23. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/README.md +0 -0
  24. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/_griffe.py +0 -0
  25. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/_pydantic.py +0 -0
  26. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/_utils.py +0 -0
  27. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/models/ollama.py +0 -0
  28. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/models/vertexai.py +0 -0
  29. {pydantic_ai_slim-0.0.13 → pydantic_ai_slim-0.0.15}/pydantic_ai/py.typed +0 -0
@@ -10,6 +10,6 @@ env*/
10
10
  /TODO.md
11
11
  /postgres-data/
12
12
  .DS_Store
13
- /pydantic_ai_examples/.chat_app_messages.sqlite
13
+ examples/pydantic_ai_examples/.chat_app_messages.sqlite
14
14
  .cache/
15
15
  .vscode/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pydantic-ai-slim
3
- Version: 0.0.13
3
+ Version: 0.0.15
4
4
  Summary: Agent Framework / shim to use Pydantic with LLMs, slim package
5
5
  Author-email: Samuel Colvin <samuel@pydantic.dev>
6
6
  License-Expression: MIT
@@ -36,7 +36,6 @@ Requires-Dist: groq>=0.12.0; extra == 'groq'
36
36
  Provides-Extra: logfire
37
37
  Requires-Dist: logfire>=2.3; extra == 'logfire'
38
38
  Provides-Extra: mistral
39
- Requires-Dist: json-repair>=0.30.3; extra == 'mistral'
40
39
  Requires-Dist: mistralai>=1.2.5; extra == 'mistral'
41
40
  Provides-Extra: openai
42
41
  Requires-Dist: openai>=1.54.3; extra == 'openai'
@@ -0,0 +1,19 @@
1
+ from importlib.metadata import version
2
+
3
+ from .agent import Agent, capture_run_messages
4
+ from .exceptions import AgentRunError, ModelRetry, UnexpectedModelBehavior, UsageLimitExceeded, UserError
5
+ from .tools import RunContext, Tool
6
+
7
+ __all__ = (
8
+ 'Agent',
9
+ 'capture_run_messages',
10
+ 'RunContext',
11
+ 'Tool',
12
+ 'AgentRunError',
13
+ 'ModelRetry',
14
+ 'UnexpectedModelBehavior',
15
+ 'UsageLimitExceeded',
16
+ 'UserError',
17
+ '__version__',
18
+ )
19
+ __version__ = version('pydantic_ai_slim')
@@ -12,8 +12,8 @@ from typing_extensions import Self, TypeAliasType, TypedDict
12
12
 
13
13
  from . import _utils, messages as _messages
14
14
  from .exceptions import ModelRetry
15
- from .result import ResultData
16
- from .tools import AgentDeps, ResultValidatorFunc, RunContext, ToolDefinition
15
+ from .result import ResultData, ResultValidatorFunc
16
+ from .tools import AgentDeps, RunContext, ToolDefinition
17
17
 
18
18
 
19
19
  @dataclass
@@ -29,25 +29,22 @@ class ResultValidator(Generic[AgentDeps, ResultData]):
29
29
  async def validate(
30
30
  self,
31
31
  result: ResultData,
32
- deps: AgentDeps,
33
- retry: int,
34
32
  tool_call: _messages.ToolCallPart | None,
35
- messages: list[_messages.ModelMessage],
33
+ run_context: RunContext[AgentDeps],
36
34
  ) -> ResultData:
37
35
  """Validate a result but calling the function.
38
36
 
39
37
  Args:
40
38
  result: The result data after Pydantic validation the message content.
41
- deps: The agent dependencies.
42
- retry: The current retry number.
43
39
  tool_call: The original tool call message, `None` if there was no tool call.
44
- messages: The messages exchanged so far in the conversation.
40
+ run_context: The current run context.
45
41
 
46
42
  Returns:
47
43
  Result of either the validated result data (ok) or a retry message (Err).
48
44
  """
49
45
  if self._takes_ctx:
50
- args = RunContext(deps, retry, messages, tool_call.tool_name if tool_call else None), result
46
+ ctx = run_context.replace_with(tool_name=tool_call.tool_name if tool_call else None)
47
+ args = ctx, result
51
48
  else:
52
49
  args = (result,)
53
50
 
@@ -19,9 +19,9 @@ class SystemPromptRunner(Generic[AgentDeps]):
19
19
  self._takes_ctx = len(inspect.signature(self.function).parameters) > 0
20
20
  self._is_async = inspect.iscoroutinefunction(self.function)
21
21
 
22
- async def run(self, deps: AgentDeps) -> str:
22
+ async def run(self, run_context: RunContext[AgentDeps]) -> str:
23
23
  if self._takes_ctx:
24
- args = (RunContext(deps, 0, [], None),)
24
+ args = (run_context,)
25
25
  else:
26
26
  args = ()
27
27