
    Fd                        d Z ddlmZ ddlZddlZddlmZ ddlmZm	Z	 ddl
Z
ddlZerddlmZ ddlmZ  e e ej                              dz            Z G d	 d
          ZdS )zR
A module that contains the AIConfig class object that contains the configuration
    )annotationsN)Path)TYPE_CHECKINGOptional)CommandRegistry)PromptGeneratorzai_settings.yamlc                  X    e Zd ZdZ	 	 	 	 dddZeefdd            ZefddZ	 dddZ	dS )AIConfigal  
    A class object that contains the configuration information for the AI

    Attributes:
        ai_name (str): The name of the AI.
        ai_role (str): The description of the AI's role.
        ai_goals (list): The list of objectives the AI is supposed to complete.
        api_budget (float): The maximum dollar value for API calls (0.0 means infinite)
     N        ai_namestrai_roleai_goalslist | None
api_budgetfloatreturnNonec                b    |g }|| _         || _        || _        || _        d| _        d| _        dS )a  
        Initialize a class instance

        Parameters:
            ai_name (str): The name of the AI.
            ai_role (str): The description of the AI's role.
            ai_goals (list): The list of objectives the AI is supposed to complete.
            api_budget (float): The maximum dollar value for API calls (0.0 means infinite)
        Returns:
            None
        N)r   r   r   r   prompt_generatorcommand_registry)selfr   r   r   r   s        LC:\Users\Administrator\Downloads\Auto-GPT-master\autogpt\config\ai_config.py__init__zAIConfig.__init__"   sA    $ H $8<8<    ai_settings_file
'AIConfig'c                   	 t          | d          5 }t          j        |t          j                  pi }ddd           n# 1 swxY w Y   n# t          $ r i }Y nw xY w|                    dd          }|                    dd          }d |                    d	g           D             }|                    d
d          }t          ||||          S )a  
        Returns class object with parameters (ai_name, ai_role, ai_goals, api_budget) loaded from
          yaml file if yaml file exists,
        else returns class with no parameters.

        Parameters:
           ai_settings_file (int): The path to the config yaml file.
             DEFAULT: "../ai_settings.yaml"

        Returns:
            cls (object): An instance of given cls object
        utf-8encoding)LoaderNr   r   r   c                    g | ]p}t          |t                    rJt          |                              d                               dd                              dd          nt          |          qS )z{}'r   ")
isinstancedictr   stripreplace).0goals     r   
<listcomp>z!AIConfig.load.<locals>.<listcomp>T   sy     
 
 
  $%%CIIOOD!!))#r22::3CCCT
 
 
r   r   r   r   )openyamlload
FullLoaderFileNotFoundErrorgetr
   )r   fileconfig_paramsr   r   r   r   s          r   r0   zAIConfig.load=   sD   	&999 NT $	$t G G G M2N N N N N N N N N N N N N N N  	 	 	MMM	  ##Ir22##Ir22
 
 &))*b99	
 
 
 #&&|S99
(J???s3   A #AA AA 	A
A AAc                    | j         | j        | j        | j        d}t	          |dd          5 }t          j        ||d           ddd           dS # 1 swxY w Y   dS )a  
        Saves the class parameters to the specified file yaml file path as a yaml file.

        Parameters:
            ai_settings_file(str): The path to the config yaml file.
              DEFAULT: "../ai_settings.yaml"

        Returns:
            None
        )r   r   r   r   wr    r!   T)allow_unicodeN)r   r   r   r   r.   r/   dump)r   r   configr4   s       r   savezAIConfig.save^   s     ||/	
 
 "C'::: 	8dIfd$7777	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8s   AAAr   Optional[PromptGenerator]c                   d}ddl m} | ||          }| j        |_        | j        |_        | j        |_        | j        |_        |j	        D ],}|
                                s|                    |          }-|j        rKt          j                    }|dk    rt          j        d          nt          j        d          }|d	| z  }d
|j         d|j         d| d}t!          | j                  D ]\  }	}
||	dz    d|
 dz  }| j        dk    r|d| j        dz  }|| _        |d|                    |           z  }|S )a5  
        Returns a prompt to the user with the class information in an organized fashion.

        Parameters:
            None

        Returns:
            full_prompt (str): A string containing the initial prompt for the user
              including the ai_name, ai_role, ai_goals, and api_budget.
        zYour decisions must always be made independently without seeking user assistance. Play to your strengths as an LLM and pursue simple strategies with no legal complications.r   )build_default_prompt_generatorNLinuxT)terse)prettyz
The OS you are running on is: zYou are z, 
z


GOALS:

   z. r   z4
It takes money to let you run. Your API budget is $z.3fz

)autogpt.prompts.promptr>   r   goalsr   namer   roler   pluginscan_handle_post_promptpost_promptexecute_local_commandsplatformsystemdistro	enumerater   r   generate_prompt_string)r   r:   r   prompt_startr>   pluginos_nameos_infofull_promptir,   s              r   construct_full_promptzAIConfig.construct_full_prompts   s    	 	JIIIII#==fEE!% $ $,0,A)n 	D 	DF0022 %112BCC( 		Io''G g%% !----[---  HwHHHL p!1!6oo:J:OooS_ooo // 	. 	.GAtac--T----KK?S  hSWSbhhhhK 0O.EEfMMOOOr   )r   r   Nr   )
r   r   r   r   r   r   r   r   r   r   )r   r   r   r   )r   r   r   r   )N)r   r<   r   r   )
__name__
__module____qualname____doc__r   staticmethod	SAVE_FILEr0   r;   rW    r   r   r
   r
      s           $= = = = =6 %. @ @ @ @ \@@ ,5 8 8 8 8 8, EI5 5 5 5 5 5 5r   r
   )r[   
__future__r   osrL   pathlibr   typingr   r   rN   r/   autogpt.models.command_registryr   autogpt.prompts.generatorr   r   getcwdr]   r
   r^   r   r   <module>rf      s    # " " " " " 				        * * * * * * * *   :??????999999 CYRY[[!!$6677	Q Q Q Q Q Q Q Q Q Qr   