Skip to content

Commit

Permalink
feat: Fix CLI agent delete functionality & allow importation of file …
Browse files Browse the repository at this point in the history
…for system prompt - attempt #2 (#1607)
  • Loading branch information
sarahwooders authored Aug 4, 2024
2 parents c4fdb35 + 614a226 commit eaa991b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions memgpt/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ def run(
agent: Annotated[Optional[str], typer.Option(help="Specify agent name")] = None,
human: Annotated[Optional[str], typer.Option(help="Specify human")] = None,
system: Annotated[Optional[str], typer.Option(help="Specify system prompt (raw text)")] = None,
system_file: Annotated[Optional[str], typer.Option(help="Specify raw text file containing system prompt")] = None,
# model flags
model: Annotated[Optional[str], typer.Option(help="Specify the LLM model")] = None,
model_wrapper: Annotated[Optional[str], typer.Option(help="Specify the LLM model wrapper")] = None,
Expand Down Expand Up @@ -651,6 +652,13 @@ def run(
persona_obj = ms.get_persona(persona, user.id)
# TODO pull system prompts from the metadata store
# NOTE: will be overriden later to a default
if system_file:
try:
with open(system_file, "r", encoding="utf-8") as file:
system = file.read().strip()
printd("Loaded system file successfully.")
except FileNotFoundError:
typer.secho(f"System file not found at {system_file}", fg=typer.colors.RED)
system_prompt = system if system else None
if human_obj is None:
typer.secho("Couldn't find human {human} in database, please run `memgpt add human`", fg=typer.colors.RED)
Expand Down
4 changes: 3 additions & 1 deletion memgpt/cli/cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,9 @@ def delete(option: str, name: str):
assert source is not None, f"Source {name} does not exist"
client.delete_source(source_id=source.id)
elif option == "agent":
client.delete_agent(name=name)
agent = client.get_agent(agent_name=name)
assert agent is not None, f"Agent {name} does not exist"
client.delete_agent(agent_id=agent.id)
elif option == "human":
human = client.get_human(name=name)
assert human is not None, f"Human {name} does not exist"
Expand Down

0 comments on commit eaa991b

Please sign in to comment.