Skip to content

Commit

Permalink
Hsl/fix image issue (microsoft#225)
Browse files Browse the repository at this point in the history
Fix bug of "cannot upload image" since image is not File type.
Fix bug of display images generated not from the plot.show(), path is
wrong.
  • Loading branch information
ShilinHe authored Mar 5, 2024
1 parent 186cada commit 71a8f35
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions playground/UI/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def file_display(files: List[Tuple[str, str]], session_cwd_path: str):
image = cl.Image(
name=file_path,
display="inline",
path=file_path,
path=file_path if os.path.isabs(file_path) else os.path.join(session_cwd_path, file_path),
size="large",
)
elements.append(image)
Expand Down Expand Up @@ -378,7 +378,6 @@ async def start():
"https://microsoft.github.io/TaskWeaver/docs/code_execution).",
)


@cl.on_chat_end
async def end():
user_session_id = cl.user_session.get("id")
Expand All @@ -395,7 +394,6 @@ async def main(message: cl.Message):
session_cwd_path = session.execution_cwd

# display loader before sending message

async with cl.Step(name="", show_input=True, root=True) as root_step:
response_round = await cl.make_async(session.send_message)(
message.content,
Expand All @@ -405,7 +403,7 @@ async def main(message: cl.Message):
"path": element.path,
}
for element in message.elements
if element.type == "file"
if element.type == "file" or element.type == "image"
],
event_handler=ChainLitMessageUpdater(root_step),
)
Expand Down Expand Up @@ -444,7 +442,6 @@ async def main(message: cl.Message):
f"{img_prefix}[{file_name}]({file_path})",
file_name,
)

elements = file_display(files, session_cwd_path)
await cl.Message(
author="TaskWeaver",
Expand Down

0 comments on commit 71a8f35

Please sign in to comment.