Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix llama 3 code halucination #1250

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions interpreter/core/computer/terminal/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ def run(self, language, code, stream=False, display=False):
self.computer._has_imported_skills = True
self.computer.skills.import_skills()

# Llama 3 likes to hallucinate this tick new line thing at the start of code blocks
if code.startswith("`\n"):
code = code[2:].strip()

if stream == False:
# If stream == False, *pull* from _streaming_run.
output_messages = []
Expand Down
5 changes: 5 additions & 0 deletions interpreter/core/respond.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ def respond(interpreter):
language = interpreter.messages[-1]["format"].lower().strip()
code = interpreter.messages[-1]["content"]

if code.startswith("`\n"):
code = code[2:].strip()
if interpreter.verbose:
print("Removing `\n")

if language == "text":

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`interpreter/core/respond.py```

# It does this sometimes just to take notes. Let it, it's useful.
# In the future we should probably not detect this behavior as code at all.
Expand Down