Skip to content

Commit

Permalink
Merge pull request #72 from jswistak/fix/missing-snippets-counting
Browse files Browse the repository at this point in the history
Fix/missing snippets counting
  • Loading branch information
jswistak authored Jan 23, 2024
2 parents 1aa2269 + 13f492d commit 8b5969d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,11 @@ def _send_message_code(self) -> None:
code_snippets = self._extract_code_snippets_from_message(code_response)
output = []
first_snippet_idx = -1
if len(code_snippets) == 0:
self.code_messages_missing_snippets += 1
containsPythonSnippet = False
for code_snippet in code_snippets:
if not code_snippet.startswith("python"):
continue # Skip code snippets that are not in python

containsPythonSnippet = True
code = code_snippet[6:] # Remove 'python' from the code snippet
try:
cell_idx = self._execute_python_snippet(code)
Expand Down Expand Up @@ -123,6 +122,8 @@ def _send_message_code(self) -> None:

if self._runtime.check_if_plot_in_output(cell_idx):
output[-1] += "\n\nPlot was generated successfully."
if not containsPythonSnippet:
self.code_messages_missing_snippets += 1

if len(output) > 0:
code_response = self.format_code_assistant_message(
Expand Down

0 comments on commit 8b5969d

Please sign in to comment.