Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Jasmine <coldlando@hotmail.com>
  • Loading branch information
sudoskys and coderabbitai[bot] authored Apr 20, 2024
1 parent 06a22e6 commit 2fb6683
Showing 1 changed file with 11 additions and 27 deletions.
38 changes: 11 additions & 27 deletions llmkira/extra/plugins/e2b_code_interpreter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,38 +36,22 @@ class exec_python(BaseModel):

def parse_e2b_jupyter_output(results: List[E2BResult]):
file_list = []
format_suffix_map = {
"html": "html", "markdown": "md", "svg": "svg", "png": "png",
"jpeg": "jpeg", "pdf": "pdf", "latex": "latex", "json": "json",
"javascript": "js", "txt": "txt"
}
for exc in results:
formats = exc.formats()
for fort in formats:
for fort in exc.formats():
logger.debug(f"e2b return format: {fort}")
if getattr(exc, fort):
# example how to show the image / prove it works
file_ = base64.b64decode(getattr(exc, fort))
content = getattr(exc, fort, None)
if content:
file_ = base64.b64decode(content)
file_io = io.BytesIO(file_)
if fort == "html":
file_suffix = "html"
elif fort == "markdown":
file_suffix = "md"
elif fort == "svg":
file_suffix = "svg"
elif fort == "png":
file_suffix = "png"
elif fort == "jpeg":
file_suffix = "jpeg"
elif fort == "pdf":
file_suffix = "pdf"
elif fort == "latex":
file_suffix = "latex"
elif fort == "json":
file_suffix = "json"
elif fort == "javascript":
file_suffix = "js"
else:
file_suffix = "txt"
file_suffix = format_suffix_map.get(fort, "txt")
file_name = f"e2b_{fort}.{file_suffix}"
logger.debug(f"e2b return format: {file_name}")
file_pair = (file_name, file_io)
file_list.append(file_pair)
file_list.append((file_name, file_io))
return file_list


Expand Down

0 comments on commit 2fb6683

Please sign in to comment.