fix: embedding params escape

This commit is contained in:
jialin
2025-06-18 15:03:35 +08:00
parent 9295f9cef3
commit 3e76d7c321
8 changed files with 76 additions and 30 deletions
@@ -276,10 +276,8 @@ const AddModal: FC<AddModalProps> = (props) => {
};
const handleOnSelectModelAfterEvaluate = (item: any) => {
console.log('handleOnSelectModelAfterEvaluate', item);
if (item.isGGUF) {
return;
}
setIsGGUF(item.isGGUF);
setSelectedModel(item);
const modelInfo = onSelectModel(item, props.source);
if (
evaluateStateRef.current.state === EvaluateProccess.model &&
+2 -1
View File
@@ -292,7 +292,8 @@ const ModelCard: React.FC<{
);
useEffect(() => {
if (!props.selectedModel) return;
console.log('ModelCard selectedModel changed', props.selectedModel);
if (!props.selectedModel.name) return;
getModelCardData();
setIsGGUFModel(props.selectedModel.isGGUF);
@@ -343,7 +343,8 @@ const SearchModel: React.FC<SearchInputProps> = (props) => {
(item) => item.id === currentRef.current
);
if (currentItem) {
// if it is gguf, would trigger a evaluation after select a model file
if (currentItem && !currentItem.isGGUF) {
onSelectModelAfterEvaluate(currentItem);
}
} catch (error) {
@@ -305,7 +305,6 @@ const MessageInput: React.FC<MessageInputProps> = forwardRef(
uid: updateUidCount(),
format: audioTypeMap[data.file.type] as AudioFormat,
base64: base64Audio.split(',')[1],
name: audioData.name,
data: _.pick(audioData, ['url', 'name', 'duration'])
}
]
@@ -519,8 +518,8 @@ const MessageInput: React.FC<MessageInputProps> = forwardRef(
<AudioWrapper>
<SimpleAudio
url={message.audio?.[0].data?.url}
name={message.audio?.[0].name}
height={44}
name={message.audio?.[0].data?.name}
height={54}
onDelete={handleDeleteAudio}
></SimpleAudio>
</AudioWrapper>
@@ -219,7 +219,7 @@ const MessageBody: React.FC<MessageBodyProps> = forwardRef(
url={data.audio?.[0]?.data.url}
name={data.audio?.[0]?.data.name}
actions={[]}
height={44}
height={54}
></SimpleAudio>
</AudioWrapper>
)}
@@ -250,7 +250,7 @@ const MessageBody: React.FC<MessageBodyProps> = forwardRef(
url={data.audio?.[0]?.data.url}
name={data.audio?.[0]?.data.name}
onDelete={handleDeleteAudio}
height={44}
height={54}
></SimpleAudio>
</AudioWrapper>
)}
-1
View File
@@ -19,7 +19,6 @@ export interface AudioData {
uid: string | number;
base64: string;
format: AudioFormat;
name?: string;
data: {
url: string;
name: string;
+14 -2
View File
@@ -1,5 +1,15 @@
import _ from 'lodash';
function toShellSafeMultilineJson(value: any): string {
const json = JSON.stringify(value, null, 2);
const escaped = json.replace(/'/g, `'\\''`);
return `${escaped}`;
}
function toShellSafeJson(value: any): string {
return JSON.stringify(value, null, 2).replace(/'/g, `'\\''`);
}
// curl format
export const formatCurlArgs = (
parameters: Record<string, any>,
@@ -9,11 +19,13 @@ export const formatCurlArgs = (
return _.keys(parameters).reduce((acc: string, key: string) => {
const val = parameters[key];
const value =
typeof val === 'object' ? JSON.stringify(val, null, 2) : `${val}`;
typeof val === 'object'
? toShellSafeMultilineJson(val)
: `${toShellSafeJson(val)}`;
return acc + `-F ${key}="${value}" \\\n`;
}, '');
}
return `-d '${JSON.stringify(parameters, null, 2)}'`;
return `-d '${toShellSafeMultilineJson(parameters)}'`;
};
// python format