pydantic-ai-slim 0.1.12__tar.gz → 0.2.1__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.
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/PKG-INFO +3 -3
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/_cli.py +10 -2
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/_parts_manager.py +3 -1
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/agent.py +23 -7
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/messages.py +4 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/models/__init__.py +1 -5
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/models/_json_schema.py +8 -2
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/models/anthropic.py +3 -2
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/providers/bedrock.py +8 -2
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/.gitignore +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/README.md +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/__init__.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/__main__.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/_agent_graph.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/_griffe.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/_output.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/_pydantic.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/_system_prompt.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/_utils.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/common_tools/__init__.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/common_tools/duckduckgo.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/common_tools/tavily.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/exceptions.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/format_as_xml.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/format_prompt.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/mcp.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/models/bedrock.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/models/cohere.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/models/fallback.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/models/function.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/models/gemini.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/models/groq.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/models/instrumented.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/models/mistral.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/models/openai.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/models/test.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/models/wrapper.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/providers/__init__.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/providers/anthropic.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/providers/azure.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/providers/cohere.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/providers/deepseek.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/providers/google_gla.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/providers/google_vertex.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/providers/groq.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/providers/mistral.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/providers/openai.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/py.typed +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/result.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/settings.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/tools.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pydantic_ai/usage.py +0 -0
- {pydantic_ai_slim-0.1.12 → pydantic_ai_slim-0.2.1}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pydantic-ai-slim
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Agent Framework / shim to use Pydantic with LLMs, slim package
|
|
5
5
|
Author-email: Samuel Colvin <samuel@pydantic.dev>, Marcelo Trylesinski <marcelotryle@gmail.com>, David Montague <david@pydantic.dev>, Alex Hall <alex@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: opentelemetry-api>=1.28.0
|
|
32
|
-
Requires-Dist: pydantic-graph==0.1
|
|
32
|
+
Requires-Dist: pydantic-graph==0.2.1
|
|
33
33
|
Requires-Dist: pydantic>=2.10
|
|
34
34
|
Requires-Dist: typing-inspection>=0.4.0
|
|
35
35
|
Provides-Extra: anthropic
|
|
@@ -45,7 +45,7 @@ Requires-Dist: cohere>=5.13.11; (platform_system != 'Emscripten') and extra == '
|
|
|
45
45
|
Provides-Extra: duckduckgo
|
|
46
46
|
Requires-Dist: duckduckgo-search>=7.0.0; extra == 'duckduckgo'
|
|
47
47
|
Provides-Extra: evals
|
|
48
|
-
Requires-Dist: pydantic-evals==0.1
|
|
48
|
+
Requires-Dist: pydantic-evals==0.2.1; extra == 'evals'
|
|
49
49
|
Provides-Extra: groq
|
|
50
50
|
Requires-Dist: groq>=0.15.0; extra == 'groq'
|
|
51
51
|
Provides-Extra: logfire
|
|
@@ -42,6 +42,15 @@ except ImportError as _import_error:
|
|
|
42
42
|
__all__ = 'cli', 'cli_exit'
|
|
43
43
|
|
|
44
44
|
|
|
45
|
+
PYDANTIC_AI_HOME = Path.home() / '.pydantic-ai'
|
|
46
|
+
"""The home directory for PydanticAI CLI.
|
|
47
|
+
|
|
48
|
+
This folder is used to store the prompt history and configuration.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
PROMPT_HISTORY_PATH = PYDANTIC_AI_HOME / 'prompt-history.txt'
|
|
52
|
+
|
|
53
|
+
|
|
45
54
|
class SimpleCodeBlock(CodeBlock):
|
|
46
55
|
"""Customised code blocks in markdown.
|
|
47
56
|
|
|
@@ -167,9 +176,8 @@ Special prompts:
|
|
|
167
176
|
pass
|
|
168
177
|
return 0
|
|
169
178
|
|
|
170
|
-
history = Path.home() / f'.{prog_name}-prompt-history.txt'
|
|
171
179
|
# doing this instead of `PromptSession[Any](history=` allows mocking of PromptSession in tests
|
|
172
|
-
session: PromptSession[Any] = PromptSession(history=FileHistory(str(
|
|
180
|
+
session: PromptSession[Any] = PromptSession(history=FileHistory(str(PROMPT_HISTORY_PATH)))
|
|
173
181
|
try:
|
|
174
182
|
return asyncio.run(run_chat(session, stream, cli_agent, console, code_theme, prog_name))
|
|
175
183
|
except KeyboardInterrupt: # pragma: no cover
|
|
@@ -14,7 +14,7 @@ event-emitting logic.
|
|
|
14
14
|
from __future__ import annotations as _annotations
|
|
15
15
|
|
|
16
16
|
from collections.abc import Hashable
|
|
17
|
-
from dataclasses import dataclass, field
|
|
17
|
+
from dataclasses import dataclass, field, replace
|
|
18
18
|
from typing import Any, Union
|
|
19
19
|
|
|
20
20
|
from pydantic_ai.exceptions import UnexpectedModelBehavior
|
|
@@ -198,6 +198,8 @@ class ModelResponsePartsManager:
|
|
|
198
198
|
return PartStartEvent(index=part_index, part=updated_part)
|
|
199
199
|
else:
|
|
200
200
|
# We updated an existing part, so emit a PartDeltaEvent
|
|
201
|
+
if updated_part.tool_call_id and not delta.tool_call_id:
|
|
202
|
+
delta = replace(delta, tool_call_id=updated_part.tool_call_id)
|
|
201
203
|
return PartDeltaEvent(index=part_index, delta=delta)
|
|
202
204
|
|
|
203
205
|
def handle_tool_call_part(
|
|
@@ -12,7 +12,7 @@ from typing import TYPE_CHECKING, Any, Callable, ClassVar, Generic, cast, final,
|
|
|
12
12
|
|
|
13
13
|
from opentelemetry.trace import NoOpTracer, use_span
|
|
14
14
|
from pydantic.json_schema import GenerateJsonSchema
|
|
15
|
-
from typing_extensions import Literal, Never,
|
|
15
|
+
from typing_extensions import Literal, Never, TypeIs, TypeVar, deprecated
|
|
16
16
|
|
|
17
17
|
from pydantic_graph import End, Graph, GraphRun, GraphRunContext
|
|
18
18
|
from pydantic_graph._utils import get_event_loop
|
|
@@ -459,7 +459,7 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
459
459
|
self,
|
|
460
460
|
user_prompt: str | Sequence[_messages.UserContent] | None,
|
|
461
461
|
*,
|
|
462
|
-
output_type:
|
|
462
|
+
output_type: None = None,
|
|
463
463
|
message_history: list[_messages.ModelMessage] | None = None,
|
|
464
464
|
model: models.Model | models.KnownModelName | str | None = None,
|
|
465
465
|
deps: AgentDepsT = None,
|
|
@@ -468,7 +468,23 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
468
468
|
usage: _usage.Usage | None = None,
|
|
469
469
|
infer_name: bool = True,
|
|
470
470
|
**_deprecated_kwargs: Never,
|
|
471
|
-
) -> AbstractAsyncContextManager[AgentRun[AgentDepsT,
|
|
471
|
+
) -> AbstractAsyncContextManager[AgentRun[AgentDepsT, OutputDataT]]: ...
|
|
472
|
+
|
|
473
|
+
@overload
|
|
474
|
+
def iter(
|
|
475
|
+
self,
|
|
476
|
+
user_prompt: str | Sequence[_messages.UserContent] | None,
|
|
477
|
+
*,
|
|
478
|
+
output_type: type[RunOutputDataT] | ToolOutput[RunOutputDataT],
|
|
479
|
+
message_history: list[_messages.ModelMessage] | None = None,
|
|
480
|
+
model: models.Model | models.KnownModelName | str | None = None,
|
|
481
|
+
deps: AgentDepsT = None,
|
|
482
|
+
model_settings: ModelSettings | None = None,
|
|
483
|
+
usage_limits: _usage.UsageLimits | None = None,
|
|
484
|
+
usage: _usage.Usage | None = None,
|
|
485
|
+
infer_name: bool = True,
|
|
486
|
+
**_deprecated_kwargs: Never,
|
|
487
|
+
) -> AbstractAsyncContextManager[AgentRun[AgentDepsT, RunOutputDataT]]: ...
|
|
472
488
|
|
|
473
489
|
@overload
|
|
474
490
|
@deprecated('`result_type` is deprecated, use `output_type` instead.')
|
|
@@ -1621,7 +1637,7 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
1621
1637
|
@staticmethod
|
|
1622
1638
|
def is_model_request_node(
|
|
1623
1639
|
node: _agent_graph.AgentNode[T, S] | End[result.FinalResult[S]],
|
|
1624
|
-
) ->
|
|
1640
|
+
) -> TypeIs[_agent_graph.ModelRequestNode[T, S]]:
|
|
1625
1641
|
"""Check if the node is a `ModelRequestNode`, narrowing the type if it is.
|
|
1626
1642
|
|
|
1627
1643
|
This method preserves the generic parameters while narrowing the type, unlike a direct call to `isinstance`.
|
|
@@ -1631,7 +1647,7 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
1631
1647
|
@staticmethod
|
|
1632
1648
|
def is_call_tools_node(
|
|
1633
1649
|
node: _agent_graph.AgentNode[T, S] | End[result.FinalResult[S]],
|
|
1634
|
-
) ->
|
|
1650
|
+
) -> TypeIs[_agent_graph.CallToolsNode[T, S]]:
|
|
1635
1651
|
"""Check if the node is a `CallToolsNode`, narrowing the type if it is.
|
|
1636
1652
|
|
|
1637
1653
|
This method preserves the generic parameters while narrowing the type, unlike a direct call to `isinstance`.
|
|
@@ -1641,7 +1657,7 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
1641
1657
|
@staticmethod
|
|
1642
1658
|
def is_user_prompt_node(
|
|
1643
1659
|
node: _agent_graph.AgentNode[T, S] | End[result.FinalResult[S]],
|
|
1644
|
-
) ->
|
|
1660
|
+
) -> TypeIs[_agent_graph.UserPromptNode[T, S]]:
|
|
1645
1661
|
"""Check if the node is a `UserPromptNode`, narrowing the type if it is.
|
|
1646
1662
|
|
|
1647
1663
|
This method preserves the generic parameters while narrowing the type, unlike a direct call to `isinstance`.
|
|
@@ -1651,7 +1667,7 @@ class Agent(Generic[AgentDepsT, OutputDataT]):
|
|
|
1651
1667
|
@staticmethod
|
|
1652
1668
|
def is_end_node(
|
|
1653
1669
|
node: _agent_graph.AgentNode[T, S] | End[result.FinalResult[S]],
|
|
1654
|
-
) ->
|
|
1670
|
+
) -> TypeIs[End[result.FinalResult[S]]]:
|
|
1655
1671
|
"""Check if the node is a `End`, narrowing the type if it is.
|
|
1656
1672
|
|
|
1657
1673
|
This method preserves the generic parameters while narrowing the type, unlike a direct call to `isinstance`.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations as _annotations
|
|
2
2
|
|
|
3
|
+
import base64
|
|
3
4
|
import uuid
|
|
4
5
|
from collections.abc import Sequence
|
|
5
6
|
from dataclasses import dataclass, field, replace
|
|
@@ -341,6 +342,9 @@ class UserPromptPart:
|
|
|
341
342
|
content.append(part)
|
|
342
343
|
elif isinstance(part, (ImageUrl, AudioUrl, DocumentUrl, VideoUrl)):
|
|
343
344
|
content.append({'kind': part.kind, 'url': part.url})
|
|
345
|
+
elif isinstance(part, BinaryContent):
|
|
346
|
+
base64_data = base64.b64encode(part.data).decode()
|
|
347
|
+
content.append({'kind': part.kind, 'content': base64_data, 'media_type': part.media_type})
|
|
344
348
|
else:
|
|
345
349
|
content.append({'kind': part.kind})
|
|
346
350
|
return Event('gen_ai.user.message', body={'content': content, 'role': 'user'})
|
|
@@ -12,7 +12,6 @@ from contextlib import asynccontextmanager, contextmanager
|
|
|
12
12
|
from dataclasses import dataclass, field
|
|
13
13
|
from datetime import datetime
|
|
14
14
|
from functools import cache
|
|
15
|
-
from typing import TYPE_CHECKING
|
|
16
15
|
|
|
17
16
|
import httpx
|
|
18
17
|
from typing_extensions import Literal, TypeAliasType
|
|
@@ -21,12 +20,9 @@ from .._parts_manager import ModelResponsePartsManager
|
|
|
21
20
|
from ..exceptions import UserError
|
|
22
21
|
from ..messages import ModelMessage, ModelRequest, ModelResponse, ModelResponseStreamEvent
|
|
23
22
|
from ..settings import ModelSettings
|
|
23
|
+
from ..tools import ToolDefinition
|
|
24
24
|
from ..usage import Usage
|
|
25
25
|
|
|
26
|
-
if TYPE_CHECKING:
|
|
27
|
-
from ..tools import ToolDefinition
|
|
28
|
-
|
|
29
|
-
|
|
30
26
|
KnownModelName = TypeAliasType(
|
|
31
27
|
'KnownModelName',
|
|
32
28
|
Literal[
|
|
@@ -25,7 +25,7 @@ class WalkJsonSchema(ABC):
|
|
|
25
25
|
self.simplify_nullable_unions = simplify_nullable_unions
|
|
26
26
|
|
|
27
27
|
self.defs: dict[str, JsonSchema] = self.schema.get('$defs', {})
|
|
28
|
-
self.refs_stack =
|
|
28
|
+
self.refs_stack: list[str] = []
|
|
29
29
|
self.recursive_refs = set[str]()
|
|
30
30
|
|
|
31
31
|
@abstractmethod
|
|
@@ -62,13 +62,16 @@ class WalkJsonSchema(ABC):
|
|
|
62
62
|
return handled
|
|
63
63
|
|
|
64
64
|
def _handle(self, schema: JsonSchema) -> JsonSchema:
|
|
65
|
+
nested_refs = 0
|
|
65
66
|
if self.prefer_inlined_defs:
|
|
66
67
|
while ref := schema.get('$ref'):
|
|
67
68
|
key = re.sub(r'^#/\$defs/', '', ref)
|
|
68
69
|
if key in self.refs_stack:
|
|
69
70
|
self.recursive_refs.add(key)
|
|
70
71
|
break # recursive ref can't be unpacked
|
|
71
|
-
self.refs_stack
|
|
72
|
+
self.refs_stack.append(key)
|
|
73
|
+
nested_refs += 1
|
|
74
|
+
|
|
72
75
|
def_schema = self.defs.get(key)
|
|
73
76
|
if def_schema is None: # pragma: no cover
|
|
74
77
|
raise UserError(f'Could not find $ref definition for {key}')
|
|
@@ -87,6 +90,9 @@ class WalkJsonSchema(ABC):
|
|
|
87
90
|
# Apply the base transform
|
|
88
91
|
schema = self.transform(schema)
|
|
89
92
|
|
|
93
|
+
if nested_refs > 0:
|
|
94
|
+
self.refs_stack = self.refs_stack[:-nested_refs]
|
|
95
|
+
|
|
90
96
|
return schema
|
|
91
97
|
|
|
92
98
|
def _handle_object(self, schema: JsonSchema) -> JsonSchema:
|
|
@@ -284,7 +284,7 @@ class AnthropicModel(Model):
|
|
|
284
284
|
|
|
285
285
|
async def _map_message(self, messages: list[ModelMessage]) -> tuple[str, list[MessageParam]]:
|
|
286
286
|
"""Just maps a `pydantic_ai.Message` to a `anthropic.types.MessageParam`."""
|
|
287
|
-
|
|
287
|
+
system_prompt_parts: list[str] = []
|
|
288
288
|
anthropic_messages: list[MessageParam] = []
|
|
289
289
|
for m in messages:
|
|
290
290
|
if isinstance(m, ModelRequest):
|
|
@@ -293,7 +293,7 @@ class AnthropicModel(Model):
|
|
|
293
293
|
] = []
|
|
294
294
|
for request_part in m.parts:
|
|
295
295
|
if isinstance(request_part, SystemPromptPart):
|
|
296
|
-
|
|
296
|
+
system_prompt_parts.append(request_part.content)
|
|
297
297
|
elif isinstance(request_part, UserPromptPart):
|
|
298
298
|
async for content in self._map_user_prompt(request_part):
|
|
299
299
|
user_content_params.append(content)
|
|
@@ -333,6 +333,7 @@ class AnthropicModel(Model):
|
|
|
333
333
|
anthropic_messages.append(MessageParam(role='assistant', content=assistant_content_params))
|
|
334
334
|
else:
|
|
335
335
|
assert_never(m)
|
|
336
|
+
system_prompt = '\n\n'.join(system_prompt_parts)
|
|
336
337
|
if instructions := self._get_instructions(messages):
|
|
337
338
|
system_prompt = f'{instructions}\n\n{system_prompt}'
|
|
338
339
|
return system_prompt, anthropic_messages
|
|
@@ -44,6 +44,7 @@ class BedrockProvider(Provider[BaseClient]):
|
|
|
44
44
|
aws_access_key_id: str | None = None,
|
|
45
45
|
aws_secret_access_key: str | None = None,
|
|
46
46
|
aws_session_token: str | None = None,
|
|
47
|
+
profile_name: str | None = None,
|
|
47
48
|
aws_read_timeout: float | None = None,
|
|
48
49
|
aws_connect_timeout: float | None = None,
|
|
49
50
|
) -> None: ...
|
|
@@ -56,6 +57,7 @@ class BedrockProvider(Provider[BaseClient]):
|
|
|
56
57
|
aws_access_key_id: str | None = None,
|
|
57
58
|
aws_secret_access_key: str | None = None,
|
|
58
59
|
aws_session_token: str | None = None,
|
|
60
|
+
profile_name: str | None = None,
|
|
59
61
|
aws_read_timeout: float | None = None,
|
|
60
62
|
aws_connect_timeout: float | None = None,
|
|
61
63
|
) -> None:
|
|
@@ -67,6 +69,7 @@ class BedrockProvider(Provider[BaseClient]):
|
|
|
67
69
|
aws_access_key_id: The AWS access key ID.
|
|
68
70
|
aws_secret_access_key: The AWS secret access key.
|
|
69
71
|
aws_session_token: The AWS session token.
|
|
72
|
+
profile_name: The AWS profile name.
|
|
70
73
|
aws_read_timeout: The read timeout for Bedrock client.
|
|
71
74
|
aws_connect_timeout: The connect timeout for Bedrock client.
|
|
72
75
|
"""
|
|
@@ -76,12 +79,15 @@ class BedrockProvider(Provider[BaseClient]):
|
|
|
76
79
|
try:
|
|
77
80
|
read_timeout = aws_read_timeout or float(os.getenv('AWS_READ_TIMEOUT', 300))
|
|
78
81
|
connect_timeout = aws_connect_timeout or float(os.getenv('AWS_CONNECT_TIMEOUT', 60))
|
|
79
|
-
|
|
80
|
-
'bedrock-runtime',
|
|
82
|
+
session = boto3.Session(
|
|
81
83
|
aws_access_key_id=aws_access_key_id,
|
|
82
84
|
aws_secret_access_key=aws_secret_access_key,
|
|
83
85
|
aws_session_token=aws_session_token,
|
|
84
86
|
region_name=region_name,
|
|
87
|
+
profile_name=profile_name,
|
|
88
|
+
)
|
|
89
|
+
self._client = session.client( # type: ignore[reportUnknownMemberType]
|
|
90
|
+
'bedrock-runtime',
|
|
85
91
|
config=Config(read_timeout=read_timeout, connect_timeout=connect_timeout),
|
|
86
92
|
)
|
|
87
93
|
except NoRegionError as exc: # pragma: no cover
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|