Skip to content

Commit d316a99

Browse files
authored
Merge pull request #1250 from Notnaton/fix-llama3-code-halucination
Fix llama 3 code halucination
2 parents 4939bed + 18c2afa commit d316a99

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

interpreter/core/computer/terminal/terminal.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ def run(self, language, code, stream=False, display=False):
5151
self.computer._has_imported_skills = True
5252
self.computer.skills.import_skills()
5353

54-
# Llama 3 likes to hallucinate this tick new line thing at the start of code blocks
55-
if code.startswith("`\n"):
56-
code = code[2:].strip()
57-
5854
if stream == False:
5955
# If stream == False, *pull* from _streaming_run.
6056
output_messages = []

interpreter/core/respond.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ def respond(interpreter):
130130
language = interpreter.messages[-1]["format"].lower().strip()
131131
code = interpreter.messages[-1]["content"]
132132

133+
if code.startswith("`\n"):
134+
code = code[2:].strip()
135+
if interpreter.verbose:
136+
print("Removing `\n")
137+
133138
if language == "text":
134139
# It does this sometimes just to take notes. Let it, it's useful.
135140
# In the future we should probably not detect this behavior as code at all.

0 commit comments

Comments
 (0)