mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-04-28 08:58:38 +00:00
🎨 chore(web): apply ESLint and Prettier auto-fixes (baseline)
- Ran: bun run eslint:fix && bun run lint:fix - Inserted AGPL license header via eslint-plugin-header - Enforced no-multiple-empty-lines and other lint rules - Formatted code using Prettier v3 (@so1ve/prettier-config) - No functional changes; formatting-only baseline across JS/JSX files
This commit is contained in:
@@ -27,7 +27,7 @@ export const useSyncMessageAndCustomBody = (
|
||||
inputs,
|
||||
setCustomRequestBody,
|
||||
setMessage,
|
||||
debouncedSaveConfig
|
||||
debouncedSaveConfig,
|
||||
) => {
|
||||
const isUpdatingFromMessage = useRef(false);
|
||||
const isUpdatingFromCustomBody = useRef(false);
|
||||
@@ -35,11 +35,13 @@ export const useSyncMessageAndCustomBody = (
|
||||
const lastCustomBodyHash = useRef('');
|
||||
|
||||
const getMessageHash = useCallback((messages) => {
|
||||
return JSON.stringify(messages.map(msg => ({
|
||||
id: msg.id,
|
||||
role: msg.role,
|
||||
content: msg.content
|
||||
})));
|
||||
return JSON.stringify(
|
||||
messages.map((msg) => ({
|
||||
id: msg.id,
|
||||
role: msg.role,
|
||||
content: msg.content,
|
||||
})),
|
||||
);
|
||||
}, []);
|
||||
|
||||
const getCustomBodyHash = useCallback((customBody) => {
|
||||
@@ -68,13 +70,13 @@ export const useSyncMessageAndCustomBody = (
|
||||
model: inputs.model || 'gpt-4o',
|
||||
messages: [],
|
||||
temperature: inputs.temperature || 0.7,
|
||||
stream: inputs.stream !== false
|
||||
stream: inputs.stream !== false,
|
||||
};
|
||||
}
|
||||
|
||||
customPayload.messages = message.map(msg => ({
|
||||
customPayload.messages = message.map((msg) => ({
|
||||
role: msg.role,
|
||||
content: msg.content
|
||||
content: msg.content,
|
||||
}));
|
||||
|
||||
const newCustomBody = JSON.stringify(customPayload, null, 2);
|
||||
@@ -88,7 +90,18 @@ export const useSyncMessageAndCustomBody = (
|
||||
} finally {
|
||||
isUpdatingFromMessage.current = false;
|
||||
}
|
||||
}, [customRequestMode, customRequestBody, message, inputs.model, inputs.temperature, inputs.stream, getMessageHash, getCustomBodyHash, setCustomRequestBody, debouncedSaveConfig]);
|
||||
}, [
|
||||
customRequestMode,
|
||||
customRequestBody,
|
||||
message,
|
||||
inputs.model,
|
||||
inputs.temperature,
|
||||
inputs.stream,
|
||||
getMessageHash,
|
||||
getCustomBodyHash,
|
||||
setCustomRequestBody,
|
||||
debouncedSaveConfig,
|
||||
]);
|
||||
|
||||
const syncCustomBodyToMessage = useCallback(() => {
|
||||
if (!customRequestMode || isUpdatingFromMessage.current) return;
|
||||
@@ -108,8 +121,8 @@ export const useSyncMessageAndCustomBody = (
|
||||
createAt: Date.now(),
|
||||
...(msg.role === MESSAGE_ROLES.ASSISTANT && {
|
||||
reasoningContent: msg.reasoningContent || '',
|
||||
isReasoningExpanded: false
|
||||
})
|
||||
isReasoningExpanded: false,
|
||||
}),
|
||||
}));
|
||||
|
||||
setMessage(newMessages);
|
||||
@@ -121,10 +134,16 @@ export const useSyncMessageAndCustomBody = (
|
||||
} finally {
|
||||
isUpdatingFromCustomBody.current = false;
|
||||
}
|
||||
}, [customRequestMode, customRequestBody, getCustomBodyHash, getMessageHash, setMessage]);
|
||||
}, [
|
||||
customRequestMode,
|
||||
customRequestBody,
|
||||
getCustomBodyHash,
|
||||
getMessageHash,
|
||||
setMessage,
|
||||
]);
|
||||
|
||||
return {
|
||||
syncMessageToCustomBody,
|
||||
syncCustomBodyToMessage
|
||||
syncCustomBodyToMessage,
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user