
    g                        d dl mZ d dlZd dlmZmZmZmZ d dlZddl	m
Z
  ed      Z G d dee         Z G d	 d
ee         Zy)    )annotationsN)GenericTypeVarIteratorAsyncIterator   )construct_type_unchecked_Tc                  Z     e Zd ZU dZded<   	 	 	 	 	 	 	 	 	 d fdZd	dZd
dZd	dZ xZ	S )JSONLDecoderzA decoder for [JSON Lines](https://jsonlines.org) format.

    This class provides an iterator over a byte-iterator that parses each JSON Line
    into a given type.
    httpx.Response | Nonehttp_responsec               v    t         |           || _        || _        || _        | j                         | _        y Nsuper__init__r   _raw_iterator
_line_type
__decode__	_iteratorselfraw_iterator	line_typer   	__class__s       N/var/www/openai/venv/lib/python3.12/site-packages/anthropic/_decoders/jsonl.pyr   zJSONLDecoder.__init__   5     	*)#*    c              #  H  K   d}| j                   D ]^  }|j                  d      D ]G  }||z  }|j                  d      st        t	        j
                  |      | j                         d}I ` |r-t        t	        j
                  |      | j                         y y wNr   T)keepends)      
s   
)valuetype_r   
splitlinesendswithr	   jsonloadsr   r   bufchunklines       r   r   zJSONLDecoder.__decode__    s     ''E(($(7t<< 782"jjo"oo  C 8 ( *jjooo  s   =B" A"B"c                6    | j                   j                         S r   )r   __next__r   s    r   r1   zJSONLDecoder.__next__3   s    ~~&&((r   c              #  6   K   | j                   D ]  }|  y wr   r   r   items     r   __iter__zJSONLDecoder.__iter__6   s     NNDJ #s   )r   zIterator[bytes]r   type[_T]r   r   returnNone)r9   zIterator[_T]r9   r
   )
__name__
__module____qualname____doc____annotations__r   r   r1   r7   __classcell__r   s   @r   r   r      sG     )(=+.+;C+Ti+	+&)r   r   c                  X     e Zd ZU dZded<   	 	 	 	 	 	 	 	 d fdZd	dZd
dZd	dZ xZ	S )AsyncJSONLDecoderzA decoder for [JSON Lines](https://jsonlines.org) format.

    This class provides an async iterator over a byte-iterator that parses each JSON Line
    into a given type.
    r   r   c               v    t         |           || _        || _        || _        | j                         | _        y r   r   r   s       r   r   zAsyncJSONLDecoder.__init__D   r   r   c               \  K   d}| j                   2 3 d {   }|j                  d      D ]H  }||z  }|j                  d      st        t	        j
                  |      | j                         d}J g7 b6 |r.t        t	        j
                  |      | j                         y y wr!   r'   r,   s       r   r   zAsyncJSONLDecoder.__decode__M   s     -- 	%(($(7t<< 782"jjo"oo  C 8	- *jjooo  s+   B,A:A8A:,B,2B,8A::2B,c                R   K   | j                   j                          d {   S 7 wr   )r   	__anext__r2   s    r   rH   zAsyncJSONLDecoder.__anext__`   s     ^^--////s   '%'c               H   K   | j                   2 3 d {   }| 7 
6 y wr   r4   r5   s     r   	__aiter__zAsyncJSONLDecoder.__aiter__c   s!     .. 	$J	.s   "  " ")r   zAsyncIterator[bytes]r   r8   r   r   r9   r:   )r9   zAsyncIterator[_T]r;   )
r<   r=   r>   r?   r@   r   r   rH   rJ   rA   rB   s   @r   rD   rD   ;   sD     )(+3+@H+Yn+	+&0r   rD   )
__future__r   r*   typing_extensionsr   r   r   r   httpx_modelsr	   r
   r   rD    r   r   <module>rP      sA    "  G G  .T]+72; +\* *r   