Ë
    ³Œjßo  ã                  ó”  — d dl mZ d dlmZmZ d dlmZ d dlmZ ddlm	Z	m
Z
mZ ddlmZ ddlmZmZmZmZmZmZmZ dd	lmZmZmZ dd
lmZ ddlmZmZ ddlm Z m!Z!m"Z"m#Z# ddl$m%Z%m&Z&m'Z'm(Z( ddl)m*Z*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1 ddgZ2 G d„ de«      Z3 G d„ de«      Z4 G d„ d«      Z5 G d„ d«      Z6 G d„ d«      Z7 G d„ d«      Z8y)é    )Úannotations)ÚListÚUnion)Údatetime)ÚLiteralé   )Úthread_query_paramsÚthread_stats_paramsÚthread_list_traces_params)Úhttpx)ÚBodyÚOmitÚQueryÚHeadersÚNotGivenÚomitÚ	not_given)Úpath_templateÚmaybe_transformÚasync_maybe_transform)Úcached_property)ÚSyncAPIResourceÚAsyncAPIResource)Úto_raw_response_wrapperÚto_streamed_response_wrapperÚasync_to_raw_response_wrapperÚ"async_to_streamed_response_wrapper)ÚSyncItemsCursorGetPaginationÚAsyncItemsCursorGetPaginationÚSyncItemsCursorPostPaginationÚAsyncItemsCursorPostPagination)ÚAsyncPaginatorÚmake_request_options)ÚThread)ÚThreadStats)ÚThreadTraceÚThreadsResourceÚAsyncThreadsResourcec                  ó
  — e Zd Zed
d„«       Zedd„«       Zeeeedddedœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zeeeeeeeeedddedœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z	edddedœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	„Z
y)r'   c                ó   — t        | «      S ©z™
        This property can be used as a prefix for any HTTP method call to return
        the raw response object instead of the parsed content.
        )ÚThreadsResourceWithRawResponse©Úselfs    úu/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/langsmith/_openapi_client/resources/threads.pyÚwith_raw_responsez!ThreadsResource.with_raw_response$   s   € ô .¨dÓ3Ð3ó    c                ó   — t        | «      S ©ze
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.
        )Ú$ThreadsResourceWithStreamingResponser-   s    r/   Úwith_streaming_responsez'ThreadsResource.with_streaming_response,   s   € ô
 4°DÓ9Ð9r1   N©ÚcursorÚfilterÚ	page_sizeÚselectsÚextra_headersÚextra_queryÚ
extra_bodyÚtimeoutc       	        óØ   — |st        d|›�«      ‚| j                  t        d|¬«      t        t           t        |||	|
t        |||||dœt        j                  «      ¬«      t        ¬«      S ©a  
        Retrieve all traces belonging to a specific thread within a project.

        Self-hosted deployments require LangSmith `v0.16` or later.

        Args:
          project_id: `project_id` is the tracing project UUID (required).

          cursor: `cursor` is the opaque string from a previous response's `next_cursor`. Omit on
              the first request; pass the returned cursor to fetch the next page.

          filter: `filter` narrows which traces are returned for this thread, using a LangSmith
              filter expression evaluated against each root trace run. For example: eq(status,
              "success") or has(tags, "production"). See
              https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language
              for syntax.

          page_size: `page_size` is the maximum number of traces to return in this response. Defaults
              to 20 when omitted; must be between 1 and 100 inclusive when set.

          selects: `selects` lists which properties to include on each returned trace (repeatable
              query parameter). Accepts any value of the `ThreadTraceSelectField` enum.
              Properties not listed are omitted from each trace object; `trace_id` is always
              returned.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        ú8Expected a non-empty value for `thread_id` but received z"/api/v2/threads/{thread_id}/traces©Ú	thread_id)Ú
