Skip to content

Commit

Permalink
remove cwd_info from context
Browse files Browse the repository at this point in the history
  • Loading branch information
granawkins committed Feb 17, 2024
1 parent 079f98a commit fe57bda
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 33 deletions.
2 changes: 1 addition & 1 deletion examples/simple/cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
{
"role": "system",
"content": "Today's date is 2024-02-14 13:32:19.\nThe current working directory is /Users/jakekoenig/rawdog, which IS a git repository.\nThe user's operating system is Darwin.\nThe contents of the current working directory are:\n2024-02-05 07:56:58 11339 bytes LICENSE\n2024-02-14 13:22:51 32 bytes requirements.txt\n2024-02-07 09:47:43 4 items /dist\n2024-02-14 13:22:51 630 bytes pyproject.toml\n2024-02-13 09:38:11 60746 bytes training_data.jsonl\n2024-02-05 07:56:58 1 items /rawdog\n2024-02-13 08:58:21 5247 bytes script_2024-02-13_08-58-21.py\n2024-02-14 08:47:33 308 bytes todo\n2024-02-13 01:40:23 3081 bytes README.md\n2024-02-05 07:57:14 45 bytes .gitignore\n2024-02-07 09:47:28 5 items /.env\n2024-02-14 13:26:01 13 items /examples\n2024-02-13 13:19:10 3 items /scripts\n2024-02-14 09:25:18 3380 bytes octagon.png\n2024-02-14 13:22:51 13 items /.git\n2024-02-09 02:29:04 58388 bytes old_training_data.jsonl\n2024-02-14 08:46:44 4 items /my_env\n2024-02-05 07:56:58 1 items /src\nThe last commit message is: Pip install not found modules (#61)\n\nIf the llm tries to use a module that cannot be found then prompt the\r\nuser to install it with pip.\r\nMisc:\r\n* Moved execution specific utils from utils to execute_script\r\n* Removed almost all the requirements\r\n* Give errors from the script to the llm (was broken by move to subprocess)\r\n\r\nCo-authored-by: biobootloader <[email protected]>\r\n\r\n---------\r\n\r\nCo-authored-by: biobootloader <[email protected]>"
"content": "Today's date is 2024-02-14 13:32:19.\nThe current working directory is /Users/jakekoenig/rawdog, which IS a git repository.\nThe user's operating system is Darwin.\nThe last commit message is: Pip install not found modules (#61)\n\nIf the llm tries to use a module that cannot be found then prompt the\r\nuser to install it with pip.\r\nMisc:\r\n* Moved execution specific utils from utils to execute_script\r\n* Removed almost all the requirements\r\n* Give errors from the script to the llm (was broken by move to subprocess)\r\n\r\nCo-authored-by: biobootloader <[email protected]>\r\n\r\n---------\r\n\r\nCo-authored-by: biobootloader <[email protected]>"
},
{
"role": "user",
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/cwd.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
{
"role": "system",
"content": "Today's date is 2024-02-14 13:27:51.\nThe current working directory is /Users/jakekoenig/rawdog, which IS a git repository.\nThe user's operating system is Darwin.\nThe contents of the current working directory are:\n2024-02-05 07:56:58 11339 bytes LICENSE\n2024-02-14 13:22:51 32 bytes requirements.txt\n2024-02-07 09:47:43 4 items /dist\n2024-02-14 13:22:51 630 bytes pyproject.toml\n2024-02-13 09:38:11 60746 bytes training_data.jsonl\n2024-02-05 07:56:58 1 items /rawdog\n2024-02-13 08:58:21 5247 bytes script_2024-02-13_08-58-21.py\n2024-02-14 08:47:33 308 bytes todo\n2024-02-13 01:40:23 3081 bytes README.md\n2024-02-05 07:57:14 45 bytes .gitignore\n2024-02-07 09:47:28 5 items /.env\n2024-02-14 13:26:01 13 items /examples\n2024-02-13 13:19:10 3 items /scripts\n2024-02-14 09:25:18 3380 bytes octagon.png\n2024-02-14 13:22:51 13 items /.git\n2024-02-09 02:29:04 58388 bytes old_training_data.jsonl\n2024-02-14 08:46:44 4 items /my_env\n2024-02-05 07:56:58 1 items /src\nThe last commit message is: Pip install not found modules (#61)\n\nIf the llm tries to use a module that cannot be found then prompt the\r\nuser to install it with pip.\r\nMisc:\r\n* Moved execution specific utils from utils to execute_script\r\n* Removed almost all the requirements\r\n* Give errors from the script to the llm (was broken by move to subprocess)\r\n\r\nCo-authored-by: biobootloader <[email protected]>\r\n\r\n---------\r\n\r\nCo-authored-by: biobootloader <[email protected]>"
"content": "Today's date is 2024-02-14 13:27:51.\nThe current working directory is /Users/jakekoenig/rawdog, which IS a git repository.\nThe user's operating system is Darwin.\nThe last commit message is: Pip install not found modules (#61)\n\nIf the llm tries to use a module that cannot be found then prompt the\r\nuser to install it with pip.\r\nMisc:\r\n* Moved execution specific utils from utils to execute_script\r\n* Removed almost all the requirements\r\n* Give errors from the script to the llm (was broken by move to subprocess)\r\n\r\nCo-authored-by: biobootloader <[email protected]>\r\n\r\n---------\r\n\r\nCo-authored-by: biobootloader <[email protected]>"
},
{
"role": "user",
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/grep.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
{
"role": "system",
"content": "Today's date is 2024-02-14 13:28:17.\nThe current working directory is /Users/jakekoenig/rawdog, which IS a git repository.\nThe user's operating system is Darwin.\nThe contents of the current working directory are:\n2024-02-05 07:56:58 11339 bytes LICENSE\n2024-02-14 13:22:51 32 bytes requirements.txt\n2024-02-07 09:47:43 4 items /dist\n2024-02-14 13:22:51 630 bytes pyproject.toml\n2024-02-13 09:38:11 60746 bytes training_data.jsonl\n2024-02-05 07:56:58 1 items /rawdog\n2024-02-13 08:58:21 5247 bytes script_2024-02-13_08-58-21.py\n2024-02-14 08:47:33 308 bytes todo\n2024-02-13 01:40:23 3081 bytes README.md\n2024-02-05 07:57:14 45 bytes .gitignore\n2024-02-07 09:47:28 5 items /.env\n2024-02-14 13:26:01 13 items /examples\n2024-02-13 13:19:10 3 items /scripts\n2024-02-14 09:25:18 3380 bytes octagon.png\n2024-02-14 13:22:51 13 items /.git\n2024-02-09 02:29:04 58388 bytes old_training_data.jsonl\n2024-02-14 08:46:44 4 items /my_env\n2024-02-05 07:56:58 1 items /src\nThe last commit message is: Pip install not found modules (#61)\n\nIf the llm tries to use a module that cannot be found then prompt the\r\nuser to install it with pip.\r\nMisc:\r\n* Moved execution specific utils from utils to execute_script\r\n* Removed almost all the requirements\r\n* Give errors from the script to the llm (was broken by move to subprocess)\r\n\r\nCo-authored-by: biobootloader <[email protected]>\r\n\r\n---------\r\n\r\nCo-authored-by: biobootloader <[email protected]>"
"content": "Today's date is 2024-02-14 13:28:17.\nThe current working directory is /Users/jakekoenig/rawdog, which IS a git repository.\nThe user's operating system is Darwin.\nThe last commit message is: Pip install not found modules (#61)\n\nIf the llm tries to use a module that cannot be found then prompt the\r\nuser to install it with pip.\r\nMisc:\r\n* Moved execution specific utils from utils to execute_script\r\n* Removed almost all the requirements\r\n* Give errors from the script to the llm (was broken by move to subprocess)\r\n\r\nCo-authored-by: biobootloader <[email protected]>\r\n\r\n---------\r\n\r\nCo-authored-by: biobootloader <[email protected]>"
},
{
"role": "user",
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
{
"role": "system",
"content": "Today's date is 2024-02-14 13:26:11.\nThe current working directory is /Users/jakekoenig/rawdog, which IS a git repository.\nThe user's operating system is Darwin.\nThe contents of the current working directory are:\n2024-02-05 07:56:58 11339 bytes LICENSE\n2024-02-14 13:22:51 32 bytes requirements.txt\n2024-02-07 09:47:43 4 items /dist\n2024-02-14 13:22:51 630 bytes pyproject.toml\n2024-02-13 09:38:11 60746 bytes training_data.jsonl\n2024-02-05 07:56:58 1 items /rawdog\n2024-02-13 08:58:21 5247 bytes script_2024-02-13_08-58-21.py\n2024-02-14 08:47:33 308 bytes todo\n2024-02-13 01:40:23 3081 bytes README.md\n2024-02-05 07:57:14 45 bytes .gitignore\n2024-02-07 09:47:28 5 items /.env\n2024-02-14 13:26:01 13 items /examples\n2024-02-13 13:19:10 3 items /scripts\n2024-02-14 09:25:18 3380 bytes octagon.png\n2024-02-14 13:22:51 13 items /.git\n2024-02-09 02:29:04 58388 bytes old_training_data.jsonl\n2024-02-14 08:46:44 4 items /my_env\n2024-02-05 07:56:58 1 items /src\nThe last commit message is: Pip install not found modules (#61)\n\nIf the llm tries to use a module that cannot be found then prompt the\r\nuser to install it with pip.\r\nMisc:\r\n* Moved execution specific utils from utils to execute_script\r\n* Removed almost all the requirements\r\n* Give errors from the script to the llm (was broken by move to subprocess)\r\n\r\nCo-authored-by: biobootloader <[email protected]>\r\n\r\n---------\r\n\r\nCo-authored-by: biobootloader <[email protected]>"
"content": "Today's date is 2024-02-14 13:26:11.\nThe current working directory is /Users/jakekoenig/rawdog, which IS a git repository.\nThe user's operating system is Darwin.\nThe last commit message is: Pip install not found modules (#61)\n\nIf the llm tries to use a module that cannot be found then prompt the\r\nuser to install it with pip.\r\nMisc:\r\n* Moved execution specific utils from utils to execute_script\r\n* Removed almost all the requirements\r\n* Give errors from the script to the llm (was broken by move to subprocess)\r\n\r\nCo-authored-by: biobootloader <[email protected]>\r\n\r\n---------\r\n\r\nCo-authored-by: biobootloader <[email protected]>"
},
{
"role": "user",
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
{
"role": "system",
"content": "Today's date is 2024-02-14 13:33:57.\nThe current working directory is /Users/jakekoenig/rawdog, which IS a git repository.\nThe user's operating system is Darwin.\nThe contents of the current working directory are:\n2024-02-05 07:56:58 11339 bytes LICENSE\n2024-02-14 13:22:51 32 bytes requirements.txt\n2024-02-07 09:47:43 4 items /dist\n2024-02-14 13:22:51 630 bytes pyproject.toml\n2024-02-13 09:38:11 60746 bytes training_data.jsonl\n2024-02-05 07:56:58 1 items /rawdog\n2024-02-13 08:58:21 5247 bytes script_2024-02-13_08-58-21.py\n2024-02-14 08:47:33 308 bytes todo\n2024-02-13 01:40:23 3081 bytes README.md\n2024-02-05 07:57:14 45 bytes .gitignore\n2024-02-07 09:47:28 5 items /.env\n2024-02-14 13:26:01 13 items /examples\n2024-02-13 13:19:10 3 items /scripts\n2024-02-14 09:25:18 3380 bytes octagon.png\n2024-02-14 13:22:51 13 items /.git\n2024-02-09 02:29:04 58388 bytes old_training_data.jsonl\n2024-02-14 08:46:44 4 items /my_env\n2024-02-05 07:56:58 1 items /src\nThe last commit message is: Pip install not found modules (#61)\n\nIf the llm tries to use a module that cannot be found then prompt the\r\nuser to install it with pip.\r\nMisc:\r\n* Moved execution specific utils from utils to execute_script\r\n* Removed almost all the requirements\r\n* Give errors from the script to the llm (was broken by move to subprocess)\r\n\r\nCo-authored-by: biobootloader <[email protected]>\r\n\r\n---------\r\n\r\nCo-authored-by: biobootloader <[email protected]>"
"content": "Today's date is 2024-02-14 13:33:57.\nThe current working directory is /Users/jakekoenig/rawdog, which IS a git repository.\nThe user's operating system is Darwin.\nThe last commit message is: Pip install not found modules (#61)\n\nIf the llm tries to use a module that cannot be found then prompt the\r\nuser to install it with pip.\r\nMisc:\r\n* Moved execution specific utils from utils to execute_script\r\n* Removed almost all the requirements\r\n* Give errors from the script to the llm (was broken by move to subprocess)\r\n\r\nCo-authored-by: biobootloader <[email protected]>\r\n\r\n---------\r\n\r\nCo-authored-by: biobootloader <[email protected]>"
},
{
"role": "user",
Expand Down
29 changes: 1 addition & 28 deletions src/rawdog/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def _set_from_dict(self, data):
self.cwd = data["cwd"]
self.os = data["os"]
self.is_git = data["is_git"]
self.cwd_info = data["cwd_info"]
self.last_commit = data["last_commit"]
self.retries = data["retries"]

Expand All @@ -36,7 +35,6 @@ def _set_from_env(self):
self.os = platform.system()
_is_git = Path(".git").exists()
self.is_git = "IS" if _is_git else "is NOT"
self.cwd_info = self._get_cwd_info()
self.last_commit = (
""
if not _is_git
Expand All @@ -52,40 +50,15 @@ def _set_from_env(self):
_retries = 0 if self.config is None else self.config.get("retries")
self.retries = f"\nYou'll get {_retries} retries."

def _get_cwd_info(self, max_items=100):
output = []
for i, item in enumerate(self.cwd.iterdir()):
if i >= max_items:
break
name = ("" if not item.is_dir() else "/") + item.name
last_modified = datetime.datetime.fromtimestamp(
item.stat().st_mtime
).strftime("%Y-%m-%d %H:%M:%S")
size, unit = 0, ""
try:
size = (
len(list(item.iterdir())) if item.is_dir() else item.stat().st_size
)
unit = " bytes" if item.is_file() else " items"
except Exception:
pass
output.append(f"{last_modified} {size:10}{unit} {name}")
if not output:
return "The directory is empty."
return "\n".join(output)

def render_prompt(self):
return """\
Today's date is {date}.
The current working directory is {cwd}, which {is_git} a git repository.
The user's operating system is {os}.
The contents of the current working directory are:
{cwd_info}{last_commit}{retries}""".format(
The user's operating system is {os}.{last_commit}{retries}""".format(
date=self.date,
cwd=self.cwd,
is_git=self.is_git,
os=self.os,
cwd_info=self.cwd_info,
last_commit=self.last_commit,
retries=self.retries,
)
Expand Down

0 comments on commit fe57bda

Please sign in to comment.