pydantic-ai-slim 0.0.28__py3-none-any.whl → 0.0.29__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 pydantic-ai-slim might be problematic. Click here for more details.

pydantic_ai/agent.py CHANGED
@@ -1,6 +1,5 @@
1
1
  from __future__ import annotations as _annotations
2
2
 
3
- import asyncio
4
3
  import dataclasses
5
4
  import inspect
6
5
  from collections.abc import AsyncIterator, Awaitable, Iterator, Sequence
@@ -13,6 +12,7 @@ import logfire_api
13
12
  from typing_extensions import TypeVar, deprecated
14
13
 
15
14
  from pydantic_graph import BaseNode, End, Graph, GraphRun, GraphRunContext
15
+ from pydantic_graph._utils import get_event_loop
16
16
 
17
17
  from . import (
18
18
  _agent_graph,
@@ -538,7 +538,7 @@ class Agent(Generic[AgentDepsT, ResultDataT]):
538
538
  """
539
539
  if infer_name and self.name is None:
540
540
  self._infer_name(inspect.currentframe())
541
- return asyncio.get_event_loop().run_until_complete(
541
+ return get_event_loop().run_until_complete(
542
542
  self.run(
543
543
  user_prompt,
544
544
  result_type=result_type,
@@ -1,3 +1,4 @@
1
+ import functools
1
2
  from dataclasses import dataclass
2
3
  from typing import TypedDict
3
4
 
@@ -39,6 +40,9 @@ class DuckDuckGoSearchTool:
39
40
  client: DDGS
40
41
  """The DuckDuckGo search client."""
41
42
 
43
+ max_results: int | None = None
44
+ """The maximum number of results. If None, returns results only from the first response."""
45
+
42
46
  async def __call__(self, query: str) -> list[DuckDuckGoResult]:
43
47
  """Searches DuckDuckGo for the given query and returns the results.
44
48
 
@@ -48,16 +52,22 @@ class DuckDuckGoSearchTool:
48
52
  Returns:
49
53
  The search results.
50
54
  """
51
- results = await anyio.to_thread.run_sync(self.client.text, query)
55
+ search = functools.partial(self.client.text, max_results=self.max_results)
56
+ results = await anyio.to_thread.run_sync(search, query)
52
57
  if len(results) == 0:
53
58
  raise RuntimeError('No search results found.')
54
59
  return duckduckgo_ta.validate_python(results)
55
60
 
56
61
 
57
- def duckduckgo_search_tool(duckduckgo_client: DDGS | None = None):
58
- """Creates a DuckDuckGo search tool."""
62
+ def duckduckgo_search_tool(duckduckgo_client: DDGS | None = None, max_results: int | None = None):
63
+ """Creates a DuckDuckGo search tool.
64
+
65
+ Args:
66
+ duckduckgo_client: The DuckDuckGo search client.
67
+ max_results: The maximum number of results. If None, returns results only from the first response.
68
+ """
59
69
  return Tool(
60
- DuckDuckGoSearchTool(client=duckduckgo_client or DDGS()).__call__,
70
+ DuckDuckGoSearchTool(client=duckduckgo_client or DDGS(), max_results=max_results).__call__,
61
71
  name='duckduckgo_search',
62
72
  description='Searches DuckDuckGo for the given query and returns the results.',
63
73
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pydantic-ai-slim
3
- Version: 0.0.28
3
+ Version: 0.0.29
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
@@ -29,7 +29,7 @@ Requires-Dist: exceptiongroup; python_version < '3.11'
29
29
  Requires-Dist: griffe>=1.3.2
30
30
  Requires-Dist: httpx>=0.27
31
31
  Requires-Dist: logfire-api>=1.2.0
32
- Requires-Dist: pydantic-graph==0.0.28
32
+ Requires-Dist: pydantic-graph==0.0.29
33
33
  Requires-Dist: pydantic>=2.10
34
34
  Provides-Extra: anthropic
35
35
  Requires-Dist: anthropic>=0.40.0; extra == 'anthropic'
@@ -6,7 +6,7 @@ pydantic_ai/_pydantic.py,sha256=dROz3Hmfdi0C2exq88FhefDRVo_8S3rtkXnoUHzsz0c,8753
6
6
  pydantic_ai/_result.py,sha256=tN1pVulf_EM4bkBvpNUWPnUXezLY-sBrJEVCFdy2nLU,10264
7
7
  pydantic_ai/_system_prompt.py,sha256=602c2jyle2R_SesOrITBDETZqsLk4BZ8Cbo8yEhmx04,1120
8
8
  pydantic_ai/_utils.py,sha256=w9BYSfFZiaX757fRtMRclOL1uYzyQnxV_lxqbU2WTPs,9435
9
- pydantic_ai/agent.py,sha256=43xGZCeEsfl_eedFVgY94RAhRoLBIw4XdV8WH8omw3M,63659
9
+ pydantic_ai/agent.py,sha256=wCXvGwPykn-cYf1_4bR4XqYofqwI6X2lj4L-0-MbMp4,63685
10
10
  pydantic_ai/exceptions.py,sha256=1ujJeB3jDDQ-pH5ydBYrgStvR35-GlEW0bYGTGEr4ME,3127
11
11
  pydantic_ai/format_as_xml.py,sha256=QE7eMlg5-YUMw1_2kcI3h0uKYPZZyGkgXFDtfZTMeeI,4480
12
12
  pydantic_ai/messages.py,sha256=U-RgeRsMR-Ew6IoeBDrnQVONX9AwxyVd0aTnAxEA7EM,20918
@@ -16,7 +16,7 @@ pydantic_ai/settings.py,sha256=ntuWnke9UA18aByDxk9OIhN0tAgOaPdqCEkRf-wlp8Y,3059
16
16
  pydantic_ai/tools.py,sha256=IPZuZJCSQUppz1uyLVwpfFLGoMirB8YtKWXIDQGR444,13414
17
17
  pydantic_ai/usage.py,sha256=60d9f6M7YEYuKMbqDGDogX4KsA73fhDtWyDXYXoIPaI,4948
18
18
  pydantic_ai/common_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
- pydantic_ai/common_tools/duckduckgo.py,sha256=EaAxC9qdfsS7kcCLuRl_3ijHB7zsTwTb4bFwwsJaUi8,1771
19
+ pydantic_ai/common_tools/duckduckgo.py,sha256=-kSa1gGn5-NIYvtxFWrFcX2XdmfEmGxI3_wAqrb6jLI,2230
20
20
  pydantic_ai/common_tools/tavily.py,sha256=Lz35037ggkdWKa_Stj0yXBkiN_hygDefEevoRDUclF0,2560
21
21
  pydantic_ai/models/__init__.py,sha256=Qw_g58KzGUmuDKOBa2u3yFrNbgCXkdRSNtkhseLC1VM,13758
22
22
  pydantic_ai/models/anthropic.py,sha256=bFtE6hku9L4l4pKJg8XER37T2ST2htArho5lPjEohAk,20637
@@ -31,6 +31,6 @@ pydantic_ai/models/openai.py,sha256=koIcK_pDHmV-JFq_-VIzU-edAqGKOOzkSk5QSYWvfoc,
31
31
  pydantic_ai/models/test.py,sha256=Ux20cmuJFkhvI9L1N7ItHNFcd-j284TBEsrM53eWRag,16873
32
32
  pydantic_ai/models/vertexai.py,sha256=9Kp_1KMBlbP8_HRJTuFnrkkFmlJ7yFhADQYjxOgIh9Y,9523
33
33
  pydantic_ai/models/wrapper.py,sha256=Zr3fgiUBpt2N9gXds6iSwaMEtEsFKr9WwhpHjSoHa7o,1410
34
- pydantic_ai_slim-0.0.28.dist-info/METADATA,sha256=9HxYFOYIFQoNh4uk1ca3yThzS_QTpx8nzPmfLte9Vr4,3062
35
- pydantic_ai_slim-0.0.28.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
36
- pydantic_ai_slim-0.0.28.dist-info/RECORD,,
34
+ pydantic_ai_slim-0.0.29.dist-info/METADATA,sha256=f7eLYpKWzEGmzTC8U29ZO5T4aTYMTW0Shmqa1zuEtG0,3062
35
+ pydantic_ai_slim-0.0.29.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
36
+ pydantic_ai_slim-0.0.29.dist-info/RECORD,,