§
    ~ŠtjÖc  ã                  ó¶  — 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Zddl	m
Z
mZ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l/m0Z0 ddgZ1 G d„ de¦  «        Z2 G d„ de¦  «        Z3 G d„ d¦  «        Z4 G d„ d¦  «        Z5 G d„ d¦  «        Z6 G d„ d¦  «        Z7dS )é    )Úannotations)ÚListÚUnion)Údatetime)ÚLiteralNé   )Úthread_query_paramsÚthread_stats_paramsÚthread_list_traces_params)Ú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dddedœ
d*d!„Z	eddded"œd+d&„Z
dS ),r&   ÚreturnÚThreadsResourceWithRawResponsec                ó    — 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.
        )r*   ©Úselfs    úi/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/langsmith/_openapi_client/resources/threads.pyÚwith_raw_responsez!ThreadsResource.with_raw_response%   s   € õ .¨dÑ3Ô3Ð3ó    Ú$ThreadsResourceWithStreamingResponsec                ó    — t          | ¦  «        S ©ze
        An alternative to `.with_raw_response` that doesn't eagerly read the response body.
        )r2   r-   s    r/   Úwith_streaming_responsez'ThreadsResource.with_streaming_response-   s   € õ
 4°DÑ9Ô9Ð9r1   N©ÚcursorÚfilterÚ	page_sizeÚselectsÚextra_headersÚextra_queryÚ
extra_bodyÚtimeoutÚ	thread_idÚstrÚ
project_idr7   ú
str | Omitr8   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 | NotGivenú)SyncItemsCursorGetPagination[ThreadTrace]c       	        ó  — |st          d|›�¦  «        ‚|                      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©r?   )rA   r7   r8   r9   r:   ©r;   r<   r=   r>   Úquery)ÚpageÚoptionsÚmodel)	Ú
ValueErrorÚ_get_api_listr   r   r%   r"   r   r   ÚThreadListTracesParams©r.   r?   rA   r7   r8   r9   r:   r;   r<   r=   r>   s              r/   Úlist_traceszThreadsResource.list_traces4   s­   € ðZ ð 	gÝÐeÐXaÐeÐeÑfÔfÐfØ×!Ò!ÝÐ>È)ÐTÑTÔTÝ-­kÔ:Ý(Ø+Ø'Ø%ØÝ%à&0Ø"(Ø"(Ø%.Ø#*ðð õ .ÔDñ	ô 	ðñ ô õ  ð' "ñ 
ô 
ð 	
r1   ©
r7   r8   Úmax_start_timeÚmin_start_timer9   rA   r;   r<   r=   r>   rY   úUnion[str, datetime] | OmitrZ   ú%SyncItemsCursorPostPagination[Thread]c       
        óÂ   — |                       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 filter.

        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.

          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   rY   rZ   r9   rA   )r;   r<   r=   r>   Úpost)rP   ÚbodyrQ   rR   Úmethod)rT   r   r#   r   r	   ÚThreadQueryParamsr"   ©r.   r7   r8   rY   rZ   r9   rA   r;   r<   r=   r>   s              r/   rO   zThreadsResource.query™   s…   € ðl ×!Ò!Ø#Ý.­vÔ6Ý à$Ø$Ø&4Ø&4Ø!*Ø",ðð õ $Ô5ñ
