o
    h                     @   s   d dl mZ d dlmZ d dlmZmZ d dl mZ d dlZG dd deZ	G dd	 d	eZ
ed
dedefddZeddedefddZdS )    )BaseTool)Type)	BaseModelField)toolNc                   @   s&   e Zd ZU dZedddZeed< dS )MyCustomToolInputzInput schema for MyCustomTool..zDescription of the argument.)descriptionargumentN)__name__
__module____qualname____doc__r   r	   str__annotations__ r   r   z/home/azureuser/microlearn/backend/user_journey_with_openai/agentic_workflow/src/user_journey_service/tools/custom_tool.pyr      s   
 r   c                   @   sH   e Zd ZU dZeed< dZeed< eZe	e
 ed< dedefdd	Zd
S )MyCustomToolzName of my toolnamezdClear description for what this tool is useful for, your agent will need this information to use it.r   args_schemar	   returnc                 C   s   dS )Nz>this is an example of a tool output, ignore it and move along.r   )selfr	   r   r   r   _run   s   zMyCustomTool._runN)r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r      s   
 
r   zTool for reading text content	file_pathr   c                 C   sH   t d|   t| ddd}| W  d   S 1 sw   Y  dS )z;Reads the content of an md file and returns it as a string.zThe file path is : rzutf-8)encodingN)printopenread)r   fr   r   r   readtool   s   $r   z+Tool for reading md file and output as JSONfilepathc              
   C   s   z.t | d}| }td|}td dd |D W  d   W S 1 s'w   Y  W dS  tyF } zdt|iW  Y d}~S d}~ww )z
    Reads the md file and returns it as a dictionary.
    
    Args:
        filepath (str): Path to the JSON file.
    
    Returns:
        dict: Parsed JSON content.
    r   z##\s*([\w\s]+?)\s*-\s*(\d+)%zmatch foundc                 S   s   i | ]\}}|  t|qS r   )stripint).0skillpercentr   r   r   
<dictcomp>3   s    z!read_defaults.<locals>.<dictcomp>Nerror)r   r   refindallr   	Exceptionr   )r    fileresultmatcheser   r   r   read_defaults!   s   (r/   )crewai.toolsr   typingr   pydanticr   r   r   r(   r   r   r   r   dictr/   r   r   r   r   <module>   s    	