Skip to content

Commit

Permalink
Fix context file error #1
Browse files Browse the repository at this point in the history
  • Loading branch information
pramitchoudhary committed May 30, 2023
1 parent a064450 commit 4742c5c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sidekick/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ def save_context(self, info: str, extract_context: bool = True) -> Dict:
if extract_context:
# Update context.json file for tracking entities
content_file_path = f"{self.path}/var/lib/tmp/data/context.json"
context_dict = extracted_entity
if Path(content_file_path).exists():
context_dict = json.load(open(content_file_path, "r"))
context_dict.update(extracted_entity)
with open(content_file_path, "w") as outfile:
json.dump(context_dict, outfile, indent=4, sort_keys=False)
with open(content_file_path, "w") as outfile:
json.dump(context_dict, outfile, indent=4, sort_keys=False)
return res
1 change: 1 addition & 0 deletions sidekick/prompter.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def update_context():
context_dict = """{\n"<new_context_key>": "<new_context_value>"\n}
"""
content_file_path = f"{base_path}/var/lib/tmp/data/context.json"
context_str = context_dict
if Path(f"{base_path}/var/lib/tmp/data/context.json").exists():
context_dict = json.load(open(content_file_path, "r"))
context_dict["<new_context_key>"] = "<new_context_value"
Expand Down

0 comments on commit 4742c5c

Please sign in to comment.