Skip to content

Commit

Permalink
wtf respects profiles 🇺🇸
Browse files Browse the repository at this point in the history
  • Loading branch information
KillianLucas committed Jul 5, 2024
1 parent 9792749 commit 32083b1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
4 changes: 4 additions & 0 deletions interpreter/terminal_interface/profiles/defaults/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ computer:
# verbose: False # If True, will print detailed logs
# multi_line: False # If True, you can input multiple lines starting and ending with ```

# To use a separate model for the `wtf` command:
# wtf:
# model: "gpt-3.5-turbo"

# Documentation
# All options: https://docs.openinterpreter.com/settings
21 changes: 14 additions & 7 deletions interpreter/terminal_interface/profiles/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,15 @@ def normalize_text(message):
def apply_profile_to_object(obj, profile):
for key, value in profile.items():
if isinstance(value, dict):
if (
key == "wtf"
): # The wtf command has a special part of the profile, not used here
continue
apply_profile_to_object(getattr(obj, key), value)
else:
setattr(obj, key, value)


def open_storage_dir(directory):
dir = os.path.join(oi_dir, directory)

Expand Down Expand Up @@ -763,25 +768,27 @@ def migrate_user_app_directory():

def write_key_to_profile(key, value):
try:
with open(user_default_profile_path, 'r') as file:
with open(user_default_profile_path, "r") as file:
lines = file.readlines()

version_line_index = None
new_lines = []
for index, line in enumerate(lines):
if line.strip().startswith("version:"):
version_line_index = index
break
new_lines.append(line)

# Insert the new key-value pair before the version line
if version_line_index is not None:
if f"{key}: {value}\n" not in new_lines:
new_lines.append(f"{key}: {value}\n\n") # Adding a newline for separation
new_lines.append(
f"{key}: {value}\n\n"
) # Adding a newline for separation
# Append the version line and all subsequent lines
new_lines.extend(lines[version_line_index:])
with open(user_default_profile_path, 'w') as file:

with open(user_default_profile_path, "w") as file:
file.writelines(new_lines)
except Exception:
pass # Fail silently
pass # Fail silently
6 changes: 5 additions & 1 deletion scripts/wtf.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ def main():
try:
with open(default_profile_path, "r") as file:
profile = yaml.safe_load(file)
model = profile.get("llm", {}).get("model", "gpt-3.5-turbo")
wtf_model = profile.get("wtf", {}).get("model")
if wtf_model:
model = wtf_model
else:
model = profile.get("llm", {}).get("model", "gpt-3.5-turbo")
except:
model = "gpt-3.5-turbo"

Expand Down

0 comments on commit 32083b1

Please sign in to comment.