L iYddlmZddlZddlmZmZmZddlmZm Z ddl Z ddl m Z m Z ddlmZddlmZmZmZmZmZmZmZmZdd lmZmZdd lmZdd lmZdd l m!Z!m"Z"dd l m#Z#ddl$m%Z%m&Z&m'Z'er,ddl(m)Z)m*Z*m+Z+m,Z,ddl-m.Z.m/Z/ddl0m1Z1m2Z2ddl3m4Z4m5Z5ddl6m7Z7m8Z8gdZ9Gdde&Z:Gdde'Z;GddZ<GddZ=GddZ>Gdd Z?e:Z@e;ZAy)!) annotationsN) TYPE_CHECKINGAnyMapping)Selfoverride) _constants _exceptions Querystring)OmitHeadersTimeoutNotGiven Transport ProxiesTypesRequestOptions not_given)is_givenget_async_library)cached_property) __version__)Stream AsyncStream)APIStatusError)DEFAULT_MAX_RETRIES SyncAPIClientAsyncAPIClient)betamodelsmessages completions)Models AsyncModels)Beta AsyncBeta) CompletionsAsyncCompletions)Messages AsyncMessages)rrrr AnthropicAsyncAnthropicClient AsyncClientc eZdZUded<ded<ej Zej Zdddeeddddd dfdZ e ddZ e dd Z e dd Z e dd Ze dd Ze dd ZeeddZeeddZeddZeddZeed fd Zed!dZdddededdddid d"dZeZe d#dZxZS)$r, str | Noneapi_key auth_tokenNF r2r3base_urltimeout max_retriesdefault_headers default_query http_client_strict_response_validationc <|tjjd}||_|tjjd}||_|tjjd}|d}t |t||||||| t|_ y)a#Construct a new synchronous Anthropic client instance. This automatically infers the following arguments from their corresponding environment variables if they are not provided: - `api_key` from `ANTHROPIC_API_KEY` - `auth_token` from `ANTHROPIC_AUTH_TOKEN` NANTHROPIC_API_KEYANTHROPIC_AUTH_TOKENANTHROPIC_BASE_URLhttps://api.anthropic.comversionr5r7r6r:custom_headers custom_queryr;) osenvirongetr2r3super__init__rr_default_stream_cls selfr2r3r5r6r7r8r9r:r; __class__s W/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/anthropic/_client.pyrIzAnthropic.__init__>s< ?jjnn%89G  (>?J$  zz~~&:;H  2H ##*&(C  $* cddlm}||S)Nr )r()resources.completionsr()rLr(s rNr#zAnthropic.completionsvs64  rOcddlm}||S)Nr )r*)resources.messagesr*)rLr*s rNr"zAnthropic.messages|s0~rOcddlm}||S)Nr )r$)resources.modelsr$)rLr$s rNr!zAnthropic.modelss,d|rOcddlm}||S)Nr )r&)resources.betar&)rLr&s rNr zAnthropic.betas(DzrOct|SN)AnthropicWithRawResponserLs rNwith_raw_responsezAnthropic.with_raw_responses '--rOct|SrY)AnthropicWithStreamedResponser[s rNwith_streaming_responsez!Anthropic.with_streaming_response ,T22rOctdSNcomma) array_formatr r[s rNqsz Anthropic.qs00rOc6i|j|jSrY _api_key_auth _bearer_authr[s rN auth_headerszAnthropic.auth_headers ;$$$:(9(9::rOc*|j}|iSd|iSN X-Api-Keyr2rLr2s rNrizAnthropic._api_key_auth ,, ?IW%%rOc0|j}|iSdd|iSN AuthorizationzBearer r3rLr3s rNrjzAnthropic._bearer_auth(__  I7:,!788rOc>it|ddd|jS)Nfalse 2023-06-01zX-Stainless-Asynczanthropic-version)rHr8_custom_headersrLrMs rNr8zAnthropic.default_headerss5 g% !(!- ""   rOcV|jds|jdry|jr|jdryt|jdtry|jr|jdryt|jdtryt dNruroz"Could not resolve authentication method. Expected either api_key or auth_token to be set. Or for one of the `X-Api-Key` or `Authorization` headers to be explicitly omitted"rGr2 isinstancerr3 TypeErrorrLheadersrCs rN_validate_headerszAnthropic._validate_headers ;; '7;;{+C  <+Jop p  $):)Fkl l&&  &44O4G ,)G##  $00-0F  *&F!1T\\ t~~  +t||!4T__.$.w$ADLLw#'/ '< $BRBR#     rOc*|jdk(rtj|||S|jdk(rtj|||S|jdk(rtj|||S|jdk(rtj |||S|jdk(rtj |||S|jdk(rtj|||S|jdk(rtj|||S|jd k(rtj|||S|jd k(rtj|||S|jd k\rtj|||St|||S) Nresponsebodyii) status_coder BadRequestErrorAuthenticationErrorPermissionDeniedError NotFoundError ConflictErrorRequestTooLargeErrorUnprocessableEntityErrorRateLimitErrorOverloadedErrorInternalServerErrorrrLerr_msgrrs rN_make_status_errorzAnthropic._make_status_errorsx   3 &..wPTU U   3 &227XTXY Y   3 &44WxVZ[ [   3 &,,WxdS S   3 &,,WxdS S   3 &33GhUYZ Z   3 &77(Y]^ ^   3 &--gtT T   3 &..wPTU U   3 &227XTXY YgtDDrO)r2r1r3r1r5str | httpx.URL | Noner6!float | Timeout | None | NotGivenr7intr8Mapping[str, str] | Noner9Mapping[str, object] | Noner:httpx.Client | Noner;boolreturnNone)rr()rr*)rr$)rr&)rrZ)rr^rr rzdict[str, str]rzdict[str, str | Omit]rrrCrrr)r2r1r3r1r5rr6rr:rr7int | NotGivenr8rrrr9rrrrMapping[str, Any]rrrstrrobjectrzhttpx.Responserr__name__ __module__ __qualname____annotations__r HUMAN_PROMPT AI_PROMPTrrrIrr#r"r!r r\r_propertyrrerkrirjr8rr with_optionsr __classcell__rMs@rNr,r,5s **L$$I #!%+/5>.4859,0-2-6*6* 6* ) 6* 3 6*6*26*36*)6*,&*-6*. /6*p!!    ..33 11 ;;&& 99      ,#!%+/5>+/&/488<599=+-/ /  / ) / 3 / )/ $/ 2/ 6/ 3/ 7/ )/  / fL $E$E $E ! $E  $E$ErOr,c eZdZUded<ded<ej Zej Zdddeeddddd dfdZ e ddZ e dd Z e dd Z e dd Ze dd Ze dd ZeeddZeeddZeddZeddZeed fd Zed!dZdddededdddid d"dZeZe d#dZxZS)$r-r1r2r3NFr4c <|tjjd}||_|tjjd}||_|tjjd}|d}t |t||||||| t|_ y)a"Construct a new async AsyncAnthropic client instance. This automatically infers the following arguments from their corresponding environment variables if they are not provided: - `api_key` from `ANTHROPIC_API_KEY` - `auth_token` from `ANTHROPIC_AUTH_TOKEN` Nr=r>r?r@rA) rErFrGr2r3rHrIrrrJrKs rNrIzAsyncAnthropic.__init__2s< ?jjnn%89G  (>?J$  zz~~&:;H  2H ##*&(C  $/ rOcddlm}||S)Nr )r))rQr))rLr)s rNr#zAsyncAnthropic.completionsjs;%%rOcddlm}||S)Nr )r+)rSr+)rLr+s rNr"zAsyncAnthropic.messagesps5T""rOcddlm}||S)Nr )r%)rUr%)rLr%s rNr!zAsyncAnthropic.modelsvs14  rOcddlm}||S)Nr )r')rWr')rLr's rNr zAsyncAnthropic.beta|s-rOct|SrY)AsyncAnthropicWithRawResponser[s rNr\z AsyncAnthropic.with_raw_responser`rOct|SrY)"AsyncAnthropicWithStreamedResponser[s rNr_z&AsyncAnthropic.with_streaming_responses 1$77rOctdSrbr r[s rNrezAsyncAnthropic.qsrfrOc6i|j|jSrYrhr[s rNrkzAsyncAnthropic.auth_headersrlrOc*|j}|iSd|iSrnrprqs rNrizAsyncAnthropic._api_key_authrrrOc0|j}|iSdd|iSrtrvrws rNrjzAsyncAnthropic._bearer_authrxrOcTit|dtdd|jS)Nzasync:r{r|)rHr8rr}r~s rNr8zAsyncAnthropic.default_headerssA g% #)*;*=)>!?!- ""   rOcV|jds|jdry|jr|jdryt|jdtry|jr|jdryt|jdtryt drrrs rNrz AsyncAnthropic._validate_headersrrOrc | | td| | td|j} |i| |} n||} |j} | i| | } n| | } |xs |j}|jd|xs |j |xs |j |xs |jt|tr |jn||t|r|n |j| | d| Srrrs rNrzAsyncAnthropic.copyrrOc|jdk(rtj|||S|jdk(rtj|||S|jdk(rtj|||S|jdk(rtj |||S|jdk(rtj |||S|jdk(rtj|||S|jdk(rtj|||S|jd k\rtj|||St|||S) Nrrrrrrrrr) rr rrrrrrrrrrs rNrz!AsyncAnthropic._make_status_errors0   3 &..wPTU U   3 &227XTXY Y   3 &44WxVZ[ [   3 &,,WxdS S   3 &,,WxdS S   3 &77(Y]^ ^   3 &--gtT T   3 &227XTXY YgtDDrO)r2r1r3r1r5rr6rr7rr8rr9rr:httpx.AsyncClient | Noner;rrr)rr))rr+)rr%)rr')rr)rrrrrr)r2r1r3r1r5rr6rr:rr7rr8rrrr9rrrrrrrrrrs@rNr-r-)s **L$$I #!%+/5>.485915-2-6/6/ 6/ ) 6/ 3 6/6/26/36/.6/,&*-6/. /6/p&& ## !!  3388 11 ;;&& 99      ,#!%+/5>04&/488<599=+-/ /  / ) / 3 / ./ $/ 2/ 6/ 3/ 7/ )/  / fL EE E ! E  EErOr-cheZdZUded<d dZed dZed dZed dZed dZ y)rZr,rc||_yrYrrLclients rNrIz!AnthropicWithRawResponse.__init__  rOcFddlm}||jjS)Nr )CompletionsWithRawResponse)rQrrr#)rLrs rNr#z$AnthropicWithRawResponse.completionssE)$,,*B*BCCrOcFddlm}||jjS)Nr )MessagesWithRawResponse)rSrrr")rLrs rNr"z!AnthropicWithRawResponse.messages#s?&t||'<'<==rOcFddlm}||jjS)Nr )ModelsWithRawResponse)rUrrr!)rLrs rNr!zAnthropicWithRawResponse.models)s;$T\\%8%899rOcFddlm}||jjS)Nr )BetaWithRawResponse)rWrrr )rLrs rNr zAnthropicWithRawResponse.beta/s7"4<<#4#455rONrr,rr)rz&completions.CompletionsWithRawResponse)rz messages.MessagesWithRawResponse)rzmodels.ModelsWithRawResponse)rzbeta.BetaWithRawResponse rrrrrIrr#r"r!r rrOrNrZrZs_ DD >> :: 66rOrZcheZdZUded<d dZed dZed dZed dZed dZ y)rr-rc||_yrYrrs rNrIz&AsyncAnthropicWithRawResponse.__init__9rrOcFddlm}||jjS)Nr )AsyncCompletionsWithRawResponse)rQrrr#)rLrs rNr#z)AsyncAnthropicWithRawResponse.completions<sJ.t||/G/GHHrOcFddlm}||jjS)Nr )AsyncMessagesWithRawResponse)rSrrr")rLrs rNr"z&AsyncAnthropicWithRawResponse.messagesBsD+DLL,A,ABBrOcFddlm}||jjS)Nr )AsyncModelsWithRawResponse)rUrrr!)rLrs rNr!z$AsyncAnthropicWithRawResponse.modelsHs@)$,,*=*=>>rOcFddlm}||jjS)Nr )AsyncBetaWithRawResponse)rWrrr )rLrs rNr z"AsyncAnthropicWithRawResponse.betaNs<' (9(9::rONrr-rr)rz+completions.AsyncCompletionsWithRawResponse)rz%messages.AsyncMessagesWithRawResponse)rz!models.AsyncModelsWithRawResponse)rzbeta.AsyncBetaWithRawResponserrrOrNrr6sa II CC ?? ;;rOrcheZdZUded<d dZed dZed dZed dZed dZ y)r^r,rc||_yrYrrs rNrIz&AnthropicWithStreamedResponse.__init__XrrOcFddlm}||jjS)Nr ) CompletionsWithStreamingResponse)rQrrr#)rLrs rNr#z)AnthropicWithStreamedResponse.completions[sK/ 0H0HIIrOcFddlm}||jjS)Nr )MessagesWithStreamingResponse)rSrrr")rLrs rNr"z&AnthropicWithStreamedResponse.messagesasE,T\\-B-BCCrOcFddlm}||jjS)Nr )ModelsWithStreamingResponse)rUrrr!)rLrs rNr!z$AnthropicWithStreamedResponse.modelsgsA*4<<+>+>??rOcFddlm}||jjS)Nr )BetaWithStreamingResponse)rWrrr )rLrs rNr z"AnthropicWithStreamedResponse.betams=():):;;rONr)rz,completions.CompletionsWithStreamingResponse)rz&messages.MessagesWithStreamingResponse)rz"models.ModelsWithStreamingResponse)rzbeta.BetaWithStreamingResponserrrOrNr^r^Usc JJ DD @@ <r s# .., %   0$!D' >>54DD qE qEhkE^kE\66>;;><<>AA>  rO