
    Fd                        d dl Z d dlZd dlZd dlZd dlmZ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  e e                      Zdd	ed
efdZddedefdZdefdZddZd ZdefdZdeeef         fdZdefdZdefdZdS )    N)ForeStyle)Repo)ANSIPromptSession)InMemoryHistory)Config)logger)historymax_batch_lengthoverlapc              #      K   |dk     rt          d          t          dt          |           ||z
            D ]}| |||z            V  dS )zPBatch data from iterable into slices of length N. The last batch may be shorter.   zn must be at least oner   N)
ValueErrorrangelen)iterabler   r   is       AC:\Users\Administrator\Downloads\Auto-GPT-master\autogpt\utils.pybatchr      sr       !12221c(mm%5%?@@ 1 1q1///000001 1     Fconfigpromptc                 4   	 | j         r| j        D ]}t          |d          s|                    |          s*|                    |          }|sC|                                dv r	| j        c S |                                dv r	| j        c S |c S t          j	        d           t                              t          |                    }|S # t          $ r; t          j	        d           t          j	        d           t          d           Y d S w xY w)	Ncan_handle_user_input)
user_input)yesyeahyokokaysurealright)nonopennegativezAsking user via keyboard...zYou interrupted Auto-GPTzQuitting...r   )chat_messages_enabledpluginshasattrr   r   lowerauthorise_keyexit_keyr
   infosessionr   r   KeyboardInterruptexit)r   r   talkpluginplugin_responseanswers         r   clean_inputr7      s[   $' 	' . ' 'v'>?? 33v3FF "("3"3v"3"F"F& "((** /   "////$**,, 1   "?***&&&& 	1222V--   .///M"""Qs%   A/C 2C C <C ADDfilec           	         	 t          | d          5 }t          j        |                                t          j                   d d d            n# 1 swxY w Y   nP# t
          $ r% ddt          j         d|  dt          j         dfcY S t          j	        $ r}dd| fcY d }~S d }~ww xY wd	d
t          j         d|  dt          j         dfS )Nutf-8encoding)LoaderFz	The file `z wasn't foundzDThere was an issue while trying to read with your AI Settings file: TzSuccessfully validated !)
openyamlloadread
FullLoaderFileNotFoundErrorr   CYANRESET	YAMLError)r8   fpes      r   validate_yaml_filerK   B   sR   	
$))) 	9RIbggii8888	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 	9 Q Q QO49OOtOOdjOOOPPPP> 
 
 
VSTVV
 	
 	
 	
 	
 	
 	

 LDILLLLtzLLLMMsF   A 3AA AA AA ,B+B+B& B+&B+   c                 >    dD ]}| dk     r n| dz  } | d| dd| S )zConverts the given size in bytes to a readable format.
    Args:
        size: Size in bytes
        decimal_places (int): Number of decimal places to display
    )BKBMBGBTBg      @.f  )sizedecimal_placesunits      r   readable_file_sizerZ   Q   sN     .  &==E.^........r   c                      	 t          j        d          } | j        dk    r| j        S n# t           j        j        $ r Y nw xY wdS )NzRhttps://raw.githubusercontent.com/Significant-Gravitas/Auto-GPT/master/BULLETIN.md   r   )requestsgetstatus_codetext
exceptionsRequestException)responses    r   get_bulletin_from_webrd   ^   se    <`
 
 3&&=  '/    2s   %) A A returnc                  P    	 t          d          } | j        }|j        S #  Y dS xY w)NT)search_parent_directoriesr   )r   active_branchname)repobranchs     r   get_current_git_branchrl   k   s7    d333#{rrs     %c                     t           j                            d          } d}| r$t          ddd                                          }t                      }|dk    o||k    }t          j        dz   }|s|r|dz  }|rE|rCt          ddd                              |           t          j	         d	t          j
         d
| }| d| |fS )Nzdata/CURRENT_BULLETIN.mdr   rr:   r;   zWelcome to Auto-GPT!
zBelow you'll find the latest Auto-GPT News and updates regarding features!
If you don't wish to see this message, you can run Auto-GPT with the *--skip-news* flag.
wz::NEW BULLETIN::z


)ospathexistsr@   rC   rd   r   YELLOWwriteREDrG   )rs   current_bulletinnew_bulletinis_new_newsnews_headers        r   get_latest_bulletinr{   t   s
   W^^677F &g
 
 

$&& 	 )**L"$I9I)IK+ 88K 
' 
>	
  W W'w???EElSSS"hVV
VVVV//-//<<r   markdownc                    g }|                      d          D ]}d}|                    d          r|t          j        z  }n/t	          j        dt          j         dt          j         |          }t	          j        d|          %|t          j	        z  }t	          j        dd|          }|
                    | | t          j                    d                    |          S )Nrp   r   z# z(?<!\*)\*(\*?[^*]+\*?)\*(?!\*)z\1z^#+ )split
startswithr   BRIGHTresubNORMALmatchr   rF   append	RESET_ALLjoin)r|   
ansi_linesline
line_styles       r   markdown_to_ansi_styler      s    Jt$$ B B
??4   	%,&JJ61L22EL22 D 8GT"".$)#J6'2t,,DZ@@u@@AAAA99Z   r   c                  
    d} | S )Na}  
## DISCLAIMER AND INDEMNIFICATION AGREEMENT
### PLEASE READ THIS DISCLAIMER AND INDEMNIFICATION AGREEMENT CAREFULLY BEFORE USING THE AUTOGPT SYSTEM. BY USING THE AUTOGPT SYSTEM, YOU AGREE TO BE BOUND BY THIS AGREEMENT.

## Introduction
AutoGPT (the "System") is a project that connects a GPT-like artificial intelligence system to the internet and allows it to automate tasks. While the System is designed to be useful and efficient, there may be instances where the System could perform actions that may cause harm or have unintended consequences.

## No Liability for Actions of the System
The developers, contributors, and maintainers of the AutoGPT project (collectively, the "Project Parties") make no warranties or representations, express or implied, about the System's performance, accuracy, reliability, or safety. By using the System, you understand and agree that the Project Parties shall not be liable for any actions taken by the System or any consequences resulting from such actions.

## User Responsibility and Respondeat Superior Liability
As a user of the System, you are responsible for supervising and monitoring the actions of the System while it is operating on your
behalf. You acknowledge that using the System could expose you to potential liability including but not limited to respondeat superior and you agree to assume all risks and liabilities associated with such potential liability.

## Indemnification
By using the System, you agree to indemnify, defend, and hold harmless the Project Parties from and against any and all claims, liabilities, damages, losses, or expenses (including reasonable attorneys' fees and costs) arising out of or in connection with your use of the System, including, without limitation, any actions taken by the System on your behalf, any failure to properly supervise or monitor the System, and any resulting harm or unintended consequences.
            rV   )
legal_texts    r   get_legal_warningr      s    J" r   )r   )r   F)rL   ) rq   r   r]   rA   coloramar   r   git.repor   prompt_toolkitr   r   prompt_toolkit.historyr   autogpt.configr	   autogpt.logsr
   r0   intr   strr7   rK   rZ   rd   rl   tupleboolr{   r   r   rV   r   r   <module>r      s   				 				                         . . . . . . . . 2 2 2 2 2 2 ! ! ! ! ! !      
- 1 1
2
2
21 1c 1C 1 1 1 1% % % % % % %PNS N N N N
/ 
/ 
/ 
/
 
 
    =U39- = = = =2!S ! ! ! !,3      r   