project_idr7   r8   r9   r:   ©r;   r<   r=   r>   Úquery)ÚpageÚoptionsÚmodel)	Ú
ValueErrorÚ_get_api_listr   r   r&   r#   r   r   ÚThreadListTracesParams©r.   rC   rD   r7   r8   r9   r:   r;   r<   r=   r>   s              r/   Úlist_traceszThreadsResource.list_traces3   sˆ   € ñZ ÜÐWÐXaÐWdÐeÓfÐfØ×!Ñ!ÜÐ>È)ÔTÜ-¬kÑ:Ü(Ø+Ø'Ø%ØÜ%à&0Ø"(Ø"(Ø%.Ø#*ñô .×DÑDó	ôô  ð' "ó 
ð 	
r1   ©r7   r8   Úmax_start_timeÚmin_start_timer9   rD   Úthread_filterÚtrace_filterÚtree_filterr;   r<   r=   r>   c               ó¬   — | j                  dt        t           t        |||||||||	dœ	t        j
                  «      t        |
|||¬«      t        d¬«      S ©aÓ  Query threads within a project (session), with cursor-based pagination.

        Returns
        threads matching the given time range and optional filters.

        Self-hosted deployments require LangSmith `v0.16` or later.

        Args:
          cursor: `cursor` is the opaque string from a previous response's `next_cursor`. Omit on
              the first request; pass the returned cursor to fetch the next page.

          filter: `filter` narrows which threads are returned, using a LangSmith filter expression
              evaluated against each thread's root run. For example: has(tags, "production")
              or eq(status, "error"). See
              https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language
              for syntax.

          max_start_time: `max_start_time` is the exclusive upper bound on thread activity (RFC3339
              date-time). Defaults to now (UTC) when omitted.

          min_start_time: `min_start_time` is the inclusive lower bound on thread activity (RFC3339
              date-time). Defaults to 1 day before now (UTC) when omitted.

          page_size: `page_size` is the maximum number of threads to return in this response.
              Defaults to 20 when omitted; must be between 1 and 100 inclusive when set. The
              response may contain fewer threads than `page_size` even when `next_cursor` is
              non-null.

          project_id: `project_id` is the tracing project UUID.

          thread_filter: `thread_filter` narrows results using a LangSmith filter expression evaluated
              against each complete thread summary. Self-hosted deployments require LangSmith
              v0.17 or later; unsupported deployments return 501. See
              https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language
              for syntax.

          trace_filter: `trace_filter` narrows results to threads containing at least one trace whose
              root run matches this LangSmith filter expression. Trace-level aggregate fields
              are evaluated using the complete trace summary. Self-hosted deployments require
              LangSmith v0.17 or later; unsupported deployments return 501. See
              https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language
              for syntax.

          tree_filter: `tree_filter` narrows results to threads containing at least one trace with a
              matching run anywhere in its run tree. Self-hosted deployments require LangSmith
              v0.17 or later; unsupported deployments return 501. See
              https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language
              for syntax.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        z/api/v2/threads/query)	r7   r8   rP   rQ   r9   rD   rR   rS   rT   )r;   r<   r=   r>   Úpost)rG   ÚbodyrH   rI   Úmethod)rK   r    r$   r   r	   ÚThreadQueryParamsr#   ©r.   r7   r8   rP   rQ   r9   rD   rR   rS   rT   r;   r<   r=   r>   s                 r/   rF   zThreadsResource.query˜   sx   € ðX ×!Ñ!Ø#Ü.¬vÑ6Ü à$Ø$Ø&4Ø&4Ø!*Ø",Ø%2Ø$0Ø#.ñ
ô $×5Ñ5óô )Ø+¸ÐQ[Ðelôô Øð+ "ó 
ð 	
r1   ©r8   r;   r<   r=   r>   c               ó¼   — |st        d|›�«      ‚| j                  t        d|¬«      t        ||||t	        |||dœt
        j                  «      ¬«      t        ¬«      S )á¶  
        Compute aggregate stats for a single thread (turn count, latency percentiles,
        token/cost sums, and detail breakdowns) within a project.

        Self-hosted deployments require LangSmith `v0.16` or later.

        Args:
          selects: `selects` lists which aggregate stats to compute and return (repeatable query
              parameter). At least one value is required. Accepts any value of
              `SingleThreadStatsSelectField`.

          session_id: `session_id` is the tracing project (session) UUID (required).

          filter: `filter` narrows which of the thread's traces are aggregated, using a LangSmith
              filter expression. For example: lt(start_time, "2025-01-01T00:00:00Z") or
              eq(trace_id, "0190a1b2-c3d4-7ef0-a5b6-6ea3a82e9328"). See
              https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language
              for syntax.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        rA   ú!/api/v2/threads/{thread_id}/statsrB   ©r:   Ú
