Team Ai
Apppublic

melghorab/code-assistant

sourceHugging Faceopenrailupdated 2y agoView on Hugging Face
0likes
tools.cpython-310.pyc24 linesDownload Raw Back to __pycache__
1o

2��gz�@s`ddlmZmZddlZddlZddlmZddlZededefdd��Z	dedefd	d3�Z4dS)�)�Tool�toolN)�Document�package_name�returnc5Cs�td|���d}zIzt�|�d|�d��}|��|��}Wntjy8}ztd|�dt|�����d}~wwt�|dd	|dd6d��}td|���|WStyk}z
d
t|���WYd}~Sd}~ww)z�Search PyPI for Python package information. Input should be the package name.7    Args: 8        package_name: name of the package 9    zTool called for package: zhttps://pypi.org/pypi�/z/jsonzError fetching PyPI info for z: N�info�name�summary)r	r10z
Tool result: z$Could not find package information: )	�print�requests�get�raise_for_status�json�RequestException�	Exception�str�dumps)r�base_url�responser�e�result�r�F/home/melghorab/maven_nlp_course/code/Project/Code_Documenter/tools.py�search_pypis*��1112���r�documentation_textcCszt�}|�d�}|D])}|�d�r|j|dd�dd�q13|�d�r.|j|dd�dd�q14|�|�q15d	}|�|�|S)16zZ17    Writes the AI-generated documentation to a .docx file and returns the file path.18    �19z# �N�)�levelz## �zgenerated_documentation.docx)r�split�20startswithZadd_headingZ
add_paragraph�save)r�doc�lines�line�	file_pathrrr�
write_to_docx!s21222324r()�langchain_core.toolsrrrr�docxr�rerrr(rrrr�<module>s