mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 06:00:56 +02:00

* Feature: Added ability to send current date and time to v1 and v2 assistants * remove date_feature.patch * fix: rename append_today_date to append_current_datetime * feat: Refactor time handling in chatV1 and chatV2, add date and time utility functions * fix: Add warning log and response for missing run values in abortRun middleware --------- Co-authored-by: Max Sanna <max@maxsanna.com>
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
const { removeNullishValues } = require('librechat-data-provider');
|
|
const generateArtifactsPrompt = require('~/app/clients/prompts/artifacts');
|
|
const { getAssistant } = require('~/models/Assistant');
|
|
|
|
const buildOptions = async (endpoint, parsedBody) => {
|
|
// eslint-disable-next-line no-unused-vars
|
|
const { promptPrefix, assistant_id, iconURL, greeting, spec, artifacts, ...modelOptions } =
|
|
parsedBody;
|
|
const endpointOption = removeNullishValues({
|
|
endpoint,
|
|
promptPrefix,
|
|
assistant_id,
|
|
iconURL,
|
|
greeting,
|
|
spec,
|
|
modelOptions,
|
|
});
|
|
|
|
if (assistant_id) {
|
|
const assistantDoc = await getAssistant({ assistant_id });
|
|
|
|
if (assistantDoc) {
|
|
// Create a clean assistant object with only the needed properties
|
|
endpointOption.assistant = {
|
|
append_current_datetime: assistantDoc.append_current_datetime,
|
|
assistant_id: assistantDoc.assistant_id,
|
|
conversation_starters: assistantDoc.conversation_starters,
|
|
createdAt: assistantDoc.createdAt,
|
|
updatedAt: assistantDoc.updatedAt,
|
|
};
|
|
}
|
|
}
|
|
|
|
if (typeof artifacts === 'string') {
|
|
endpointOption.artifactsPrompt = generateArtifactsPrompt({ endpoint, artifacts });
|
|
}
|
|
|
|
return endpointOption;
|
|
};
|
|
|
|
module.exports = buildOptions;
|