Ë
    uPêj7	  ã                   óî   — d dl mZmZ d dlmZ d dlmZ  edd¬«       G d„ d«      «       Zdeee	f   d	e
e   fd
„Zdeee	f   d	e
e   fd„Zdeee	f   d	efd„Zdeee	f   d	efd„Zdeeee	f      d	efd„Zy)é    )ÚMappingÚSequence)Ú	dataclass)ÚFinalT)ÚfrozenÚslotsc                   ó:   — e Zd ZU edz  ed<   edz  ed<   defd„Zy)ÚGroundingRequestsNÚweb_search_requestsÚgoogle_maps_grounding_requestsÚreturnc                 óH   — t        | j                  xs | j                  «      S ©N)Úboolr   r   )Úselfs    úu/home/oem/CyberBrain26-unified/.venv/lib/python3.12/site-packages/litellm/llms/vertex_ai/gemini/grounding_requests.pyÚhas_billable_groundingz(GroundingRequests.has_billable_grounding   s   € Ü�D×,Ñ,ÒS°×0SÑ0SÓTÐTó    )Ú__name__Ú
__module__Ú__qualname__ÚintÚ__annotations__r   r   © r   r   r
   r
      s$   … à˜t™Ó#Ø$'¨$¡JÓ.ðU¨ô Ur   r
   Úitemr   c                 ó|   — | j                  d«      }t        |t        «      s
t        «       S t        d„ |D «       «      S )NÚgroundingChunksc              3   óP   K  — | ]  }t        |t        «      sŒ|D ]  }|–— Œ Œ  y ­wr   ©Ú
isinstancer   )Ú.0ÚchunkÚkinds      r   ú	<genexpr>z_chunk_kinds.<locals>.<genexpr>   s'   è ø€ Ò^˜e´¸EÄ7Õ1KÐX]Ò^ÐPT”TÐ^�TÑ^ùs   ‚&˜&©Úgetr    ÚlistÚ	frozenset)r   Úchunkss     r   Ú_chunk_kindsr*      s4   € Ø—H‘HÐ.Ó/€FÜ�fœdÔ#Ü‹{ÐÜÑ^ vÔ^Ó^Ð^r   c                 ó|   — | j                  d«      }t        |t        «      s
t        «       S t        d„ |D «       «      S )NÚwebSearchQueriesc              3   óH   K  — | ]  }t        |t        «      sŒ|sŒ|–— Œ y ­wr   )r    Ústr)r!   Úquerys     r   r$   z_queries.<locals>.<genexpr>   s   è ø€ ÒT˜u´:¸eÄSÕ3IÊe”UÑTùs   ‚"˜"›"r%   )r   Úqueriess     r   Ú_queriesr1      s4   € Ø—X‘XÐ0Ó1€GÜ�gœtÔ$Ü‹{ÐÜÑT¨ÔTÓTÐTr   c                 óT   — dt        | «      v xs t        | j                  d«      «      S )NÚmapsÚgoogleMapsWidgetContextToken)r*   r   r&   ©r   s    r   Ú_is_maps_itemr6      s&   € Ø”\ $Ó'Ð'ÒY¬4°·±Ð9WÓ0XÓ+YÐYr   c                 ó6   — t        | «      xr dt        | «      vS )NÚweb)r6   r*   r5   s    r   Ú_attributes_queries_to_mapsr9   !   s   € Ü˜ÓÒB 5´¸TÓ0BÐ#BÐBr   Úgrounding_metadatac                 óþ   — t        d„ | D «       «      }t        d„ |D «       «      }t        d„ |D «       «      }t        d„ |D «       «      }t        t	        |«      xs d|rt        t	        |«      d«      ¬«      S d¬«      S )a£  Billable grounding requests across candidates, counting each distinct query once.

    Duplicate queries within and across grounding metadata items collapse to the
    distinct-query count (#36377), and empty strings are ignored. Maps grounding is
    floored at one request whenever a candidate carries maps chunks or a widget token,
    since per-prompt billing charges the prompt even when no query is reported.
    c              3   óB   K  — | ]  }t        |t        «      sŒ|–— Œ y ­wr   r   ©r!   r   s     r   r$   z/calculate_grounding_requests.<locals>.<genexpr>-   s   è ø€ ÒZ $Ä
È4ÔQXÕ@YœÑZùs   ‚˜c              3   óX   K  — | ]"  }t        |«      rŒt        |«      D ]  }|–— Œ Œ$ y ­wr   ©r9   r1   ©r!   r   r/   s      r   r$   z/calculate_grounding_requests.<locals>.<genexpr>.   s6   è ø€ ò #ØÔ'BÀ4Õ'HÔV^Ð_cÓVdò#ØMRŒð#Øñ#ùó   ‚*“*c              3   óX   K  — | ]"  }t        |«      sŒt        |«      D ]  }|–— Œ Œ$ y ­wr   r?   r@   s      r   r$   z/calculate_grounding_requests.<locals>.<genexpr>1   s6   è ø€ ò $ØÔ#>¸tÕ#DÔRZÐ[_ÓR`ò$ØINŒð$Øñ$ùrA   c              3   ó2   K  — | ]  }t        |«      –— Œ y ­wr   )r6   r=   s     r   r$   z/calculate_grounding_requests.<locals>.<genexpr>4   s   è ø€ Ò@°$œ-¨×-Ñ@ùs   ‚Né   )r   r   )Útupler(   Úanyr
   ÚlenÚmax)r:   ÚitemsÚweb_queriesÚmaps_queriesÚhas_mapss        r   Úcalculate_grounding_requestsrM   %   s�   € ô ÑZÐ*<ÔZÓZ€EÜ"ñ #Øô#ó €Kô $ñ $Øô$ó €Lô Ñ@¸%Ô@Ó@€HÜÜ Ó,Ò4°ÙDL¤s¬3¨|Ó+<¸aÓ'@ôð àRVôð r   N)Úcollections.abcr   r   Údataclassesr   Útypingr   r
   r.   Úobjectr(   r*   r1   r   r6   r9   rM   r   r   r   ú<module>rR      s×   ðß -Ý !Ý ñ �$˜dÔ#÷Uð Uó $ðUð_�w˜s F˜{Ñ+ð _°	¸#±ó _ðU�7˜3 ˜;Ñ'ð U¨I°c©Nó UðZ˜  V Ñ,ð Z°ó ZðC g¨c°6¨kÑ&:ð C¸tó Cð°X¸gÀcÈ6ÀkÑ>RÑ5Sð ÐXiô r   