|
|
@ -82,16 +82,20 @@ def teach():
|
|
|
|
elif step.strip() == "":
|
|
|
|
elif step.strip() == "":
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
logger.info(f"Performing step: {step}")
|
|
|
|
logger.info(f"Performing step: {step}")
|
|
|
|
|
|
|
|
root.update()
|
|
|
|
chunk_code = ""
|
|
|
|
chunk_code = ""
|
|
|
|
interpreter.computer.languages = [l for l in interpreter.computer.languages if l.name.lower() == "python"]
|
|
|
|
interpreter.computer.languages = [l for l in interpreter.computer.languages if l.name.lower() == "python"]
|
|
|
|
interpreter.force_task_completion = True
|
|
|
|
interpreter.force_task_completion = True
|
|
|
|
for chunk in interpreter.chat(step, stream=True, display=False):
|
|
|
|
for chunk in interpreter.chat(step, stream=True, display=False):
|
|
|
|
if "format" in chunk and chunk["format"] == "execution":
|
|
|
|
if chunk["role"] == "computer" and "start" not in chunk and "end" not in chunk:
|
|
|
|
content = chunk["content"]
|
|
|
|
chunk_type = chunk["type"]
|
|
|
|
language = content["format"]
|
|
|
|
chunk_content = chunk["content"]
|
|
|
|
code = content["content"]
|
|
|
|
chunk_format = chunk["format"]
|
|
|
|
chunk_code += code
|
|
|
|
if chunk_type == "confirmation" and chunk_format == "execution" and chunk_content["type"] == "code" and chunk_content["format"] == "python":
|
|
|
|
# interpreter.computer.run(code, language)
|
|
|
|
chunk_code += chunk_content["content"]
|
|
|
|
|
|
|
|
elif chunk_type == "console" and chunk_format == "output" and ("Traceback" in chunk_content or "Error" in chunk_content or "Exception" in chunk_content):
|
|
|
|
|
|
|
|
# this was an error so we disregard chunk_code
|
|
|
|
|
|
|
|
chunk_code = ""
|
|
|
|
time.sleep(0.05)
|
|
|
|
time.sleep(0.05)
|
|
|
|
accumulator.accumulate(chunk)
|
|
|
|
accumulator.accumulate(chunk)
|
|
|
|
|
|
|
|
|
|
|
|