mirror of
https://github.com/tcsenpai/agenticSeek.git
synced 2025-06-06 11:05:26 +00:00
fix : various bugs & improve memory system
This commit is contained in:
parent
caf1b5e9a9
commit
8b5bb28c94
@ -17,7 +17,7 @@ class BrowserAgent(Agent):
|
||||
self.tools = {
|
||||
"web_search": searxSearch(),
|
||||
}
|
||||
self.role = "Web Research"
|
||||
self.role = "Web surfing, website & news"
|
||||
self.type = "browser_agent"
|
||||
self.browser = Browser()
|
||||
self.current_page = ""
|
||||
|
@ -18,7 +18,7 @@ class CasualAgent(Agent):
|
||||
"file_finder": FileFinder(),
|
||||
"bash": BashInterpreter()
|
||||
}
|
||||
self.role = "Chat and Conversation"
|
||||
self.role = "talk, quick search"
|
||||
self.type = "casual_agent"
|
||||
|
||||
def process(self, prompt, speech_module) -> str:
|
||||
|
@ -20,7 +20,7 @@ class CoderAgent(Agent):
|
||||
"go": GoInterpreter(),
|
||||
"file_finder": FileFinder()
|
||||
}
|
||||
self.role = "Code Assistance"
|
||||
self.role = "Coding task"
|
||||
self.type = "code_agent"
|
||||
|
||||
def process(self, prompt, speech_module) -> str:
|
||||
|
@ -18,23 +18,15 @@ class FileAgent(Agent):
|
||||
self.type = "file_agent"
|
||||
|
||||
def process(self, prompt, speech_module) -> str:
|
||||
complete = False
|
||||
exec_success = False
|
||||
self.memory.push('user', prompt)
|
||||
|
||||
self.wait_message(speech_module)
|
||||
while not complete:
|
||||
if exec_success:
|
||||
complete = True
|
||||
animate_thinking("Thinking...", color="status")
|
||||
answer, reasoning = self.llm_request()
|
||||
exec_success, _ = self.execute_modules(answer)
|
||||
answer = self.remove_blocks(answer)
|
||||
self.last_answer = answer
|
||||
complete = True
|
||||
for name, tool in self.tools.items():
|
||||
if tool.found_executable_blocks():
|
||||
complete = False # AI read results and continue the conversation
|
||||
animate_thinking("Thinking...", color="status")
|
||||
answer, reasoning = self.llm_request()
|
||||
exec_success, _ = self.execute_modules(answer)
|
||||
answer = self.remove_blocks(answer)
|
||||
self.last_answer = answer
|
||||
return answer, reasoning
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -28,7 +28,7 @@ class Browser:
|
||||
'Accept-Language': 'en-US,en;q=0.9',
|
||||
'Referer': 'https://www.google.com/',
|
||||
}
|
||||
self.js_scripts_folder = "./web_scripts/"
|
||||
self.js_scripts_folder = "./sources/web_scripts/"
|
||||
try:
|
||||
chrome_options = Options()
|
||||
chrome_path = self.get_chrome_path()
|
||||
@ -258,7 +258,7 @@ class Browser:
|
||||
|
||||
except Exception as e:
|
||||
self.logger.error(f"Error extracting form inputs: {str(e)}")
|
||||
return f"Error extracting form inputs."
|
||||
return [f"Error extracting form inputs."]
|
||||
|
||||
def get_buttons_xpath(self) -> List[str]:
|
||||
"""
|
||||
|
@ -80,10 +80,10 @@ class Memory():
|
||||
|
||||
def push(self, role: str, content: str) -> None:
|
||||
"""Push a message to the memory."""
|
||||
self.memory.append({'role': role, 'content': content})
|
||||
# EXPERIMENTAL
|
||||
if self.memory_compression and role == 'assistant':
|
||||
self.compress()
|
||||
# we don't compress the last message
|
||||
self.memory.append({'role': role, 'content': content})
|
||||
|
||||
def clear(self) -> None:
|
||||
self.memory = []
|
||||
@ -133,9 +133,9 @@ class Memory():
|
||||
if not self.memory_compression:
|
||||
return
|
||||
for i in range(len(self.memory)):
|
||||
if i <= 2:
|
||||
if i < 3:
|
||||
continue
|
||||
if self.memory[i]['role'] == 'assistant':
|
||||
if len(self.memory[i]['content']) > 1024:
|
||||
self.memory[i]['content'] = self.summarize(self.memory[i]['content'])
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -35,6 +35,7 @@ class PyInterpreter(Tools):
|
||||
try:
|
||||
try:
|
||||
buffer = exec(code, global_vars)
|
||||
print(buffer)
|
||||
if buffer is not None:
|
||||
output = buffer + '\n'
|
||||
except Exception as e:
|
||||
|
Loading…
x
Reference in New Issue
Block a user