ô 
õ )Ø+¸ÐQ[Ðelðñ ô õ Øð% "ñ 
ô 
ð 	
r1   ©r8   r;   r<   r=   r>   áJ  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']]Ú
session_idr$   c               óÞ   — |st          d|›�¦  «        ‚|                      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
        rL   ú!/api/v2/threads/{thread_id}/statsrM   ©r:   rf   r8   rN   ©rQ   Úcast_to)rS   Ú_getr   r"   r   r
   ÚThreadStatsParamsr$   ©	r.   r?   r:   rf   r8   r;   r<   r=   r>   s	            r/   ÚstatszThreadsResource.statsä   s�   € ðz ð 	gÝÐeÐXaÐeÐeÑfÔfÐfØ�yŠyÝÐ=ÈÐSÑSÔSÝ(Ø+Ø'Ø%ØÝ%à#*Ø&0Ø"(ðð õ
 (Ô9ñô ðñ ô õ  ð! ñ 
ô 
ð 	
r1   )r)   r*   )r)   r2   )r?   r@   rA   r@   r7   rB   r8   rB   r9   rC   r:   rD   r;   rE   r<   rF   r=   rG   r>   rH   r)   rI   )r7   rB   r8   rB   rY   r[   rZ   r[   r9   rC   rA   rB   r;   rE   r<   rF   r=   rG   r>   rH   r)   r\   ©r?   r@   r:   re   rf   r@   r8   rB   r;   rE   r<   rF   r=   rG   r>   rH   r)   r$   ©Ú__name__Ú
__module__Ú__qualname__r   r0   r5   r   r   rW   rO   rp   © r1   r/   r&   r&   $   s  € € € € € Øð4ð 4ð 4ñ „_ð4ð ð:ð :ð :ñ „_ð:ð "Ø!Ø $ð: ð )-Ø$(Ø"&Ø;DðUc
ð c
ð c
ð c
ð c
ð c
ðP "Ø!Ø6:Ø6:Ø $Ø!%ð )-Ø$(Ø"&Ø;DðI
ð I
ð I
ð I
ð I
ð I
ðJ "ð )-Ø$(Ø"&Ø;DðAP
ð P
ð P
ð P
ð P
ð P
ð P
ð 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dddedœ
d*d!„Z	eddded"œd+d&„Z
dS ),r'   r)   Ú#AsyncThreadsResourceWithRawResponsec                ó    — t          | ¦  «        S r,   )rx   r-   s    r/   r0   z&AsyncThreadsResource.with_raw_response8  s   € õ 3°4Ñ8Ô8Ð8r1   Ú)AsyncThreadsResourceWithStreamingResponsec                ó    — t          | ¦  «        S r4   )rz   r-   s    r/   r5   z,AsyncThreadsResource.with_streaming_response@  s   € õ
 9¸Ñ>Ô>Ð>r1   Nr6   r?   r@   rA   r7   rB   r8   r9   rC   r:   rD   r;   rE   r<   rF   r=   rG   r>   rH   úGAsyncPaginator[ThreadTrace, AsyncItemsCursorGetPagination[ThreadTrace]]c       	        ó  — |st          d|›�¦  «        ‚|                      t          d|¬¦  «        t          t                   t          |||	|