session_idr8   rE   ©rH   Úcast_to)rJ   Ú_getr   r#   r   r
   ÚThreadStatsParamsr%   ©	r.   rC   r:   ra   r8   r;   r<   r=   r>   s	            r/   ÚstatszThreadsResource.statsü   sx   € ñz ÜÐWÐXaÐWdÐeÓfÐfØ�y‰yÜÐ=ÈÔSÜ(Ø+Ø'Ø%ØÜ%à#*Ø&0Ø"(ñô
 (×9Ñ9óôô  ð! ó 
ð 	
r1   )Úreturnr,   )rh   r4   )rC   ÚstrrD   ri   r7   ú
str | Omitr8   rj   r9   ú
int | Omitr:   á”  List[Literal['THREAD_ID', 'TRACE_ID', 'OP', 'PROMPT_TOKENS', 'COMPLETION_TOKENS', 'TOTAL_TOKENS', 'START_TIME', 'END_TIME', 'LATENCY', 'FIRST_TOKEN_TIME', 'INPUTS_PREVIEW', 'OUTPUTS_PREVIEW', 'INPUTS', 'OUTPUTS', 'ERROR', 'PROMPT_COST', 'COMPLETION_COST', 'TOTAL_COST', 'PROMPT_TOKEN_DETAILS', 'COMPLETION_TOKEN_DETAILS', 'PROMPT_COST_DETAILS', 'COMPLETION_COST_DETAILS', 'NAME', 'ERROR_PREVIEW']] | Omitr;   úHeaders | Noner<   úQuery | Noner=   úBody | Noner>   ú'float | httpx.Timeout | None | NotGivenrh   z)SyncItemsCursorGetPagination[ThreadTrace])r7   rj   r8   rj   rP   úUnion[str, datetime] | OmitrQ   rq   r9   rk   rD   rj   rR   rj   rS   rj   rT   rj   r;   rm   r<   rn   r=   ro   r>   rp   rh   z%SyncItemsCursorPostPagination[Thread]©rC   ri   r:   aJ  List[Literal['TURNS', 'FIRST_START_TIME', 'LAST_START_TIME', 'LAST_END_TIME', 'LATENCY_P50', 'LATENCY_P99', 'PROMPT_TOKENS', 'PROMPT_COST', 'COMPLETION_TOKENS', 'COMPLETION_COST', 'TOTAL_TOKENS', 'TOTAL_COST', 'PROMPT_TOKEN_DETAILS', 'COMPLETION_TOKEN_DETAILS', 'PROMPT_COST_DETAILS', 'COMPLETION_COST_DETAILS', 'FEEDBACK_STATS']]ra   ri   r8   rj   r;   rm   r<   rn   r=   ro   r>   rp   rh   r%   ©Ú__name__Ú
__module__Ú__qualname__r   r0   r5   r   r   rN   rF   rg   © r1   r/   r'   r'   #   s  „ Øò4ó ð4ð ò:ó ð:ð "Ø!Ø $ð: ð )-Ø$(Ø"&Ø;DñUc
àðc
ð ð	c
ð
 ðc
