Skip to content

Commit db172e5

Browse files
committed
Hallucination fix
1 parent fe34c1a commit db172e5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

interpreter/core/respond.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,21 @@ def respond(interpreter):
181181
except:
182182
pass
183183

184+
if code.endswith("executeexecute"):
185+
edited_code = code.replace("executeexecute", "")
186+
try:
187+
code_dict = json.loads(edited_code)
188+
language = code_dict.get("language", language)
189+
code = code_dict.get("code", code)
190+
interpreter.messages[-1][
191+
"content"
192+
] = code # So the LLM can see it.
193+
interpreter.messages[-1][
194+
"format"
195+
] = language # So the LLM can see it.
196+
except:
197+
pass
198+
184199
if code.replace("\n", "").replace(" ", "").startswith('{"language":'):
185200
try:
186201
code_dict = json.loads(code)

0 commit comments

Comments
 (0)