t          |||||dœt          j        ¦  «        ¬¦  «        t          ¬¦  «        S rK   )	rS   rT   r   r   r%   r"   r   r   rU   rV   s              r/   rW   z AsyncThreadsResource.list_tracesG  s­   € ðZ ð 	gÝÐeÐXaÐeÐeÑfÔfÐfØ×!Ò!ÝÐ>È)ÐTÑTÔTÝ.­{Ô;Ý(Ø+Ø'Ø%ØÝ%à&0Ø"(Ø"(Ø%.Ø#*ðð õ .ÔDñ	ô 	ðñ ô õ  ð' "ñ 
ô 
ð 	
r1   rX   rY   r[   rZ   ú>AsyncPaginator[Thread, AsyncItemsCursorPostPagination[Thread]]c       
        óÂ   — |                       dt          t                   t          ||||||dœt          j        ¦  «        t          |||	|
¬¦  «        t          d¬¦  «        S r^   )rT   r    r#   r   r	   rb   r"   rc   s              r/   rO   zAsyncThreadsResource.query¬  s…   € ðl ×!Ò!Ø#Ý/µÔ7Ý à$Ø$Ø&4Ø&4Ø!*Ø",ðð õ $Ô5ñ
ô 
õ )Ø+¸ÐQ[Ðelðñ ô õ Øð% "ñ 
ô 
ð 	
r1   rd   re   rf   r$   c             ƒ  óú   K  — |st          d|›�¦  «        ‚|                      t          d|¬¦  «        t          ||||t	          |||dœt
          j        ¦  «        ƒ d{V —†¬¦  «        t          ¬¦  «        ƒ d{V —†S )rh   rL   ri   rM   rj   NrN   rk   )rS   rm   r   r"   r   r
   rn   r$   ro   s	            r/   rp   zAsyncThreadsResource.stats÷  sÝ   è è € ðz ð 	gÝÐeÐXaÐeÐeÑfÔfÐfØ—Y’YÝÐ=ÈÐSÑSÔSÝ(Ø+Ø'Ø%ØÝ1à#*Ø&0Ø"(ðð õ
 (Ô9ñô ð ð ð ð ð ð ðñ ô õ  ð! ñ 
ô 
ð 
ð 
ð 
ð 
ð 
ð 
ð 	
r1   )r)   rx   )r)   rz   )r?   r@   rA   r@   r7   rB   r8   rB   r9   rC   r:   rD   r;   rE   r<   rF   r=   rG   r>   rH   r)   r|   )r7   rB   r8   rB   rY   r[   rZ   r[   r9   rC   rA   rB   r;   rE   r<   rF   r=   rG   r>   rH   r)   r~   rq   rr   rv   r1   r/   r'   r'   7  s  € € € € € Øð9ð 9ð 9ñ „_ð9ð ð?ð ?ð ?ñ „_ð?ð "Ø!Ø $ð: ð )-Ø$(Ø"&Ø;DðUc
ð c
ð c
ð c
ð c
ð c
ðP "Ø!Ø6:Ø6:Ø $Ø!%ð )-Ø$(Ø"&Ø;DðI
ð I
ð I
ð I
ð I
ð I
ðJ "ð )-Ø$(Ø"&Ø;DðAP
ð P
ð P
ð P
ð P
ð P
ð P
ð P
r1   c                  ó   — e Zd Zdd„ZdS )r*   Úthreadsr&   r)   ÚNonec                óª   — || _         t          |j        ¦  «        | _        t          |j        ¦  «        | _        t          |j        ¦  «        | _        d S ©N)Ú_threadsr   rW   rO   rp   ©r.   r‚   s     r/   Ú__init__z'ThreadsResourceWithRawResponse.__init__K  sU   € ØˆŒå2ØÔñ
ô 
ˆÔõ -ØŒMñ
ô 
ˆŒ
õ -ØŒMñ
ô 
ˆŒ
ˆ
ˆ
r1   N©r‚   r&   r)   rƒ   ©rs   rt   ru   rˆ   rv   r1   r/   r*   r*   J  ó(   € € € € € ð
ð 
ð 
ð 
ð 
ð 
r1   r*   c                  ó   — e Zd Zdd„ZdS )rx   r‚   r'   r)   rƒ   c                óª   — || _         t          |j        ¦  «        | _        t          |j        ¦  «        | _        t          |j        ¦  «        | _        d S r…   )r†   r   rW   rO   rp   r‡   s     r/   rˆ   z,AsyncThreadsResourceWithRawResponse.__init__Z  sU   € ØˆŒå8ØÔñ
ô 
ˆÔõ 3ØŒMñ
ô 
ˆŒ
õ 3ØŒMñ
ô 
ˆŒ
ˆ
ˆ
r1   N©r‚   r'   r)   rƒ   rŠ   rv   r1   r/   rx   rx   Y  r‹   r1   rx   c                  ó   — e Zd Zdd„ZdS )r2   r‚   r&   r)   rƒ   c                óª   — || _         t          |j        ¦  «        | _        t          |j        ¦  «        | _        t          |j        ¦  «        | _        d S r…   )r†   r   rW   rO   rp   r‡   s     r/   rˆ   z-ThreadsResourceWithStreamingResponse.__init__i  sU   € ØˆŒå7ØÔñ
ô 
ˆÔõ 2ØŒMñ
ô 
ˆŒ
õ 2ØŒMñ
ô 
ˆŒ
ˆ
ˆ
r1   Nr‰   rŠ   rv   r1   r/   r2   r2   h  r‹   r1   r2   c                  ó   — e Zd Zdd„ZdS )rz   r‚   r'   r)   rƒ   c                óª   — || _         t          |j        ¦  «        | _        t          |j        ¦  «        | _        t          |j        ¦  «        | _        d S r…   )r†   r   rW   rO   rp   r‡   s     r/   rˆ   z2AsyncThreadsResourceWithStreamingResponse.__init__x  sU   € ØˆŒå=ØÔñ
ô 
ˆÔõ 8ØŒMñ
ô 
ˆŒ
õ 8ØŒMñ
ô 
ˆŒ
ˆ
ˆ
r1   NrŽ   rŠ   rv   r1   r/   rz   rz   w  r‹   r1   rz   )8Ú
__future__r   Útypingr   r   r   Útyping_extensionsr   ÚhttpxÚtypesr	   r
   r   Ú_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*   rx   r2   rz   rv   r1   r/   ú<module>r£      sß  ðð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø %Ð %Ð %Ð %Ð %Ð %à €€€à WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WÐ WØ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JØ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JÐ JØ %Ð %Ð %Ð %Ð %Ð %Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9ðð ð ð ð ð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð ð ð @Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ð ?Ø !Ð !Ð !Ð !Ð !Ð !Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,àÐ4Ð
5€ðP
ð P
ð P
ð P
ð P
�oñ P
ô P
ð P
ðfP
ð P
ð P
ð P
ð P
Ð+ñ P
ô P
ð P
ðf
ð 
ð 
ð 
ð 
ñ 
ô 
ð 
ð
ð 
ð 
ð 
ð 
ñ 
ô 
ð 
ð
ð 
ð 
ð 
ð 
ñ 
ô 
ð 
ð
ð 
ð 
ð 
ð 
ñ 
ô 
ð 
ð 
ð 
r1   