Ë
    õ¡Ÿj8  ã                  ó¼   — d Z ddlmZ ddlmZmZ ddlmZmZ ddl	m
Z
 ddl	mZ e G d„ d«      «       Ze G d	„ d
«      «       Ze G d„ d«      «       Z G d„ de«      Zy)zM
author: Yagnik Poshiya
organization: Webbrains Technologies Private Limited
é    )Úannotations)ÚABCÚabstractmethod)Ú	dataclassÚfield)ÚIterator)ÚAnyc                  ó*   — e Zd ZU dZded<   dZded<   y)ÚLLMUsager   ÚintÚinput_tokensÚoutput_tokensN)Ú__name__Ú
__module__Ú__qualname__r   Ú__annotations__r   © ó    ú@/var/www/html/agent-engine/apps/agents/rag-agent/src/llm/base.pyr   r      s   … à€L�#ÓØ€M�3Ôr   r   c                  ó8   — e Zd ZU dZded<    ee¬«      Zded<   y)ÚLLMResponseÚ ÚstrÚtext)Údefault_factoryr   ÚusageN)r   r   r   r   r   r   r   r   r   r   r   r   r      s   … à€Dˆ#ƒNÙ¨HÔ5€Eˆ8Ô5r   r   c                  óT   — e Zd ZU dZded<   dZded<   dZded<   dZded	<   d
Zded<   y)ÚGenerationConfiggš™™™™™Ù?ÚfloatÚtemperatureNzfloat | NoneÚtop_pz
int | NoneÚtop_kÚmax_output_tokensFÚboolÚresponse_json)	r   r   r   r    r   r!   r"   r#   r%   r   r   r   r   r      s5   … à€K�ÓØ€Eˆ<ÓØ€Eˆ:ÓØ$(Ð�zÓ(Ø€M�4Ôr   r   c                  óR   — e Zd ZdZeddœ	 	 	 	 	 dd„«       Zdd„Zddœ	 	 	 	 	 d	d„Zy)
Ú	LLMClientz,Provider-agnostic chat completion interface.N©Úconfigc                ó   — y )Nr   )ÚselfÚpromptr)   s      r   ÚgeneratezLLMClient.generate&   s   € ð 	r   c                óÔ   — dd l }| j                  |t        dd¬«      ¬«      }|j                  j	                  «       }|si |j
                  fS |j                  |«      |j
                  fS )Nr   gš™™™™™É?T)r    r%   r(   )Újsonr-   r   r   Ústripr   Úloads)r+   r,   r/   Úrespr   s        r   Úgenerate_jsonzLLMClient.generate_json/   s`   € ÛØ�}‰}ØÜ#°À4ÔHð ó 
ˆð �y‰y�‰Ó ˆÙØ�t—z‘z�>Ð!Ø�z‰z˜$Ó §¡Ð+Ð+r   c             #  óh   K  — | j                  ||¬«      }|j                  r|j                  –— yy­w)zV
        Streaming fallback for providers that do not expose token streaming.
        r(   N)r-   r   )r+   r,   r)   r2   s       r   Ústream_generatezLLMClient.stream_generate:   s/   è ø€ ð �}‰}˜V¨Fˆ}Ó3ˆØ�9Š9Ø—)‘)‹Oð ùs   ‚02)r,   r   r)   úGenerationConfig | NoneÚreturnr   )r,   r   r7   ztuple[dict[str, Any], LLMUsage])r,   r   r)   r6   r7   zIterator[str])r   r   r   Ú__doc__r   r-   r3   r5   r   r   r   r'   r'   #   sc   „ Ù6àð
 +/ñ	àðð (ð	ð
 
òó ðó	,ð +/ñ	àðð (ð	ð
 
ôr   r'   N)r8   Ú
__future__r   Úabcr   r   Údataclassesr   r   Útypingr   r	   r   r   r   r'   r   r   r   ú<module>r=      sr   ðñõ
 #ç #ß (Ý Ý ð ÷ð ó ðð
 ÷6ð 6ó ð6ð
 ÷ ð  ó ð ô"�õ "r   