ó
    UB/jú  ã                  óŽ   • S r SSKJr  SSKJr  SSKJr  SSKJr  SSK	J
r
Jr  SSKJr  SSKJr  S	r " S
 S\
5      r " S S5      rg)a%  
Period / quarter-end inference.

Asks an LLM to read a table fragment and infer the reporting period it
covers (period end date plus the label as printed). Uses pydantic-ai so
it sits alongside the existing inference processor.

Value extraction is deliberately out of scope for this module.
é    )Úannotations)Údate)ÚOptional)Úlogger)Ú	BaseModelÚField)ÚAgentFactory)ÚModelProvideraê  You are reading a financial-document table fragment to infer the
reporting period it covers.

Return a JSON object with:
- period_end (ISO date YYYY-MM-DD, or null if unknown)
- period_label (free-text label as it appears in the source, e.g.
  "Q1 FY25", "For the 3 Months Ended September 30, 2025")
- fiscal_quarter (1-4, or null)
- fiscal_year (e.g. 2025, or null)

Do not guess. If the table fragment does not state the period
unambiguously, return nulls for the fields you cannot fill.
c                  ór   • \ rS rSr% \" SS9rS\S'   \" SS9rS\S'   \" SSS	S
9rS\S'   \" SS9r	S\S'   Sr
g)ÚPeriodInferenceé&   N)ÚdefaultzOptional[date]Ú
period_endúOptional[str]Úperiod_labelé   é   )r   ÚgeÚlezOptional[int]Úfiscal_quarterÚfiscal_year© )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r   Ú__annotations__r   r   r   Ú__static_attributes__r   ó    Ú5/home/mande/repo/quber/src/quber/processors/period.pyr   r   &   sB   ‡ Ù!&¨tÑ!4€J�Ó4Ù"'°Ñ"5€L�-Ó5Ù$)°$¸1ÀÑ$C€N�MÓCÙ!&¨tÑ!4€K�Ö4r   r   c                  ó:   • \ rS rSr  S     SS jjrSS jrSrg)	ÚPeriodInferenceProcessoré-   Nc                óT   • [        SS9nUR                  [        [        UUS9U l        g )NF)Úenable_logfire)Úoutput_typeÚsystem_promptÚproviderÚmodel)r	   Úcreate_agentr   ÚPERIOD_PROMPTÚagent)Úselfr(   r)   Úfactorys       r    Ú__init__Ú!PeriodInferenceProcessor.__init__.   s1   € ô
 ¨eÑ4ˆØ×)Ñ)Ü'Ü'ØØð	 *ð 
ˆ�
r   c              ƒ  óÚ   #   •  U R                   R                  U5      I S h  v•N nUR                  $  N! [         a)  n[        R
                  " SUS9  [        5       s S nA$ S nAff = f7f)Nz&PeriodInferenceProcessor failed: {exc})Úexc)r,   ÚrunÚoutputÚ	Exceptionr   Úwarningr   )r-   ÚfragmentÚresultr2   s       r    ÚinferÚPeriodInferenceProcessor.infer;   sU   é € ð	%ØŸ:™:Ÿ>™>¨(Ó3×3ˆFØ—=‘=Ð ñ 4øäó 	%Ü�NŠNÐCÈÒMÜ"Ó$Õ$ûð	%üs<   ‚A+„5 ¢3£5 ²A+³5 µ
A(¿A#ÁA(ÁA+Á#A(Á(A+)r,   )NN)r(   zOptional[ModelProvider]r)   r   ÚreturnÚNone)r7   Ústrr;   r   )r   r   r   r   r/   r9   r   r   r   r    r"   r"   -   s0   † ð -1Ø#ð
à)ð
ð ð
ð 
õ	
÷%r   r"   N)Ú__doc__Ú
__future__r   Údatetimer   Útypingr   Úlogurur   Úpydanticr   r   Úquber.agentsr	   Úquber.agents.factoryr
   r+   r   r"   r   r   r    Ú<module>rF      s>   ðñõ #å Ý å ß %å %Ý .ð€ô 5�iô 5÷%ò %r   