🌿 fix: Message Route Improvements pt. 2 (#3379)

* fix: edge case with debugTraverse function in parsers.js

* chore: Update error message in audio stream processing

* refactor: Add ONE_MINUTE and THIRTY_SECONDS options to Time enum

* fix: logging
This commit is contained in:
Danny Avila 2024-07-18 13:56:19 -04:00 committed by GitHub
parent 1acd47a0f6
commit f6125ccd59
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 61 additions and 15 deletions

View file

@ -29,10 +29,12 @@ const idSchema = z.string().uuid();
* @param {string} [params.plugin] - Plugin associated with the message.
* @param {string[]} [params.plugins] - An array of plugins associated with the message.
* @param {string} [params.model] - The model used to generate the message.
* @param {Object} [metadata] - Additional metadata for this operation
* @param {string} [metadata.context] - The context of the operation
* @returns {Promise<TMessage>} The updated or newly inserted message document.
* @throws {Error} If there is an error in saving the message.
*/
async function saveMessage(req, params) {
async function saveMessage(req, params, metadata) {
try {
if (!req || !req.user || !req.user.id) {
throw new Error('User not authenticated');
@ -61,8 +63,16 @@ async function saveMessage(req, params) {
const validConvoId = idSchema.safeParse(conversationId);
if (!validConvoId.success) {
if (metadata && metadata?.context) {
logger.info(`\`saveMessage\` context: ${metadata.context}`);
}
logger.warn(`Invalid conversation ID: ${conversationId}`);
logger.info(params);
logger.info(`Invalid conversation ID Params:
${JSON.stringify(params, null, 2)}
`);
return;
}