ð ðc
ð ðc
ððc
ðN &ðOc
ðP "ðQc
ðR  ðSc
ðT 9ðUc
ðV 
3óWc
ðP "Ø!Ø6:Ø6:Ø $Ø!%Ø$(Ø#'Ø"&ð )-Ø$(Ø"&Ø;Dñ#b
ð ðb
ð ð	b
ð
 4ðb
ð 4ðb
ð ðb
ð ðb
ð "ðb
ð !ðb
ð  ðb
ð &ðb
ð "ðb
ð   ð!b
ð" 9ð#b
ð$ 
/ó%b
ð| "ð )-Ø$(Ø"&Ø;DñAP
àðP
ð
ð	P
ð2 ð3P
ð4 ð5P
ð: &ð;P
ð< "ð=P
ð>  ð?P
ð@ 9ðAP
ðB 
ôCP
r1   c                  ó
  — e Zd Zed
d„«       Zedd„«       Zeeeedddedœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zeeeeeeeeedddedœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Z	edddedœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd	„Z
y)r(   c                ó   — t        | «      S r+   )Ú#AsyncThreadsResourceWithRawResponser-   s    r/   r0   z&AsyncThreadsResource.with_raw_responseP  s   € ô 3°4Ó8Ð8r1   c                ó   — t        | «      S r3   )Ú)AsyncThreadsResourceWithStreamingResponser-   s    r/   r5   z,AsyncThreadsResource.with_streaming_responseX  s   € ô
 9¸Ó>Ð>r1   Nr6   c       	        óØ   — |st        d|›�«      ‚| j                  t        d|¬«      t        t           t        |||	|
t        |||||dœt        j                  «      ¬«      t        ¬«      S r@   )	rJ   rK   r   r   r&   r#   r   r   rL   rM   s              r/   rN   z AsyncThreadsResource.list_traces_  sˆ   € ñZ ÜÐWÐXaÐWdÐeÓfÐfØ×!Ñ!ÜÐ>È)ÔTÜ.¬{Ñ;Ü(Ø+Ø'Ø%ØÜ%à&0Ø"(Ø"(Ø%.Ø#*ñô .×DÑDó	ôô  ð' "ó 
ð 	
r1   rO   c               ó¬   — | j                  dt        t           t        |||||||||	dœ	t        j
                  «      t        |
