Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Yiannis128 committed Nov 13, 2024
1 parent 2a1c639 commit 0dcac28
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
16 changes: 7 additions & 9 deletions esbmc_ai/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,15 @@
help_command: HelpCommand = HelpCommand()
fix_code_command: FixCodeCommand = FixCodeCommand()
exit_command: ExitCommand = ExitCommand()
command_runner: CommandRunner = CommandRunner()

verifier_runner: VerifierRunner = VerifierRunner()
command_runner: CommandRunner = CommandRunner().init(
builtin_commands=[
help_command,
exit_command,
fix_code_command,
]
)

chat: UserChat

Expand Down Expand Up @@ -114,14 +120,6 @@ def print_assistant_response(

def _load_addons() -> None:
"""Manages loading addons"""
command_runner.init(
builtin_commands=[
help_command,
exit_command,
fix_code_command,
]
)

# Load all the addon commands
command_runner.addon_commands.clear()
command_runner.addon_commands.extend(
Expand Down
4 changes: 2 additions & 2 deletions esbmc_ai/chat_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ def dict_to_base_message(json_string: dict) -> BaseMessage:
raise Exception()


def list_to_base_messages(json_messages: list[dict]) -> list[BaseMessage]:
def list_to_base_messages(json_messages: list[dict]) -> tuple[BaseMessage, ...]:
"""Converts a list of messages from JSON format to a list of BaseMessage."""
return [dict_to_base_message(msg) for msg in json_messages]
return tuple(dict_to_base_message(msg) for msg in json_messages)
4 changes: 3 additions & 1 deletion esbmc_ai/command_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __new__(cls):
cls.instance = super(CommandRunner, cls).__new__(cls)
return cls.instance

def init(self, builtin_commands: list[ChatCommand]) -> None:
def init(self, builtin_commands: list[ChatCommand]) -> "CommandRunner":
self._builtin_commands: list[ChatCommand] = builtin_commands.copy()
self._addon_commands: list[ChatCommand] = []

Expand All @@ -23,6 +23,8 @@ def init(self, builtin_commands: list[ChatCommand]) -> None:
assert isinstance(cmd, HelpCommand)
cmd.commands = self.commands

return self

@property
def commands(self) -> list[ChatCommand]:
"""Returns all commands. The list is copied."""
Expand Down

0 comments on commit 0dcac28

Please sign in to comment.