Feat : integration of more code interpreter

This commit is contained in:
martin legrand 2025-03-02 11:10:17 +01:00
parent 5bc2c26757
commit bba98786f5
3 changed files with 14 additions and 11 deletions

View File

@ -1,7 +1,7 @@
from sources.tools import PyInterpreter, BashInterpreter
from sources.utility import pretty_print from sources.utility import pretty_print
from sources.agent import Agent, executorResult from sources.agent import Agent, executorResult
from sources.tools import PyInterpreter, BashInterpreter, CInterpreter, GoInterpreter
class CoderAgent(Agent): class CoderAgent(Agent):
def __init__(self, model, name, prompt_path, provider): def __init__(self, model, name, prompt_path, provider):
@ -9,6 +9,8 @@ class CoderAgent(Agent):
self.tools = { self.tools = {
"bash": BashInterpreter(), "bash": BashInterpreter(),
"python": PyInterpreter() "python": PyInterpreter()
"C": CInterpreter(),
"go": GoInterpreter()
} }
def remove_blocks(self, text: str) -> str: def remove_blocks(self, text: str) -> str:

View File

@ -5,6 +5,7 @@ import datetime
import uuid import uuid
import os import os
import json import json
from sources.utility import timer_decorator
class Memory(): class Memory():
""" """
@ -101,16 +102,6 @@ class Memory():
) )
summary = self.tokenizer.decode(summary_ids[0], skip_special_tokens=True) summary = self.tokenizer.decode(summary_ids[0], skip_special_tokens=True)
return summary return summary
def timer_decorator(func):
from time import time
def wrapper(*args, **kwargs):
start_time = time()
result = func(*args, **kwargs)
end_time = time()
print(f"{func.__name__} took {end_time - start_time:.2f} seconds to execute")
return result
return wrapper
@timer_decorator @timer_decorator
def compress(self) -> str: def compress(self) -> str:

View File

@ -35,3 +35,13 @@ def pretty_print(text, color = "info"):
if color not in color_map: if color not in color_map:
color = "default" color = "default"
print(colored(text, color_map[color])) print(colored(text, color_map[color]))
def timer_decorator(func):
from time import time
def wrapper(*args, **kwargs):
start_time = time()
result = func(*args, **kwargs)
end_time = time()
print(f"{func.__name__} took {end_time - start_time:.2f} seconds to execute")
return result
return wrapper