|||¬«      t        d¬«      S rV   )rK   r!   r$   r   r	   rZ   r#   r[   s                 r/   rF   zAsyncThreadsResource.queryÄ  sx   € ðX ×!Ñ!Ø#Ü/´Ñ7Ü à$Ø$Ø&4Ø&4Ø!*Ø",Ø%2Ø$0Ø#.ñ
ô $×5Ñ5óô )Ø+¸ÐQ[Ðelôô Øð+ "ó 
ð 	
r1   r\   c             ƒ  óì   K  — |st        d|›�«      ‚| j                  t        d|¬«      t        ||||t	        |||dœt
        j                  «      ƒ d{  –—† ¬«      t        ¬«      ƒ d{  –—† S 7 Œ7 Œ­w)r^   rA   r_   rB   r`   NrE   rb   )rJ   rd   r   r#   r   r
   re   r%   rf   s	            r/   rg   zAsyncThreadsResource.stats(  s‘   è ø€ ñz ÜÐWÐXaÐWdÐeÓfÐfØ—Y‘YÜÐ=ÈÔSÜ(Ø+Ø'Ø%ØÜ1à#*Ø&0Ø"(ñô
 (×9Ñ9ó÷ ôô  ð! ó 
÷ 
ð 	
ðøð
ús$   ‚AA4ÁA0ÁA4Á+A2Á,A4Á2A4)rh   rz   )rh   r|   )rC   ri   rD   ri   r7   rj   r8   rj   r9   rk   r:   rl   r;   rm   r<   rn   r=   ro   r>   rp   rh   zGAsyncPaginator[ThreadTrace, AsyncItemsCursorGetPagination[ThreadTrace]])r7   rj   r8   rj   rP   rq   rQ   rq   r9   rk   rD   rj   rR   rj   rS   rj   rT   rj   r;   rm   r<   rn   r=   ro   r>   rp   rh   z>AsyncPaginator[Thread, AsyncItemsCursorPostPagination[Thread]]rr   rs   rw   r1   r/   r(   r(   O  s  „ Øò9ó ð9ð ò?ó ð?ð "Ø!Ø $ð: ð )-Ø$(Ø"&Ø;DñUc
àðc
ð ð	c
ð
 ðc
ð ðc
ð ðc
ððc
ðN &ðOc
ðP "ðQc
ðR  ðSc
ðT 9ðUc
ðV 
QóWc
ðP "Ø!Ø6:Ø6:Ø $Ø!%Ø$(Ø#'Ø"&ð )-Ø$(Ø"&Ø;Dñ#b
ð ðb
ð ð	b
ð
 4ðb
ð 4ðb
ð ðb
ð ðb
ð "ðb
ð !ðb
ð  ðb
ð &ðb
ð "ðb
ð   ð!b
ð" 9ð#b
ð$ 
Hó%b
ð| "ð )-Ø$(Ø"&Ø;DñAP
àðP
ð
ð	P
ð2 ð3P
ð4 ð5P
ð: &ð;P
ð< "ð=P
ð>  ð?P
ð@ 9ðAP
ðB 
ôCP
r1   c                  ó   — e Zd Zdd„Zy)r,   c                ó®   — || _         t        |j                  «      | _        t        |j                  «      | _        t        |j                  «      | _        y ©N)Ú_threadsr   rN   rF   rg   ©r.   Úthreadss     r/   Ú__init__z'ThreadsResourceWithRawResponse.__init__|  sI   € ØˆŒä2Ø×Ñó
ˆÔô -Ø�M‰Mó
ˆŒ
ô -Ø�M‰Mó
ˆ�
r1   N©r…   r'   rh   ÚNone©rt   ru   rv   r†   rw   r1   r/   r,   r,   {  ó   „ ô
r1   r,   c                  ó   — e Zd Zdd„Zy)rz   c                ó®   — || _         t        |j                  «      | _        t        |j                  «      | _        t        |j                  «      | _        y r‚   )rƒ   r   rN   rF   rg   r„   s     r/   r†   z,AsyncThreadsResourceWithRawResponse.__init__‹  sI   € ØˆŒä8Ø×Ñó
ˆÔô 3Ø�M‰Mó
ˆŒ
ô 3Ø�M‰Mó
ˆ�
r1   N©r…   r(   rh   rˆ   r‰   rw   r1   r/   rz   rz   Š  rŠ   r1   rz   c                  ó   — e Zd Zdd„Zy)r4   c                ó®   — || _         t        |j                  «      | _        t        |j                  «      | _        t        |j                  «      | _        y r‚   )rƒ   r   rN   rF   rg   r„   s     r/   r†   z-ThreadsResourceWithStreamingResponse.__init__š  sI   € ØˆŒä7Ø×Ñó
ˆÔô 2Ø�M‰Mó
ˆŒ
ô 2Ø�M‰Mó
ˆ�
r1   Nr‡   r‰   rw   r1   r/   r4   r4   ™  rŠ   r1   r4   c                  ó   — e Zd Zdd„Zy)r|   c                ó®   — || _         t        |j                  «      | _        t        |j                  «      | _        t        |j                  «      | _        y r‚   )rƒ   r   rN   rF   rg   r„   s     r/   r†   z2AsyncThreadsResourceWithStreamingResponse.__init__©  sI   € ØˆŒä=Ø×Ñó
ˆÔô 8Ø�M‰Mó
ˆŒ
ô 8Ø�M‰Mó
ˆ�
r1   Nr�   r‰   rw   r1   r/   r|   r|   ¨  rŠ   r1   r|   N)9Ú
__future__r   Útypingr   r   r   Útyping_extensionsr   Útypesr	   r
   r   Ú_httpxr   Ú_typesr   r   r   r   r   r   r   Ú_utilsr   r   r   Ú_compatr   Ú	_resourcer   r   Ú	_responser   r   r   r   Ú
paginationr   r   r    r!   Ú_base_clientr"   r#   Útypes.threadr$   Útypes.thread_statsr%   Útypes.thread_tracer&   Ú__all__r'   r(   r,   rz   r4   r|   rw   r1   r/   Ú<module>r¢      s¦   ðõ #ç Ý Ý %ç WÑ WÝ ß J× JÑ Jß JÑ JÝ %ß 9÷ó ÷ó ÷ @Ý !Ý ,Ý ,àÐ4Ð
5€ôi
�oô i
ôX	i
Ð+ô i
÷X	
ñ 
÷
ñ 
÷
ñ 
÷
ò 
r1   