
    dhy	                        S SK Jr  S SKrS SKJrJr  S SKJr  S SKJ	r	J
r
Jr  S SKJr  \R                  " \5      r " S S\	5      r " S	 S
\5      rg)    )annotationsN)OptionalType)CallbackManagerForToolRun)	BaseModelFieldHttpUrl)
EdenaiToolc                  ,    \ rS rSr% \" SS9rS\S'   Srg)InvoiceParsingInput   zurl of the document to parse)descriptionr	   query N)__name__
__module____qualname____firstlineno__r   r   __annotations____static_attributes__r       j/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/tools/edenai/ocr_invoiceparser.pyr   r      s    'EFE7Fr   r   c                      \ rS rSr% SrSrS\S'   SrS\S'   \r	S\S	'   S
r
S\S'    SrS\S'   SrS\S'   SS jr S     SS jjrSrg
)EdenAiParsingInvoiceTool   aI  Tool that queries the Eden AI Invoice parsing API.

for api reference check edenai documentation:
https://docs.edenai.co/reference/ocr_invoice_parser_create.

To use, you should have
the environment variable ``EDENAI_API_KEY`` set with your API token.
You can find your token here: https://app.edenai.run/admin/account/settings

edenai_invoice_parsingstrnamea  A wrapper around edenai Services invoice parsing. Useful for when you have to extract information from 
        an image it enables to take invoices 
        in a variety of formats and returns the data in contains
        (items, prices, addresses, vendor name, etc.)
        in a structured format to automate the invoice processing Input should be the string url of the document to parse.r   zType[BaseModel]args_schemaNzOptional[str]languageocrfeatureinvoice_parser
subfeaturec                    / n[        U5      S:X  a  U R                  US   S   S   U5        O8U H2  nUR                  S5      S:X  d  M  U R                  US   S   U5        M4     SR                  U5      $ )N   r   extracted_dataproviderzeden-ai
)len_parse_json_multilevelgetjoin)selfresponseformatted_listentrys       r   _parse_response(EdenAiParsingInvoiceTool._parse_response2   s    !x=A'',-a0. "99Z(I5//./2N " yy((r   c                D    UU R                   SS.nU R                  U5      $ )zUse the tool.F)file_urlr    attributes_as_list)r    _call_eden_ai)r.   r   run_managerquery_paramss       r   _runEdenAiParsingInvoiceTool._runB   s+     "'
 !!,//r   r   )r/   listreturnr   )N)r   r   r8   z#Optional[CallbackManagerForToolRun]r=   r   )r   r   r   r   __doc__r   r   r   r   r   r    r"   r$   r2   r:   r   r   r   r   r   r      s    	 )D#(	C   $7K6"Hm" GS&J&)& <@00 90 
	0 0r   r   )
__future__r   loggingtypingr   r   langchain_core.callbacksr   pydanticr   r   r	   1langchain_community.tools.edenai.edenai_base_toolr
   	getLoggerr   loggerr   r   r   r   r   <module>rG      sD    "  ! > . . H			8	$G) G<0z <0r   