Skip to content

Commit 69c6302

Browse files
committed
Construct system message with try excepts
1 parent 8514f0d commit 69c6302

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

interpreter_1/interpreter.py

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,31 @@ def from_profile(cls, path):
191191
return cls(Profile.from_file(path))
192192

193193
def default_system_message(self):
194-
system_message = f"""<SYSTEM_CAPABILITY>
195-
* You are an AI assistant with access to a machine running on {"Mac OS" if platform.system() == "Darwin" else platform.system()} with internet access.
196-
* The current date is {datetime.today().strftime('%A, %B %d, %Y')}.
197-
* The user's cwd is {os.getcwd()} and username is {os.getlogin()}.
198-
</SYSTEM_CAPABILITY>"""
194+
system_message = "<SYSTEM_CAPABILITY>\n"
195+
196+
try:
197+
system_message += f"* You are an AI assistant with access to a machine running on {'Mac OS' if platform.system() == 'Darwin' else platform.system()} with internet access.\n"
198+
except:
199+
print("Error adding system capability for platform")
200+
201+
try:
202+
system_message += (
203+
f"* The current date is {datetime.today().strftime('%A, %B %d, %Y')}.\n"
204+
)
205+
except:
206+
print("Error adding system capability for date")
207+
208+
try:
209+
cwd_line = f"* The user's cwd is {os.getcwd()}"
210+
try:
211+
cwd_line += f" and username is {os.getlogin()}"
212+
except:
213+
print("Error adding system capability for username")
214+
system_message += cwd_line + "\n"
215+
except:
216+
print("Error adding system capability for cwd")
217+
218+
system_message += "</SYSTEM_CAPABILITY>"
199219

200220
# Add web search capability if enabled
201221
if (

0 commit comments

Comments
 (0)