mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-11 12:04:24 +01:00
🔉 feat: TTS/STT rate limiters (#2925)
* fix: remove double initialization of speech routes * refactor(useMessageHelpers): more consistent latestMessage updates based on unique textKey and early returns when setting * feat: TTS/STT rate limiters * chore: remove console log * fix: make modular chat true by default
This commit is contained in:
parent
08d6bea359
commit
8318f26d66
12 changed files with 265 additions and 35 deletions
26
client/src/utils/messages.ts
Normal file
26
client/src/utils/messages.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { ContentTypes } from 'librechat-data-provider';
|
||||
import type { TMessage } from 'librechat-data-provider';
|
||||
|
||||
export const getLengthAndFirstFiveChars = (str?: string) => {
|
||||
const length = str ? str.length : 0;
|
||||
const firstFiveChars = str ? str.substring(0, 5) : '';
|
||||
return `${length}${firstFiveChars}`;
|
||||
};
|
||||
|
||||
export const getLatestText = (message?: TMessage | null) => {
|
||||
if (!message) {
|
||||
return '';
|
||||
}
|
||||
if (message.text) {
|
||||
return message.text;
|
||||
}
|
||||
if (message.content?.length) {
|
||||
for (let i = message.content.length - 1; i >= 0; i--) {
|
||||
const part = message.content[i];
|
||||
if (part.type === ContentTypes.TEXT && part[ContentTypes.TEXT]?.value?.length > 0) {
|
||||
return part[ContentTypes.TEXT].value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return '';
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue