-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fcm_message_notice
- Loading branch information
Showing
8 changed files
with
356 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Author: Yiannis Charalambous | ||
|
||
from typing_extensions import override | ||
from langchain_core.messages import BaseMessage | ||
from esbmc_ai.solution_generator import SolutionGenerator | ||
from esbmc_ai.chat_response import FinishReason | ||
|
||
# TODO Test me | ||
|
||
|
||
class LatestStateSolutionGenerator(SolutionGenerator): | ||
"""SolutionGenerator that only shows the latest source code and verifier | ||
output state.""" | ||
|
||
@override | ||
def generate_solution(self) -> tuple[str, FinishReason]: | ||
# Backup message stack and clear before sending base message. We want | ||
# to keep the message stack intact because we will print it with | ||
# print_raw_conversation. | ||
messages: list[BaseMessage] = self.messages | ||
self.messages: list[BaseMessage] = [] | ||
solution, finish_reason = super().generate_solution() | ||
# Append last messages to the messages stack | ||
messages.extend(self.messages) | ||
# Restore | ||
self.messages = messages | ||
return solution, finish_reason |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Author: Yiannis Charalambous | ||
|
||
from langchain.schema import BaseMessage, HumanMessage | ||
from typing_extensions import override, Optional | ||
from esbmc_ai.solution_generator import ( | ||
SolutionGenerator, | ||
get_source_code_formatted, | ||
get_source_code_err_line_idx, | ||
get_clang_err_line_index, | ||
apply_line_patch, | ||
) | ||
from esbmc_ai.chat_response import FinishReason, ChatResponse | ||
|
||
# TODO Test me | ||
|
||
|
||
class ReverseOrderSolutionGenerator(SolutionGenerator): | ||
"""SolutionGenerator that shows the source code and verifier output state in | ||
reverse order.""" | ||
|
||
@override | ||
def send_message(self, message: Optional[str] = None) -> ChatResponse: | ||
# Reverse the messages | ||
messages: list[BaseMessage] = self.messages.copy() | ||
self.messages.reverse() | ||
|
||
response: ChatResponse = super().send_message(message) | ||
|
||
# Add to the reversed message the new message received by the LLM. | ||
messages.append(self.messages[-1]) | ||
# Restore | ||
self.messages = messages | ||
|
||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.