diff --git a/frontend/src/pages/Chat.tsx b/frontend/src/pages/Chat.tsx
index 9ce7fc6..838124d 100644
--- a/frontend/src/pages/Chat.tsx
+++ b/frontend/src/pages/Chat.tsx
@@ -25,7 +25,7 @@ import { toast } from 'react-toastify';
import { WorkHeader } from '../components/WorkHeader';
import { DialogButton } from '../components/DialogButton';
import { OpenFileFolder, OpenOpenFileDialog, OpenSaveFileDialog } from '../../wailsjs/go/backend_golang/App';
-import { bytesToReadable, toastWithButton } from '../utils';
+import { absPathAsset, bytesToReadable, toastWithButton } from '../utils';
import { PresetsButton } from './PresetsManager/PresetsButton';
import { useMediaQuery } from 'usehooks-ts';
@@ -122,6 +122,13 @@ const ChatMessageItem: FC<{
}
};
+ let avatarImg: string | undefined;
+ if (commonStore.activePreset && messageItem.sender === botName) {
+ avatarImg = absPathAsset(commonStore.activePreset.avatarImg);
+ } else if (messageItem.avatarImg) {
+ avatarImg = messageItem.avatarImg;
+ }
+
return
{
// Both are slow. Communication between frontend and backend is slow. Use AssetServer Handler to read the file.
// const blob = new Blob([atob(info.content as unknown as string)]); // await fetch(`data:application/octet-stream;base64,${info.content}`).then(r => r.blob());
- const blob = await fetch(`=>${filePath}`).then(r => r.blob());
+ const blob = await fetch(absPathAsset(filePath)).then(r => r.blob());
const attachmentName = filePath.split(/[\\/]/).pop();
const urlPath = `/file-to-text?file_name=${attachmentName}`;
const bodyForm = new FormData();
diff --git a/frontend/src/pages/PresetsManager/PresetsButton.tsx b/frontend/src/pages/PresetsManager/PresetsButton.tsx
index 298c99d..5240579 100644
--- a/frontend/src/pages/PresetsManager/PresetsButton.tsx
+++ b/frontend/src/pages/PresetsManager/PresetsButton.tsx
@@ -36,6 +36,7 @@ import { ClipboardGetText, ClipboardSetText } from '../../../wailsjs/runtime';
import { toast } from 'react-toastify';
import { CustomToastContainer } from '../../components/CustomToastContainer';
import { v4 as uuid } from 'uuid';
+import { absPathAsset } from '../../utils';
export type PresetType = 'chat' | 'completion' | 'chatInCompletion'
@@ -124,7 +125,7 @@ export const PresetCard: FC<{
const { t } = useTranslation();
return
-
+
{name}
} />
-
+
diff --git a/frontend/src/utils/index.tsx b/frontend/src/utils/index.tsx
index fd1908d..6e0f247 100644
--- a/frontend/src/utils/index.tsx
+++ b/frontend/src/utils/index.tsx
@@ -289,6 +289,14 @@ export function bytesToReadable(size: number) {
else return bytesToGb(size) + ' GB';
}
+export function absPathAsset(path: string) {
+ if ((path.length > 0 && path[0] === '/') ||
+ (path.length > 1 && path[1] === ':')) {
+ return '=>' + path;
+ }
+ return path;
+}
+
export async function checkUpdate(notifyEvenLatest: boolean = false) {
fetch(!commonStore.settings.giteeUpdatesSource ?
'https://api.github.com/repos/josstorer/RWKV-Runner/releases/latest' :