
    dh	                        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)ExplicitImageInput   zurl of the image to analyze)descriptionr	   query N)__name__
__module____qualname____firstlineno__r   r   __annotations____static_attributes__r       n/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/tools/edenai/image_explicitcontent.pyr   r      s    'DEE7Er   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 jr S     SS jjrSrg)EdenAiExplicitImageTool   aR  Tool that queries the Eden AI Explicit image detection.

for api reference check edenai documentation:
https://docs.edenai.co/reference/image_explicit_content_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_image_explicit_content_detectionstrnamea  A wrapper around edenai Services Explicit image detection. Useful for when you have to extract Explicit Content from images.
        it detects adult only content in images, 
        that is generally inappropriate for people under
        the age of 18 and includes nudity, sexual activity,
        pornography, violence, gore content, etc.Input should be the string url of the image .r   zType[BaseModel]args_schemaTboolcombine_availableimagefeatureexplicit_content
subfeaturec                    SUS    S3n[        US   5       H*  u  p4US   R                  5       nUS   nX# SU SU S	3-  nM,     US S
 $ )Nznsfw_likelihood: nsfw_likelihood
itemslabel
likelihoodz: z likelihood z,
)	enumeratelower)self	json_data
result_stridx	found_objr*   r+   s          r   _parse_json#EdenAiExplicitImageTool._parse_json/   ss    (3D)E(FbI
'	'(:;NCg&,,.E"<0JEE7,zl#FFJ <
 #2r   c                    [        U5      S:X  a  U R                  US   5      nU$ U H+  nUR                  S5      S:X  d  M  U R                  U5      nM-     W$ )N   r   providerzeden-ai)lenr4   get)r/   r0   resultentrys       r   _parse_response'EdenAiExplicitImageTool._parse_response8   s]    y>Q%%il3F 	 #99Z(I5!--e4F # r   Nc                .    USS.nU R                  U5      $ )zUse the tool.F)file_urlattributes_as_list)_call_eden_ai)r/   r   run_managerquery_paramss       r   _runEdenAiExplicitImageTool._runB   s     %*G!!,//r   r   )r0   dictreturnr   )r0   listrH   r   )N)r   r   rC   z#Optional[CallbackManagerForToolRun]rH   r   )r   r   r   r   __doc__r   r   r   r   r   r!   r#   r%   r4   r=   rE   r   r   r   r   r   r      s    	 :D#9	8   $6K5"t"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>rS      sD    "  ! > . . H			8	$F F70j 70r   