Skip to content

Commit

Permalink
Update the shell script system prompt and expand on comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jef808 committed Mar 2, 2024
1 parent e9065d4 commit e76d43c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
19 changes: 19 additions & 0 deletions echo_crafter/prompts/make_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,25 @@ def extract_sections_from_markdown(markdown_text: str, sections: list[str]) -> d
Returns:
dict: A dictionary containing the extracted content as {'section': content}.
Example:
markdown_text = '''
## CODE:
```python
def hello_world():
print("Hello, world!")
```
## FILENAME:
hello.py
## DESCRIPTION:
A simple hello world program.
'''
sections = ["CODE", "FILENAME", "DESCRIPTION"]
extract_sections_from_markdown(markdown_text, sections)
# Output: {'CODE': 'def hello_world():\n print("Hello, world!")', 'FILENAME': 'hello.py', 'DESCRIPTION': 'A simple hello world program.'}
"""
# Regular expressions for extracting the sections
section_patterns = [f"## {section}:\n(.*)\n\n## {sections[i+1]}" for i, section in enumerate(sections[:-1])]
Expand Down
10 changes: 7 additions & 3 deletions echo_crafter/prompts/templates/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@
SHELL_BASE_PROMPT = [
{
"role": "system",
"content": "carefully analyze the intent of the provided command then replace it with a zsh shell script which, when executed on a linux system, will run that command"
"content": "1. **Analysis**: Carefully analyze the intent of the provided command\n"
"2. **Code**: Generate a zsh shell script which, when executed on a linux system, will run that command "
"3. **Comments**: Carefully annotate all functions and the script itself with docstrings according to common practice "
"4. **Types**: From the provided command, infer the expected input and output types and add type hints to the function signature "
"5. **Metadata**: Provide a FILENAME for saving the script to a file and a DESCRIPTION reflecting the user's prompt for retrieving the script."
},
{
"role": "system", "name": "example_user",
"content": "```\ngive me the absolute path to my home directory\n```"
"content": "```\nGive me the absolute path to my home directory\n```"
},
{
"role": "system", "name": "example_assistant",
"content": "```zsh\necho $HOME\n```"
"content": '## CODE:\n```zsh\n# print the content of the $HOME environment variable to standard output.\necho $HOME\n```\n\n## FILENAME:\nprint_home_dir.sh\n\n## DESCRIPTION:\nA script to print the home directory of the current user.'
}
]

Expand Down

0 comments on commit e76d43c

Please sign in to comment.