a
    dg                     @  sn   d dl mZ d dlZd dlmZ d dlmZ d dlmZ d dl	m
Z
 dZG dd	 d	eZed
gee dZdS )    )annotationsN)List)PromptTemplate)BaseOutputParser)OutputParserExceptiona  If someone asks you to perform a task, your job is to come up with a series of bash commands that will perform the task. There is no need to put "#!/bin/bash" in your answer. Make sure to reason step by step, using this format:

Question: "copy the files in the directory named 'target' into a new directory at the same level as target called 'myNewDirectory'"

I need to take the following actions:
- List all files in the directory
- Create a new directory
- Copy the files from the first directory into the second directory
```bash
ls
mkdir myNewDirectory
cp -r target/* myNewDirectory
```

That is the format. Begin!

Question: {question}c                   @  sF   e Zd ZdZdddddZeddddd	Zedd
ddZdS )BashOutputParserzParser for bash output.strz	List[str])textreturnc                 C  s$   d|v r|  |S td| dS )z#Parse the output of a bash command.z```bashz"Failed to parse bash output. Got: N)get_code_blocksr   )selfr	    r   t/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain_experimental/llm_bash/prompt.pyparse!   s
    
zBashOutputParser.parse)tr
   c                 C  sR   g }t dt j}|| D ]0}|d }|r|dd |dD  q|S )z-Get multiple code blocks from the LLM result.z```bash(.*?)(?:\n\s*)```   c                 S  s   g | ]}|  r|qS r   )strip).0liner   r   r   
<listcomp>5       z4BashOutputParser.get_code_blocks.<locals>.<listcomp>
)recompileDOTALLfinditergroupr   extendsplit)r   Zcode_blockspatternmatchZmatchedr   r   r   r   +   s    z BashOutputParser.get_code_blocks)r
   c                 C  s   dS )Nbashr   )r   r   r   r   _type:   s    zBashOutputParser._typeN)	__name__
__module____qualname____doc__r   staticmethodr   propertyr"   r   r   r   r   r      s   
r   question)Zinput_variablestemplateZoutput_parser)
__future__r   r   typingr   Zlangchain_core.prompts.promptr   Zlangchain_core.output_parsersr   Zlangchain_core.exceptionsr   Z_PROMPT_TEMPLATEr   ZPROMPTr   r   r   r   <module>   s   !