pydantic-ai-slim 0.0.20__py3-none-any.whl → 0.0.22__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_graph.py +770 -0
- pydantic_ai/_parts_manager.py +1 -1
- pydantic_ai/_result.py +3 -7
- pydantic_ai/_utils.py +1 -56
- pydantic_ai/agent.py +192 -560
- pydantic_ai/messages.py +21 -46
- pydantic_ai/models/__init__.py +104 -57
- pydantic_ai/models/anthropic.py +17 -10
- pydantic_ai/models/cohere.py +37 -25
- pydantic_ai/models/gemini.py +27 -7
- pydantic_ai/models/groq.py +19 -17
- pydantic_ai/models/mistral.py +22 -23
- pydantic_ai/models/openai.py +25 -12
- pydantic_ai/models/test.py +37 -22
- pydantic_ai/result.py +1 -1
- pydantic_ai/settings.py +46 -1
- pydantic_ai/tools.py +11 -8
- {pydantic_ai_slim-0.0.20.dist-info → pydantic_ai_slim-0.0.22.dist-info}/METADATA +2 -3
- pydantic_ai_slim-0.0.22.dist-info/RECORD +30 -0
- pydantic_ai/models/ollama.py +0 -123
- pydantic_ai_slim-0.0.20.dist-info/RECORD +0 -30
- {pydantic_ai_slim-0.0.20.dist-info → pydantic_ai_slim-0.0.22.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
pydantic_ai/__init__.py,sha256=FbYetEgT6OO25u2KF5ZnFxKpz5DtnSpfckRXP4mjl8E,489
|
|
2
|
+
pydantic_ai/_agent_graph.py,sha256=IdznyPzgrLmfiw3733GA3gYWOA_6LYIEuXBKTBXOi0A,32942
|
|
3
|
+
pydantic_ai/_griffe.py,sha256=RYRKiLbgG97QxnazbAwlnc74XxevGHLQet-FGfq9qls,3960
|
|
4
|
+
pydantic_ai/_parts_manager.py,sha256=ARfDQY1_5AIY5rNl_M2fAYHEFCe03ZxdhgjHf9qeIKw,11872
|
|
5
|
+
pydantic_ai/_pydantic.py,sha256=dROz3Hmfdi0C2exq88FhefDRVo_8S3rtkXnoUHzsz0c,8753
|
|
6
|
+
pydantic_ai/_result.py,sha256=tN1pVulf_EM4bkBvpNUWPnUXezLY-sBrJEVCFdy2nLU,10264
|
|
7
|
+
pydantic_ai/_system_prompt.py,sha256=602c2jyle2R_SesOrITBDETZqsLk4BZ8Cbo8yEhmx04,1120
|
|
8
|
+
pydantic_ai/_utils.py,sha256=zfuY3NiPPsSM5J1q2JElfbfIa8S1ONGOlC7M-iyBVso,9430
|
|
9
|
+
pydantic_ai/agent.py,sha256=RDKBnHU1yFBMwW9e7_BUYs4aRfbwJ69bpWp_ha2y9M0,44880
|
|
10
|
+
pydantic_ai/exceptions.py,sha256=eGDKX6bGhgVxXBzu81Sk3iiAkXr0GUtgT7bD5Rxlqpg,2028
|
|
11
|
+
pydantic_ai/format_as_xml.py,sha256=QE7eMlg5-YUMw1_2kcI3h0uKYPZZyGkgXFDtfZTMeeI,4480
|
|
12
|
+
pydantic_ai/messages.py,sha256=kzXn4ZjlX9Sy2KXgFHWYbbwPk7TzTPdztzOJLWEONwU,17101
|
|
13
|
+
pydantic_ai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
pydantic_ai/result.py,sha256=0beXiUfiSb2kVc68iqLeg2qFQW6-mnTC8TFtiQayPDQ,18394
|
|
15
|
+
pydantic_ai/settings.py,sha256=ntuWnke9UA18aByDxk9OIhN0tAgOaPdqCEkRf-wlp8Y,3059
|
|
16
|
+
pydantic_ai/tools.py,sha256=lhupwm815lPlFFS79B0P61AyhUYtepA62LbZOCJrPEY,13205
|
|
17
|
+
pydantic_ai/usage.py,sha256=60d9f6M7YEYuKMbqDGDogX4KsA73fhDtWyDXYXoIPaI,4948
|
|
18
|
+
pydantic_ai/models/__init__.py,sha256=kVWd_WEK2dThHoG0Yha4t93w4Zaqkjcu9sKJ7nNqX_U,13245
|
|
19
|
+
pydantic_ai/models/anthropic.py,sha256=v2m6zjaezLjtkHO2Rx67rmoN1iOqDeAp9fswJcqRMBA,16967
|
|
20
|
+
pydantic_ai/models/cohere.py,sha256=wyjtD2uwkYYbsXLKwr-flmXSng_Atd-0jqtVDxDie14,10611
|
|
21
|
+
pydantic_ai/models/function.py,sha256=jv2aw5K4KrMIRPFSTiGbBHcv16UZtGEe_1irjTudLg0,9826
|
|
22
|
+
pydantic_ai/models/gemini.py,sha256=OsvtVqmKK4XmnLjPTRFwtCeXEuBOWfPrVZVZq0mSA30,28305
|
|
23
|
+
pydantic_ai/models/groq.py,sha256=W-uosi9PtvgXp8yoF6w8QZxPtrVjX1fmRQDjQQ10meE,13603
|
|
24
|
+
pydantic_ai/models/mistral.py,sha256=RuRlxTBPGXIpcwTdjX2596uN2tgHBvCDQCWieWa1A_Q,24793
|
|
25
|
+
pydantic_ai/models/openai.py,sha256=ZwhYcpPIehDzmOBY_U1BKQhxYPtvKUeQjs9jDNr23bU,15547
|
|
26
|
+
pydantic_ai/models/test.py,sha256=D_wBpRtrPcikopd5LBYjdAp3q-1gvuB9WnuopBQiRME,16659
|
|
27
|
+
pydantic_ai/models/vertexai.py,sha256=bQZ5W8n4521AH3jTiyP1fOYxtNgCgkhjCbBeASv5Ap8,9388
|
|
28
|
+
pydantic_ai_slim-0.0.22.dist-info/METADATA,sha256=lhhSBLTlHXj025p-n0u_X3EGOZnoSUTjAkXk59_WEV8,2839
|
|
29
|
+
pydantic_ai_slim-0.0.22.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
30
|
+
pydantic_ai_slim-0.0.22.dist-info/RECORD,,
|
pydantic_ai/models/ollama.py
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations as _annotations
|
|
2
|
-
|
|
3
|
-
from dataclasses import dataclass
|
|
4
|
-
from typing import Literal, Union
|
|
5
|
-
|
|
6
|
-
from httpx import AsyncClient as AsyncHTTPClient
|
|
7
|
-
|
|
8
|
-
from ..tools import ToolDefinition
|
|
9
|
-
from . import (
|
|
10
|
-
AgentModel,
|
|
11
|
-
Model,
|
|
12
|
-
cached_async_http_client,
|
|
13
|
-
check_allow_model_requests,
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
try:
|
|
17
|
-
from openai import AsyncOpenAI
|
|
18
|
-
except ImportError as e:
|
|
19
|
-
raise ImportError(
|
|
20
|
-
'Please install `openai` to use the OpenAI model, '
|
|
21
|
-
"you can use the `openai` optional group — `pip install 'pydantic-ai-slim[openai]'`"
|
|
22
|
-
) from e
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
from .openai import OpenAIModel
|
|
26
|
-
|
|
27
|
-
CommonOllamaModelNames = Literal[
|
|
28
|
-
'codellama',
|
|
29
|
-
'deepseek-r1',
|
|
30
|
-
'gemma',
|
|
31
|
-
'gemma2',
|
|
32
|
-
'llama3',
|
|
33
|
-
'llama3.1',
|
|
34
|
-
'llama3.2',
|
|
35
|
-
'llama3.2-vision',
|
|
36
|
-
'llama3.3',
|
|
37
|
-
'mistral',
|
|
38
|
-
'mistral-nemo',
|
|
39
|
-
'mixtral',
|
|
40
|
-
'phi3',
|
|
41
|
-
'phi4',
|
|
42
|
-
'qwq',
|
|
43
|
-
'qwen',
|
|
44
|
-
'qwen2',
|
|
45
|
-
'qwen2.5',
|
|
46
|
-
'starcoder2',
|
|
47
|
-
]
|
|
48
|
-
"""This contains just the most common ollama models.
|
|
49
|
-
|
|
50
|
-
For a full list see [ollama.com/library](https://ollama.com/library).
|
|
51
|
-
"""
|
|
52
|
-
OllamaModelName = Union[CommonOllamaModelNames, str]
|
|
53
|
-
"""Possible ollama models.
|
|
54
|
-
|
|
55
|
-
Since Ollama supports hundreds of models, we explicitly list the most models but
|
|
56
|
-
allow any name in the type hints.
|
|
57
|
-
"""
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
@dataclass(init=False)
|
|
61
|
-
class OllamaModel(Model):
|
|
62
|
-
"""A model that implements Ollama using the OpenAI API.
|
|
63
|
-
|
|
64
|
-
Internally, this uses the [OpenAI Python client](https://github.com/openai/openai-python) to interact with the Ollama server.
|
|
65
|
-
|
|
66
|
-
Apart from `__init__`, all methods are private or match those of the base class.
|
|
67
|
-
"""
|
|
68
|
-
|
|
69
|
-
model_name: OllamaModelName
|
|
70
|
-
openai_model: OpenAIModel
|
|
71
|
-
|
|
72
|
-
def __init__(
|
|
73
|
-
self,
|
|
74
|
-
model_name: OllamaModelName,
|
|
75
|
-
*,
|
|
76
|
-
base_url: str | None = 'http://localhost:11434/v1/',
|
|
77
|
-
api_key: str = 'ollama',
|
|
78
|
-
openai_client: AsyncOpenAI | None = None,
|
|
79
|
-
http_client: AsyncHTTPClient | None = None,
|
|
80
|
-
):
|
|
81
|
-
"""Initialize an Ollama model.
|
|
82
|
-
|
|
83
|
-
Ollama has built-in compatability for the OpenAI chat completions API ([source](https://ollama.com/blog/openai-compatibility)), so we reuse the
|
|
84
|
-
[`OpenAIModel`][pydantic_ai.models.openai.OpenAIModel] here.
|
|
85
|
-
|
|
86
|
-
Args:
|
|
87
|
-
model_name: The name of the Ollama model to use. List of models available [here](https://ollama.com/library)
|
|
88
|
-
You must first download the model (`ollama pull <MODEL-NAME>`) in order to use the model
|
|
89
|
-
base_url: The base url for the ollama requests. The default value is the ollama default
|
|
90
|
-
api_key: The API key to use for authentication. Defaults to 'ollama' for local instances,
|
|
91
|
-
but can be customized for proxy setups that require authentication
|
|
92
|
-
openai_client: An existing
|
|
93
|
-
[`AsyncOpenAI`](https://github.com/openai/openai-python?tab=readme-ov-file#async-usage)
|
|
94
|
-
client to use, if provided, `base_url` and `http_client` must be `None`.
|
|
95
|
-
http_client: An existing `httpx.AsyncClient` to use for making HTTP requests.
|
|
96
|
-
"""
|
|
97
|
-
self.model_name = model_name
|
|
98
|
-
if openai_client is not None:
|
|
99
|
-
assert base_url is None, 'Cannot provide both `openai_client` and `base_url`'
|
|
100
|
-
assert http_client is None, 'Cannot provide both `openai_client` and `http_client`'
|
|
101
|
-
self.openai_model = OpenAIModel(model_name=model_name, openai_client=openai_client)
|
|
102
|
-
else:
|
|
103
|
-
# API key is not required for ollama but a value is required to create the client
|
|
104
|
-
http_client_ = http_client or cached_async_http_client()
|
|
105
|
-
oai_client = AsyncOpenAI(base_url=base_url, api_key=api_key, http_client=http_client_)
|
|
106
|
-
self.openai_model = OpenAIModel(model_name=model_name, openai_client=oai_client)
|
|
107
|
-
|
|
108
|
-
async def agent_model(
|
|
109
|
-
self,
|
|
110
|
-
*,
|
|
111
|
-
function_tools: list[ToolDefinition],
|
|
112
|
-
allow_text_result: bool,
|
|
113
|
-
result_tools: list[ToolDefinition],
|
|
114
|
-
) -> AgentModel:
|
|
115
|
-
check_allow_model_requests()
|
|
116
|
-
return await self.openai_model.agent_model(
|
|
117
|
-
function_tools=function_tools,
|
|
118
|
-
allow_text_result=allow_text_result,
|
|
119
|
-
result_tools=result_tools,
|
|
120
|
-
)
|
|
121
|
-
|
|
122
|
-
def name(self) -> str:
|
|
123
|
-
return f'ollama:{self.model_name}'
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
pydantic_ai/__init__.py,sha256=FbYetEgT6OO25u2KF5ZnFxKpz5DtnSpfckRXP4mjl8E,489
|
|
2
|
-
pydantic_ai/_griffe.py,sha256=RYRKiLbgG97QxnazbAwlnc74XxevGHLQet-FGfq9qls,3960
|
|
3
|
-
pydantic_ai/_parts_manager.py,sha256=pMDZs6BGC8EmaNa-73QvuptmxdG2MhBrBLIydCOl-gM,11886
|
|
4
|
-
pydantic_ai/_pydantic.py,sha256=dROz3Hmfdi0C2exq88FhefDRVo_8S3rtkXnoUHzsz0c,8753
|
|
5
|
-
pydantic_ai/_result.py,sha256=zlkI82g78DeLW4zTCP3OgWeMUUOqxeDdu0nxLKYsv9c,10381
|
|
6
|
-
pydantic_ai/_system_prompt.py,sha256=602c2jyle2R_SesOrITBDETZqsLk4BZ8Cbo8yEhmx04,1120
|
|
7
|
-
pydantic_ai/_utils.py,sha256=EHW866W6ZpGJLCWtoEAcwIPeWo9OQFhnD5el2DwVcwc,10949
|
|
8
|
-
pydantic_ai/agent.py,sha256=EwaH207k4LcU_M-DYom8ZFiKMVaHJ2ZobxU2WjjsrSk,63500
|
|
9
|
-
pydantic_ai/exceptions.py,sha256=eGDKX6bGhgVxXBzu81Sk3iiAkXr0GUtgT7bD5Rxlqpg,2028
|
|
10
|
-
pydantic_ai/format_as_xml.py,sha256=QE7eMlg5-YUMw1_2kcI3h0uKYPZZyGkgXFDtfZTMeeI,4480
|
|
11
|
-
pydantic_ai/messages.py,sha256=V6JwFuADF21wKfszqT1CNgiYUeSAuJzjsngD-BJo3Y4,17841
|
|
12
|
-
pydantic_ai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
-
pydantic_ai/result.py,sha256=uubCdc51fYeZwkGGy1E9x2H9WP8FKoeqNQDaL0vzD1s,18393
|
|
14
|
-
pydantic_ai/settings.py,sha256=Yn4cXoESeJouFktfWqY1o0Exlf6yHfsvf6Uw6iMkuZQ,2278
|
|
15
|
-
pydantic_ai/tools.py,sha256=IrFeIxYQcpRUCrIv9p_4-hqmpjmUNC3dVwvr0gXf-1w,13057
|
|
16
|
-
pydantic_ai/usage.py,sha256=60d9f6M7YEYuKMbqDGDogX4KsA73fhDtWyDXYXoIPaI,4948
|
|
17
|
-
pydantic_ai/models/__init__.py,sha256=-tsz2kKwqvLXhTXk2WvdxB-PoMcaA043sQhkhzM9OFU,11715
|
|
18
|
-
pydantic_ai/models/anthropic.py,sha256=xhTTSq7wniIf4IlTyIAIGSmXpuXUvVOF9I6TRJLfmeo,16645
|
|
19
|
-
pydantic_ai/models/cohere.py,sha256=fGuXNpHUXfhfQ9AyG-Bo-Zet2njuNhjcpELmsCjhsvo,9933
|
|
20
|
-
pydantic_ai/models/function.py,sha256=jv2aw5K4KrMIRPFSTiGbBHcv16UZtGEe_1irjTudLg0,9826
|
|
21
|
-
pydantic_ai/models/gemini.py,sha256=nixBvW4YEtzURAj1qQrVEHKabFN13SUV1QgA1lm_eWo,27595
|
|
22
|
-
pydantic_ai/models/groq.py,sha256=6V_b4Gj63Uask8CfZLO1RjCNdv2FYd8SVjcRtMLMvgo,13355
|
|
23
|
-
pydantic_ai/models/mistral.py,sha256=8kyZiHeAOaZdcJCwFF_xgS_dJkq_e9xwjFOv9IE3YPY,24766
|
|
24
|
-
pydantic_ai/models/ollama.py,sha256=CEgcMW6KliaS7h5Fakx80EmSgm4rDLNjofBOCwM15lM,4288
|
|
25
|
-
pydantic_ai/models/openai.py,sha256=MV7S6hxW6PTOAWNmKBLTZ-e6vkYMByQXT16t4KK54DA,14776
|
|
26
|
-
pydantic_ai/models/test.py,sha256=SKtWqfjc8cb-U2gXJD1U43POxQnHFj_bEx734tCMov0,16328
|
|
27
|
-
pydantic_ai/models/vertexai.py,sha256=bQZ5W8n4521AH3jTiyP1fOYxtNgCgkhjCbBeASv5Ap8,9388
|
|
28
|
-
pydantic_ai_slim-0.0.20.dist-info/METADATA,sha256=3Z-xQLFaAP-JStPOVeiZFwU8ZkIbXzUCkBh8TkLEbuQ,2879
|
|
29
|
-
pydantic_ai_slim-0.0.20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
30
|
-
pydantic_ai_slim-0.0.20.dist-info/RECORD,,
|
|
File without changes
|