
    Fd                         d Z ddlZddlmZmZ ddlmZ ddlmZ 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mZ ddlmZmZmZ de
defdZde
defdZdede
defdZdS )zSet up the AI and its goals    N)ForeStyle)Template)utils)Config)AIConfig)ChatSequenceMessage)create_chat_completion)logger)(DEFAULT_SYSTEM_PROMPT_AICONFIG_AUTOMATIC&DEFAULT_TASK_PROMPT_AICONFIG_AUTOMATICDEFAULT_USER_DESIRE_PROMPTconfigreturnc                 $   d}d}t          j        dt          j        dd           t          j        dt          j        dd           t	          j        | t          j         d	t          j         d
          }|dk    rt          }d|v r0t          j        dt          j        d           t          |           S 	 t          ||           S # t          $ r;}t          j        dt          j        dd           t          |           cY d}~S d}~ww xY w)zoPrompt the user for input

    Returns:
        AIConfig: The AIConfig object tailored to the user's input
     NzWelcome to Auto-GPT! z'run with '--help' for more information.T
speak_textCreate an AI-Assistant:z&input '--manual' to enter manual mode.zI want Auto-GPT to: z--manualzManual Mode Selectedz@Unable to automatically generate AI Config based on user desire.zFalling back to manual mode.)r   typewriter_logr   GREENr   clean_inputLIGHTBLUE_EXr   	RESET_ALLr   generate_aiconfig_manualgenerate_aiconfig_automatic	ExceptionRED)r   ai_name	ai_configuser_desirees        AC:\Users\Administrator\Downloads\Auto-GPT-master\autogpt\setup.pyprompt_userr&      s`    GI 
1	    !
0	    #4$KKKKK K b0 [  "J	
 	
 	
 	

 (///
	4.{FCCC 	4 	4 	4!R.	    ,F33333333	4s   :C
 

D0D
D
Dc           
      t   t          j        dt          j        dd           t          j        dt          j        d           t	          j        | d          }|dk    rd	}t          j        | d
t          j        dd           t          j        dt          j        d           t	          j        | | d          }|dk    rd}	 t          j        dt          j        d           t          j        d           g }t          d          D ]T}t	          j        | t          j         dt          j
         d|dz    d          }|dk    r n|                    |           U|sg d}t          j        dt          j        d           t          j        d           t	          j        | t          j         dt          j
         d          }|dk    rd}nV	 t          |                    dd                    }n1# t          $ r$ t          j        d t          j                   d}Y nw xY wt!          ||||          S )!a*  
    Interactively create an AI configuration by prompting the user to provide the name, role, and goals of the AI.

    This function guides the user through a series of prompts to collect the necessary information to create
    an AIConfig object. The user will be asked to provide a name and role for the AI, as well as up to five
    goals. If the user does not provide a value for any of the fields, default values will be used.

    Returns:
        AIConfig: An AIConfig object containing the user-defined or default AI name, role, and goals.
    r   zREnter the name of your AI and its role below. Entering nothing will load defaults.Tr   zName your AI: zFor example, 'Entrepreneur-GPT'z	AI Name: r   zEntrepreneur-GPTz here!zI am at your service.zDescribe your AI's role: zyFor example, 'an AI designed to autonomously develop and run businesses with the sole goal of increasing your net worth.'z is: zBan AI designed to autonomously develop and run businesses with thez!Enter up to 5 goals for your AI: zlFor example: 
Increase net worth, Grow Twitter Account, Develop and manage multiple businesses autonomously'z<Enter nothing to load defaults, enter nothing when finished.   Goal    r   )zIncrease net worthzGrow Twitter Accountz3Develop and manage multiple businesses autonomouslyz!Enter your budget for API calls: zFor example: $1.50z6Enter nothing to let the AI run without monetary limitBudgetz: $        $z2Invalid budget input. Setting budget to unlimited.)r   r   r   r   r   r   r   inforanger   r   appendfloatreplace
ValueErrorr    r   )r   r!   ai_roleai_goalsiai_goalapi_budget_input
api_budgets           r%   r   r   K   s    !
	    $*&G   44G"}}$
D-/FSW   
 #
	8   7(9(9(9::G"}}V2 +
	-   KNOOOH1XX ! !#t(GGeoGG!GGG
 
 b==E     

 
 
 +
  
 KHIII(4$@@EO@@@  2

	/77R@@AAJJ 	 	 	!Ddh   JJJ		 GWh
;;;s   #G7 7+H%$H%user_promptc           
         t           }t          t                                        |           }t	          t          j        |j        t          d|          t          d|          g          |          j	        }t          j        d|            t          j        d|t          j                                      d          }t          j        d|t          j        t          j        z                                d                                          }t          j        d|          }d	}t'          ||||          S )
zGenerates an AIConfig object from the given string.

    Returns:
    AIConfig: The AIConfig object tailored to the user's input
    )r;   systemuserz AI Config Generator Raw Output: zName(?:\s*):(?:\s*)(.*)r+   z/Description(?:\s*):(?:\s*)(.*?)(?:(?:\n)|Goals)z(?<=\n)-\s*(.*)r-   )r   r   r   renderr   r	   	for_modelfast_llm_modelr
   contentr   debugresearch
IGNORECASEgroupDOTALLstripfindallr   )	r;   r   system_promptprompt_ai_config_automaticoutputr!   r5   r6   r:   s	            r%   r   r      s,    =M!)." "ff%%  $!-00 :;;	
 	
 		 	   L<F<<=== i2FBMJJPPQRSSG
	>MBI%	
 	

 
q	  z,f55HJGWh
;;;    )__doc__rD   coloramar   r   jinja2r   autogptr   autogpt.configr   autogpt.config.ai_configr   autogpt.llm.baser	   r
   autogpt.llm.chatr   autogpt.logsr   autogpt.prompts.default_promptsr   r   r   r&   r   strr    rN   r%   <module>r[      sa   ! ! 				                             ! ! ! ! ! ! - - - - - - 2 2 2 2 2 2 2 2 3 3 3 3 3 3               44 448 44 44 44 44nY<V Y< Y< Y< Y< Y<x(<S (<& (<X (< (< (< (< (< (<rN   