mirror of
https://github.com/tcsenpai/agenticSeek.git
synced 2025-06-04 18:20:09 +00:00
add tools log
This commit is contained in:
parent
6d1edf9184
commit
2cb7ac34ce
@ -47,7 +47,6 @@ Some rules:
|
||||
- Be efficient, no need to explain your code, unless asked.
|
||||
- You do not ever need to use bash to execute code.
|
||||
- Do not ever tell user how to run it. user know it.
|
||||
- In python do not use if __name__ == "__main__"
|
||||
- If using gui, make sure echap or exit button close the program
|
||||
- No lazyness, write and rewrite full code every time
|
||||
- If query is unclear say REQUEST_CLARIFICATION
|
@ -46,7 +46,6 @@ Some rules:
|
||||
- Be efficient, no need to explain your code, unless asked.
|
||||
- You do not ever need to use bash to execute code.
|
||||
- Do not ever tell user how to run it. user know it.
|
||||
- In python do not use if __name__ == "__main__"
|
||||
- If using gui, make sure echap close the program
|
||||
- No lazyness, write and rewrite full code every time
|
||||
- If query is unclear say REQUEST_CLARIFICATION
|
||||
|
@ -34,7 +34,7 @@ class Provider:
|
||||
}
|
||||
self.logger = Logger("provider.log")
|
||||
self.api_key = None
|
||||
self.unsafe_providers = ["openai", "deepseek", "dsk_deepseek"]
|
||||
self.unsafe_providers = ["openai", "deepseek", "dsk_deepseek", "together"]
|
||||
if self.provider_name not in self.available_providers:
|
||||
raise ValueError(f"Unknown provider: {provider_name}")
|
||||
if self.provider_name in self.unsafe_providers:
|
||||
|
@ -33,16 +33,24 @@ class PyInterpreter(Tools):
|
||||
'__name__': '__main__'
|
||||
}
|
||||
code = '\n\n'.join(codes)
|
||||
self.logger.info(f"Executing code:\n{code}")
|
||||
try:
|
||||
try:
|
||||
buffer = exec(code, global_vars)
|
||||
self.logger.info(f"Code executed successfully.\noutput:{buffer}")
|
||||
print(buffer)
|
||||
if buffer is not None:
|
||||
output = buffer + '\n'
|
||||
except SystemExit:
|
||||
self.logger.info("SystemExit caught, code execution stopped.")
|
||||
output = stdout_buffer.getvalue()
|
||||
return f"[SystemExit caught] Output before exit:\n{output}"
|
||||
except Exception as e:
|
||||
self.logger.error(f"Code execution failed: {str(e)}")
|
||||
return "code execution failed:" + str(e)
|
||||
output = stdout_buffer.getvalue()
|
||||
finally:
|
||||
self.logger.info("Code execution finished.")
|
||||
sys.stdout = sys.__stdout__
|
||||
return output
|
||||
|
||||
@ -75,7 +83,9 @@ class PyInterpreter(Tools):
|
||||
]
|
||||
combined_pattern = "|".join(error_patterns)
|
||||
if re.search(combined_pattern, feedback, re.IGNORECASE):
|
||||
self.logger.error(f"Execution failure detected: {feedback}")
|
||||
return True
|
||||
self.logger.info("No execution success detected.")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -21,6 +21,7 @@ import sys
|
||||
import os
|
||||
import configparser
|
||||
from abc import abstractmethod
|
||||
from sources.logger import Logger
|
||||
|
||||
sys.path.append('..')
|
||||
|
||||
@ -33,6 +34,7 @@ class Tools():
|
||||
self.api_key = None
|
||||
self.client = None
|
||||
self.messages = []
|
||||
self.logger = Logger("tools.log")
|
||||
self.config = configparser.ConfigParser()
|
||||
self.work_dir = self.create_work_dir()
|
||||
self.excutable_blocks_found = False
|
||||
@ -118,10 +120,12 @@ class Tools():
|
||||
"""
|
||||
if save_path is None:
|
||||
return
|
||||
self.logger.info(f"Saving blocks to {save_path}")
|
||||
save_path_dir = os.path.dirname(save_path)
|
||||
save_path_file = os.path.basename(save_path)
|
||||
directory = os.path.join(self.work_dir, save_path_dir)
|
||||
if directory and not os.path.exists(directory):
|
||||
self.logger.info(f"Creating directory {directory}")
|
||||
os.makedirs(directory)
|
||||
for block in blocks:
|
||||
with open(os.path.join(directory, save_path_file), 'w') as f:
|
||||
@ -199,6 +203,7 @@ class Tools():
|
||||
self.excutable_blocks_found = True
|
||||
code_blocks.append(content)
|
||||
start_index = end_pos + len(end_tag)
|
||||
self.logger.info(f"Found {len(code_blocks)} blocks to execute")
|
||||
return code_blocks, save_path
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
Loading…
x
Reference in New Issue
Block a user