Skip to content

Commit

Permalink
Change shared model stream output schema
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Sep 9, 2024
1 parent 7493033 commit 09c9bb5
Showing 1 changed file with 24 additions and 28 deletions.
52 changes: 24 additions & 28 deletions plugins/kernels/fps_kernels/kernel_driver/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,24 +228,16 @@ async def _handle_outputs(self, outputs: Array, msg: Dict[str, Any]):
text = text[:-1]
if (not outputs) or (outputs[-1]["name"] != content["name"]): # type: ignore
outputs.append(
#Map(
# {
# "name": content["name"],
# "output_type": msg_type,
# "text": Array([content["text"]]),
# }
#)
{
"name": content["name"],
"output_type": msg_type,
"text": [text],
}
Map(
{
"name": content["name"],
"output_type": msg_type,
"text": Array([content["text"]]),
}
)
)
else:
#outputs[-1]["text"].append(content["text"]) # type: ignore
last_output = outputs[-1]
last_output["text"].append(text) # type: ignore
outputs[-1] = last_output
outputs[-1]["text"].append(content["text"]) # type: ignore
elif msg_type in ("display_data", "execute_result"):
if "application/vnd.jupyter.ywidget-view+json" in content["data"]:
# this is a collaborative widget
Expand All @@ -258,21 +250,25 @@ async def _handle_outputs(self, outputs: Array, msg: Dict[str, Any]):
outputs.append(doc)
else:
outputs.append(
{
"data": {"text/plain": [content["data"].get("text/plain", "")]},
"execution_count": content["execution_count"],
"metadata": {},
"output_type": msg_type,
}
Map(
{
"data": {"text/plain": [content["data"].get("text/plain", "")]},
"execution_count": content["execution_count"],
"metadata": {},
"output_type": msg_type,
}
)
)
elif msg_type == "error":
outputs.append(
{
"ename": content["ename"],
"evalue": content["evalue"],
"output_type": "error",
"traceback": content["traceback"],
}
Map(
{
"ename": content["ename"],
"evalue": content["evalue"],
"output_type": "error",
"traceback": content["traceback"],
}
)
)


Expand Down

0 comments on commit 09c9bb5

Please sign in to comment.