render tool reponse
This commit is contained in:
35
src/messageDetail.tsx
Normal file
35
src/messageDetail.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import { ChatStoreMessage } from "./app";
|
||||
|
||||
interface Props {
|
||||
chat: ChatStoreMessage;
|
||||
renderMarkdown: boolean;
|
||||
}
|
||||
export function MessageDetail({ chat, renderMarkdown }: Props) {
|
||||
if (typeof chat.content === "string") {
|
||||
return <div></div>;
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
{chat.content.map((mdt) =>
|
||||
mdt.type === "text" ? (
|
||||
chat.hide ? (
|
||||
mdt.text?.split("\n")[0].slice(0, 16) + "... (deleted)"
|
||||
) : renderMarkdown ? (
|
||||
// @ts-ignore
|
||||
<Markdown markdown={mdt.text} />
|
||||
) : (
|
||||
mdt.text
|
||||
)
|
||||
) : (
|
||||
<img
|
||||
className="cursor-pointer max-w-xs max-h-32 p-1"
|
||||
src={mdt.image_url?.url}
|
||||
onClick={() => {
|
||||
window.open(mdt.image_url?.url, "_blank");
|
||||
}}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user