适配上传不同类型的文件,适配gpt-4-all,支持包含vision字段的模型,自动打开上传文件按钮

This commit is contained in:
Clivia
2024-02-08 02:30:45 +00:00
parent 9212773d88
commit f6afa671ed
5 changed files with 135 additions and 39 deletions

View File

@@ -121,10 +121,25 @@ function _MarkDownContent(props: { content: string; imageBase64?: string }) {
() => escapeDollarNumber(props.content),
[props.content],
);
// 判断文件路径
const isImage = (filename: any) => {
const imageExtensions = ['.png', '.jpg', '.jpeg', '.gif', '.bmp', '.webp', '.tiff'];
return imageExtensions.some(ext => filename.toLowerCase().endsWith(ext));
};
const show_filename = (base64: any) => {
let parts = base64.split("/");
return parts.pop();
};
return (
<div style={{ fontSize: "inherit" }}>
{props.imageBase64 && <img src={props.imageBase64} alt="" />}
{props.imageBase64 && isImage(props.imageBase64) && <img src={props.imageBase64} alt="" />}
{props.imageBase64 && !isImage(props.imageBase64) &&
<a href={props.imageBase64} style={{ fontWeight: 'bold' }}>
{show_filename(props.imageBase64)}
</a>
}
<ReactMarkdown
remarkPlugins={[RemarkMath, RemarkGfm, RemarkBreaks]}
rehypePlugins={[