-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext_manager.py
More file actions
40 lines (31 loc) · 1.3 KB
/
context_manager.py
File metadata and controls
40 lines (31 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class ContextManager:
def __init__(self):
self.global_context = {
"summaries": {},
"previous_prompts": [],
"analyzed_files": [],
"analyzed_directories": [],
"file_contents": {},
"interaction_history": []
}
def add_analyzed_directory(self, directory_path):
self.global_context["analyzed_directories"].append(directory_path)
def add_analyzed_file(self, file_path):
self.global_context["analyzed_files"].append(file_path)
def add_file_content(self, file_path, content):
self.global_context["file_contents"][file_path] = content
def add_summary(self, key, summary):
self.global_context["summaries"][key] = summary
def add_previous_prompt(self, prompt):
self.global_context["previous_prompts"].append(prompt)
def add_interaction(self, interaction):
self.global_context["interaction_history"].append(interaction)
def summarize_previous_interactions(self):
summary = "Summary of previous interactions:\n"
for item in self.global_context["interaction_history"]:
summary += f"{item}\n"
return summary
def get_context(self):
return self.global_context
# Instantiate context manager
context_manager = ContextManager()