ó
    ±"³jy-  ã                  ól  • % S SK Jr  S SKrS SKrS SKJr  S SKJrJ	r	  S SK
Jr  S SKJrJr  S SKJr  S SKJrJr  S S	KJrJr  S S
KJr  SSKJrJr   S SKJrJrJrJ r J!r!  S SK$r$\\-  \-  \ -  \!-  r%S\&S'   Sr' Sr(  " S S\\%   5      r)\" SS9 " S S\5      5       r*g! \" a  r#\"" S5      \#eSr#C#ff = f)é    )ÚannotationsN)Ú	dataclass)Ú	TypeAliasÚoverload)ÚModelProfile)ÚAsyncHTTPClientÚcreate_async_httpx2_client)Úmerge_profile)ÚAnthropicModelProfileÚanthropic_model_profile)ÚProviderÚmissing_api_key_error)Úsplit_bedrock_model_idé   )Ú
JsonSchemaÚJsonSchemaTransformer)ÚAsyncAnthropicÚAsyncAnthropicBedrockÚAsyncAnthropicBedrockMantleÚAsyncAnthropicFoundryÚAsyncAnthropicVertexu    Please install the `anthropic` package to use the Anthropic provider, you can use the `anthropic` optional group â€” `pip install "pydantic-ai-slim[anthropic]"`r   ÚAsyncAnthropicClient)zclaude-fable-5zclaude-mythos-5zclaude-opus-4-8zclaude-opus-5c                  óæ   • \ rS rSrSr\SS j5       r\SS j5       r\SS j5       r\	SS j5       r
\SS.SS	 jj5       r\SSSS
.       SS jj5       rSSSSS.         SS jjrSS jrSrg)ÚAnthropicProvideréL   zProvider for Anthropic API.c                ó   • g)NÚ	anthropic© ©Úselfs    Ú\/home/mande/repo/quber/.venv/lib/python3.13/site-packages/pydantic_ai/providers/anthropic.pyÚnameÚAnthropicProvider.nameO   s   € àó    c                ó@   • [        U R                  R                  5      $ ©N)ÚstrÚ_clientÚbase_urlr   s    r!   r)   ÚAnthropicProvider.base_urlS   s   € ä�4—<‘<×(Ñ(Ó)Ð)r$   c                ó   • U R                   $ r&   )r(   r   s    r!   ÚclientÚAnthropicProvider.clientW   s   € à�|‰|Ðr$   c           	     ó  • [        U 5      u  pUS:X  a  Un [        U 5      n[        [        [        S9U[        U R                  [        5      S9U R                  [        5      (       a  [        SS95      $ [        5       5      $ )Nr   )Újson_schema_transformer)Úsupports_inline_system_promptsÚby_reference)Útool_addition_mode)r   r   r
   r   ÚAnthropicJsonSchemaTransformerÚ
startswithÚ$_INLINE_SYSTEM_PROMPT_MODEL_PREFIXESÚ'_TOOL_AVAILABILITY_DELTA_MODEL_PREFIXES)Ú
model_nameÚbedrock_providerÚbase_model_nameÚprofiles       r!   Úmodel_profileÚAnthropicProvider.model_profile[   sŒ   € ô -CÀ:Ó,NÑ)ÐØ˜{Ó*Ø(ˆJÜ)¨*Ó5ˆÜÜ!Ô:XÑYØô "Ø/9×/DÑ/DÔEiÓ/jñð ×$Ñ$Ô%L×MÑMô "°^ÑDó
ð 	
ô 'Ó(ó
ð 	
r$   N)Úanthropic_clientc               ó   • g r&   r   )r    r=   s     r!   Ú__init__ÚAnthropicProvider.__init__w   s   € ØY\r$   ©Úapi_keyr)   Úhttp_clientc               ó   • g r&   r   )r    rB   r)   rC   s       r!   r?   r@   z   s   € ð r$   )rB   r)   r=   rC   c               ó  • Ub  Ub   S5       eUb   S5       eX0l         gU=(       d    [        R                  " S5      nU(       d  [        S5      eUb  [	        XUS9U l         g[        5       nX@l        [
        U l        [	        XUS9U l         g)añ  Create a new Anthropic provider.

Args:
    api_key: The API key to use for authentication, if not provided, the `ANTHROPIC_API_KEY` environment variable
        will be used if available.
    base_url: The base URL to use for the Anthropic API.
    anthropic_client: An existing Anthropic client to use. Accepts
        [`AsyncAnthropic`](https://github.com/anthropics/anthropic-sdk-python),
        [`AsyncAnthropicBedrock`](https://platform.claude.com/docs/en/build-with-claude/claude-on-amazon-bedrock-legacy),
        [`AsyncAnthropicBedrockMantle`](https://platform.claude.com/docs/en/build-with-claude/claude-in-amazon-bedrock),
        [`AsyncAnthropicFoundry`](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry), or
        [`AsyncAnthropicVertex`](https://docs.anthropic.com/en/api/claude-on-vertex-ai).
        If provided, the `api_key` and `http_client` arguments will be ignored.
    http_client: An existing `httpx2.AsyncClient` to use for making HTTP requests.
Nz8Cannot provide both `anthropic_client` and `http_client`z4Cannot provide both `anthropic_client` and `api_key`ÚANTHROPIC_API_KEYzSet the `ANTHROPIC_API_KEY` environment variable or pass it via `AnthropicProvider(api_key=...)` to use the Anthropic provider.rA   )r(   ÚosÚgetenvr   r   r	   Ú_own_http_clientÚ_http_client_factory)r    rB   r)   r=   rC   s        r!   r?   r@   ƒ   s–   € ð. Ñ'ØÑ&ÐbÐ(bÓbÐ&Ø‘?ÐZÐ$ZÓZ�?Ø+�Là×?¤§¢Ð+>Ó!?ˆGÞÜ+ð6óð ð Ñ&Ü-°gÐ^iÑj�•ä8Ó:�Ø(3Ô%Ü,F�Ô)Ü-°gÐ^iÑj�•r$   c                óf   • [        U[        R                  5      (       d   eXR                  l        g r&   )Ú
isinstanceÚhttpx2ÚAsyncClientr(   )r    rC   s     r!   Ú_set_http_clientÚ"AnthropicProvider._set_http_client­   s%   € Ü˜+¤v×'9Ñ'9×:Ñ:Ð:Ð:Ø*�‰Õr$   )r(   rJ   rI   )Úreturnr'   )rQ   r   )r7   r'   rQ   zModelProfile | None)r=   úAsyncAnthropicClient | NonerQ   ÚNone)rB   ú
str | Noner)   rT   rC   úhttpx2.AsyncClient | NonerQ   rS   )
rB   rT   r)   rT   r=   rR   rC   rU   rQ   rS   )rC   r   rQ   rS   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Úpropertyr"   r)   r,   Ústaticmethodr;   r   r?   rO   Ú__static_attributes__r   r$   r!   r   r   L   sü   † Ù%àóó ðð ó*ó ð*ð óó ðð ó
ó ð
ð6 ØJNÖ\ó Ø\àð #Ø#Ø15ñð ðð ð	ð
 /ðð 
ôó ðð #Ø#Ø8<Ø15ñ(kð ð(kð ð	(kð
 6ð(kð /ð(kð 
õ(k÷T+r$   r   F)Úinitc                  óJ   ^ • \ rS rSrSrSU 4S jjrSU 4S jjrSS jrSrU =r	$ )	r3   é²   aH  Transforms schemas to the subset supported by Anthropic structured outputs.

Transformation is applied when:
- `NativeOutput` is used as the `output_type` of the Agent
- `strict=True` is set on the `Tool`

The behavior of this transformer differs from the OpenAI one in that it sets `Tool.strict=False` by default when not explicitly set to True.

Example:
    ```python
    from pydantic_ai import Agent

    agent = Agent('anthropic:claude-sonnet-4-6')

    @agent.tool_plain  # -> defaults to strict=False
    def my_tool(x: str) -> dict[str, int]:
        ...
    ```

Anthropic's SDK `transform_schema()` automatically:
- Adds `additionalProperties: false` to all objects (required by API)
- Removes unsupported constraints (minLength, pattern, etc.)
- Moves removed constraints to description field
- Removes title and $schema fields
c                ó„   >• [         TU ]  5       nU R                  SL U l        U R                  SL a  SSKJn  U" U5      $ U$ )NTr   )Útransform_schema)ÚsuperÚwalkÚstrictÚis_strict_compatibler   rb   )r    Úschemarb   Ú	__class__s      €r!   rd   Ú#AnthropicJsonSchemaTransformer.walkÎ   s@   ø€ Ü‘‘“ˆð %)§K¡K°4Ð$7ˆÔ!à�;‰;˜$ÒÝ2á# FÓ+Ð+àˆMr$   c                óÐ   >• [         TU ]  U5      nU R                  SL aF  UR                  S5      n[	        U[
        5      (       d  USL a  [        R                  " S[        5        U$ )NTÚadditionalPropertiesa—  `dict` fields are not supported by Anthropic in strict mode (including `NativeOutput`, which is automatically selected when thinking is enabled). Anthropic's schema transformation sets `additionalProperties` to `false`, which forces the model to return `{}`. Use a `list` of `tuple[str, str]`, or a `TypedDict` or `dataclass` with explicit `key` and `value` fields, or set `output_type=PromptedOutput(...)`.)	rc   Ú_handle_objectre   ÚgetrL   ÚdictÚwarningsÚwarnÚUserWarning)r    rg   Úadditional_propertiesrh   s      €r!   rl   Ú-AnthropicJsonSchemaTransformer._handle_objectà   sc   ø€ Ü‘Ñ'¨Ó/ˆØ�;‰;˜$ÒØ$*§J¡JÐ/EÓ$FÐ!ÜÐ/´×6Ñ6Ð:OÐSWÒ:WÜ—’ð@ô  ô	ð ˆr$   c                óN   • UR                  SS 5        UR                  SS 5        U$ )NÚtitlez$schema)Úpop)r    rg   s     r!   Ú	transformÚ(AnthropicJsonSchemaTransformer.transformñ   s#   € Ø�
‰
�7˜DÔ!Ø�
‰
�9˜dÔ#Øˆr$   )rf   )rQ   r   )rg   r   rQ   r   )
rV   rW   rX   rY   rZ   rd   rl   rw   r]   Ú__classcell__)rh   s   @r!   r3   r3   ²   s   ø† ñ÷4÷$÷"ò r$   r3   )+Ú
__future__r   Ú_annotationsrG   ro   Údataclassesr   Útypingr   r   Úpydantic_air   Úpydantic_ai._httpr   r	   Úpydantic_ai.profilesr
   Úpydantic_ai.profiles.anthropicr   r   Úpydantic_ai.providersr   r   Ú*pydantic_ai.providers._bedrock_model_namesr   Ú_json_schemar   r   r   r   r   r   r   r   ÚImportErrorÚ_import_errorrM   r   Ú__annotations__r5   r6   r   r3   r   r$   r!   Ú<module>rˆ      sä   ðÞ 2ã 	Û Ý !ß &å $ß IÝ .ß Yß AÝ Mç <ð÷õ ó ð Ð*Ñ*Ð-HÑHÐK`Ñ`ÐcwÑwð �ió ð(Ð $ðð+Ð 'ð	ôc+˜Ð!5Ñ6ô c+ñL �ÑôAÐ%:ó Aó ñAøðu ó Ù
ð	eóð ðûðús   ÁB ÂB3Â%	B.Â.B3