From a06e999dd668f4f81a5adce49db1ddbf0fcdfc86 Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Sat, 31 May 2025 20:48:23 +0200 Subject: [PATCH] cleanup: code formatting and improve readability across multiple components --- api/app/clients/ChatGPTClient.js | 7 +- api/app/clients/GoogleClient.js | 10 +- api/app/clients/OllamaClient.js | 2 +- api/app/clients/memory/example.js | 34 ++--- api/app/clients/memory/summaryBuffer.demo.js | 2 +- .../clients/output_parsers/addImages.spec.js | 2 +- .../clients/output_parsers/handleOutputs.js | 6 +- .../clients/prompts/addCacheControl.spec.js | 8 +- api/app/clients/prompts/artifacts.js | 1 - .../clients/prompts/createContextHandlers.js | 34 ++--- .../prompts/formatAgentMessages.spec.js | 20 +-- api/app/clients/prompts/instructions.js | 4 +- .../clients/prompts/shadcn-docs/generate.js | 16 +-- api/app/clients/specs/BaseClient.test.js | 4 +- api/app/clients/specs/OpenAIClient.test.js | 6 +- .../clients/tools/structured/AzureAISearch.js | 2 +- api/app/clients/tools/structured/DALLE3.js | 2 +- api/app/clients/tools/structured/FluxAPI.js | 2 +- .../tools/structured/OpenAIImageTools.js | 2 +- .../clients/tools/structured/OpenWeather.js | 4 +- .../tools/structured/StableDiffusion.js | 4 +- .../tools/structured/TraversaalSearch.js | 3 +- api/app/clients/tools/structured/YouTube.js | 2 +- api/app/clients/tools/util/fileSearch.js | 2 +- .../clients/tools/util/handleTools.test.js | 1 - api/models/ConversationTag.js | 12 +- api/models/Message.spec.js | 6 +- api/server/controllers/ErrorController.js | 1 - api/server/controllers/agents/errors.js | 2 +- api/server/controllers/agents/request.js | 2 +- api/server/controllers/assistants/errors.js | 2 +- api/server/controllers/assistants/v1.js | 20 ++- api/server/controllers/assistants/v2.js | 12 +- api/server/middleware/abortMiddleware.js | 2 +- api/server/middleware/abortRun.js | 2 +- api/server/routes/__tests__/config.spec.js | 1 - api/server/routes/share.js | 4 +- api/server/routes/types/assistants.js | 2 +- api/server/services/Artifacts/update.spec.js | 4 +- .../services/Config/loadAsyncEndpoints.js | 14 +- .../Endpoints/azureAssistants/build.js | 1 - .../services/Endpoints/google/initialize.js | 6 +- api/server/services/Endpoints/google/llm.js | 2 +- .../Endpoints/gptPlugins/initialize.spec.js | 10 +- .../Endpoints/openAI/initialize.spec.js | 10 +- api/server/services/Runs/StreamRunManager.js | 2 +- .../services/Threads/processMessages.spec.js | 8 +- api/strategies/appleStrategy.js | 8 +- api/strategies/appleStrategy.test.js | 18 +-- api/strategies/validators.spec.js | 4 +- client/src/@types/i18next.d.ts | 12 +- client/src/common/menus.ts | 1 - .../Artifacts/useDebounceCodeBlock.ts | 21 +-- client/src/components/Auth/AuthLayout.tsx | 4 +- .../components/Auth/RequestPasswordReset.tsx | 22 +-- client/src/components/Auth/ResetPassword.tsx | 31 +---- .../Auth/__tests__/Registration.spec.tsx | 1 - .../Chat/Input/Files/DragDropOverlay.tsx | 12 +- .../Chat/Input/Files/ImagePreview.tsx | 6 +- .../src/components/Chat/Input/StreamAudio.tsx | 2 +- .../Endpoints/components/EndpointItem.tsx | 12 +- .../components/EndpointModelItem.tsx | 8 +- .../Endpoints/components/SearchResults.tsx | 24 ++-- .../components/Chat/Menus/Models/fakeData.ts | 2 +- .../src/components/Chat/Menus/UI/MenuItem.tsx | 4 +- .../Messages/Content/Parts/EditTextPart.tsx | 6 +- .../src/components/Chat/Messages/Message.tsx | 4 +- client/src/components/Chat/TemporaryChat.tsx | 2 +- client/src/components/Endpoints/Icon.tsx | 18 +-- .../Endpoints/SaveAsPresetDialog.tsx | 4 +- .../Endpoints/Settings/Advanced.tsx | 7 +- .../Endpoints/Settings/Assistants.tsx | 4 +- .../Endpoints/Settings/Examples.tsx | 4 +- .../components/Endpoints/Settings/Google.tsx | 10 +- .../components/Endpoints/Settings/Plugins.tsx | 2 +- .../components/Input/Generations/Continue.tsx | 2 +- .../src/components/Input/Generations/Stop.tsx | 2 +- .../Input/SetKeyDialog/SetKeyDialog.tsx | 4 +- .../components/Messages/Content/Plugin.tsx | 6 +- .../components/Messages/MessageContent.tsx | 4 +- client/src/components/Nav/NavToggle.tsx | 2 +- client/src/components/Nav/Settings.tsx | 8 +- .../Speech/STT/DecibelSelector.tsx | 4 +- .../Speech/STT/EngineSTTDropdown.tsx | 6 +- .../Speech/TTS/EngineTTSDropdown.tsx | 6 +- .../SettingsTabs/Speech/TTS/PlaybackRate.tsx | 4 +- .../Plugins/Store/PluginStoreDialog.tsx | 3 +- .../Plugins/Store/PluginTooltip.tsx | 2 +- .../Prompts/Groups/FilterPrompts.tsx | 10 +- .../components/Prompts/Groups/ListCard.tsx | 3 +- client/src/components/Prompts/PromptForm.tsx | 22 +-- client/src/components/Share/MultiMessage.tsx | 2 +- .../SidePanel/Agents/ImageVision.tsx | 2 +- .../SidePanel/Agents/ShareAgent.tsx | 14 +- .../SidePanel/Bookmarks/BookmarkTableRow.tsx | 4 +- .../SidePanel/Builder/ActionsAuth.tsx | 4 +- .../src/components/SidePanel/Builder/Code.tsx | 2 +- .../SidePanel/Builder/ImageVision.tsx | 2 +- .../SidePanel/Parameters/DynamicCheckbox.tsx | 8 +- .../SidePanel/Parameters/DynamicCombobox.tsx | 16 ++- .../SidePanel/Parameters/DynamicDropdown.tsx | 14 +- .../SidePanel/Parameters/DynamicSlider.tsx | 36 +++-- .../SidePanel/Parameters/DynamicTextarea.tsx | 14 +- client/src/components/svg/AppleIcon.tsx | 2 +- .../src/components/svg/AzureMinimalIcon.tsx | 1 - client/src/components/ui/Accordion.tsx | 2 +- .../src/components/ui/AnimatedSearchInput.tsx | 48 ++----- client/src/components/ui/Breadcrumb.tsx | 36 ++--- client/src/components/ui/Combobox.tsx | 10 +- .../components/ui/DataTableColumnHeader.tsx | 8 +- client/src/components/ui/DropdownNoState.tsx | 2 +- .../src/components/ui/InputWithDropDown.tsx | 4 +- client/src/components/ui/MultiSearch.tsx | 4 +- .../src/components/ui/MultiSelectDropDown.tsx | 2 +- client/src/components/ui/MultiSelectPop.tsx | 8 +- client/src/components/ui/Prompt.tsx | 2 +- client/src/components/ui/Resizable.tsx | 8 +- client/src/components/ui/Slider.tsx | 32 ++--- client/src/components/ui/Table.tsx | 8 +- client/src/components/ui/Tag.tsx | 22 +-- .../components/ui/TermsAndConditionsModal.tsx | 2 +- client/src/hooks/Chat/useAddedHelpers.ts | 2 +- .../hooks/Conversations/useDebouncedInput.ts | 2 +- .../Conversations/useExportConversation.ts | 5 +- client/src/hooks/Endpoint/useEndpoints.ts | 10 +- client/src/hooks/SSE/useContentHandler.ts | 5 +- client/src/locales/Translation.spec.ts | 2 +- client/src/locales/en/translation.json | 5 +- client/src/utils/convos.fakeData.ts | 3 +- client/src/utils/latex.spec.ts | 1 - client/test/setupTests.js | 2 +- config/deployed-update.js | 4 +- config/update.js | 4 +- packages/data-provider/specs/actions.spec.ts | 16 +-- packages/data-provider/specs/generate.spec.ts | 5 +- packages/data-provider/specs/mcp.spec.ts | 15 ++- packages/data-provider/src/actions.ts | 25 ++-- packages/data-provider/src/azure.ts | 24 ++-- packages/data-provider/src/file-config.ts | 1 - packages/data-provider/src/generate.ts | 15 ++- packages/data-provider/src/zod.spec.ts | 126 ++++++++---------- packages/data-schemas/src/schema/user.ts | 2 +- .../mcp/src/examples/everything/everything.ts | 4 +- packages/mcp/src/examples/filesystem.ts | 13 +- 144 files changed, 608 insertions(+), 648 deletions(-) diff --git a/api/app/clients/ChatGPTClient.js b/api/app/clients/ChatGPTClient.js index 07b2fa97bb..36a3f4936a 100644 --- a/api/app/clients/ChatGPTClient.js +++ b/api/app/clients/ChatGPTClient.js @@ -244,9 +244,9 @@ class ChatGPTClient extends BaseClient { baseURL = this.langchainProxy ? constructAzureURL({ - baseURL: this.langchainProxy, - azureOptions: this.azure, - }) + baseURL: this.langchainProxy, + azureOptions: this.azure, + }) : this.azureEndpoint.split(/(? { try { let done = false; diff --git a/api/app/clients/GoogleClient.js b/api/app/clients/GoogleClient.js index c9102e9ae2..4151e6663a 100644 --- a/api/app/clients/GoogleClient.js +++ b/api/app/clients/GoogleClient.js @@ -236,11 +236,11 @@ class GoogleClient extends BaseClient { msg.content = ( !Array.isArray(msg.content) ? [ - { - type: ContentTypes.TEXT, - [ContentTypes.TEXT]: msg.content, - }, - ] + { + type: ContentTypes.TEXT, + [ContentTypes.TEXT]: msg.content, + }, + ] : msg.content ).concat(message.image_urls); diff --git a/api/app/clients/OllamaClient.js b/api/app/clients/OllamaClient.js index 77d007580c..7ca1330db7 100644 --- a/api/app/clients/OllamaClient.js +++ b/api/app/clients/OllamaClient.js @@ -67,7 +67,7 @@ class OllamaClient { return models; } catch (error) { const logMessage = - 'Failed to fetch models from Ollama API. If you are not using Ollama directly, and instead, through some aggregator or reverse proxy that handles fetching via OpenAI spec, ensure the name of the endpoint doesn\'t start with `ollama` (case-insensitive).'; + "Failed to fetch models from Ollama API. If you are not using Ollama directly, and instead, through some aggregator or reverse proxy that handles fetching via OpenAI spec, ensure the name of the endpoint doesn't start with `ollama` (case-insensitive)."; logAxiosError({ message: logMessage, error }); return []; } diff --git a/api/app/clients/memory/example.js b/api/app/clients/memory/example.js index 49bf9dde08..7e59bc2a18 100644 --- a/api/app/clients/memory/example.js +++ b/api/app/clients/memory/example.js @@ -22,17 +22,17 @@ '\n' + 'Celestia had the power to grant one wish to anyone who dared to find her abode. Ethan, captivated by the tales he had read and yearning for something greater, approached the cottage with trepidation. When he shared his desire to embark on a grand adventure, Celestia smiled warmly and agreed to grant his wish.\n' + '\n' + - 'With a wave of her wand and a sprinkle of stardust, Celestia bestowed upon Ethan a magical necklace. This necklace, adorned with a rare gemstone called the Eye of Imagination, had the power to turn dreams and imagination into reality. From that moment forward, Ethan\'s every thought and idea became manifest.\n' + + "With a wave of her wand and a sprinkle of stardust, Celestia bestowed upon Ethan a magical necklace. This necklace, adorned with a rare gemstone called the Eye of Imagination, had the power to turn dreams and imagination into reality. From that moment forward, Ethan's every thought and idea became manifest.\n" + '\n' + 'Energized by this newfound power, Ethan continued his journey, encountering mythical creatures, solving riddles, and overcoming treacherous obstacles along the way. With the Eye of Imagination, he brought life to ancient statues, unlocked hidden doors, and even tamed fiery dragons.\n' + '\n' + 'As days turned into weeks and weeks into months, Ethan became wiser and more in tune with the world around him. He learned that true adventure was not merely about seeking thrills and conquering the unknown, but also about fostering compassion, friendship, and a deep appreciation for the beauty of the ordinary.\n' + '\n' + - 'Eventually, Ethan\'s journey led him back to his village. With the Eye of Imagination, he transformed the village into a place of wonders and endless possibilities. Fields blossomed into vibrant gardens, simple tools turned into intricate works of art, and the villagers felt a renewed sense of hope and inspiration.\n' + + "Eventually, Ethan's journey led him back to his village. With the Eye of Imagination, he transformed the village into a place of wonders and endless possibilities. Fields blossomed into vibrant gardens, simple tools turned into intricate works of art, and the villagers felt a renewed sense of hope and inspiration.\n" + '\n' + - 'Ethan, now known as the Village Magician, realized that the true magic lied within everyone\'s hearts. He taught the villagers to embrace their creativity, to dream big, and to never underestimate the power of imagination. And so, the village flourished, becoming a beacon of wonder and creativity for all to see.\n' + + "Ethan, now known as the Village Magician, realized that the true magic lied within everyone's hearts. He taught the villagers to embrace their creativity, to dream big, and to never underestimate the power of imagination. And so, the village flourished, becoming a beacon of wonder and creativity for all to see.\n" + '\n' + - 'In the years that followed, Ethan\'s adventures continued, though mostly within the confines of his beloved village. But he never forgot the thrill of that first grand adventure. And every now and then, when looking up at the starry night sky, he would allow his mind to wander, knowing that the greatest adventures were still waiting to be discovered.', + "In the years that followed, Ethan's adventures continued, though mostly within the confines of his beloved village. But he never forgot the thrill of that first grand adventure. And every now and then, when looking up at the starry night sky, he would allow his mind to wander, knowing that the greatest adventures were still waiting to be discovered.", }, { role: 'user', @@ -41,30 +41,30 @@ '\n' + 'Once there was a young lad by the name of Ethan, raised in a little hamlet nestled betwixt the verdant knolls, who possessed an irrepressible yearning for knowledge, a thirst unquenchable and a spirit teeming with curiosity. As the golden sun bathed the bucolic land in its effulgent light, he would tread through the village, his ears attuned to the tales spun by the townsfolk, his eyes absorbing the tapestry woven by the world surrounding him.\n' + '\n' + - 'One radiant day, whilst exploring the periphery of the settlement, Ethan chanced upon a timeworn tome, ensconced amidst the roots of an ancient oak, cloaked in the shroud of neglect. The dust gathered upon it spoke of time\'s relentless march. A book of fairy tales – garnished with vivid descriptions of mystical woods, fantastical beasts, and ventures daring beyond the ordinary humdrum existence. Intrigued and beguiled, Ethan pried open the weathered pages and succumbed to their beckoning whispers.\n' + + "One radiant day, whilst exploring the periphery of the settlement, Ethan chanced upon a timeworn tome, ensconced amidst the roots of an ancient oak, cloaked in the shroud of neglect. The dust gathered upon it spoke of time's relentless march. A book of fairy tales – garnished with vivid descriptions of mystical woods, fantastical beasts, and ventures daring beyond the ordinary humdrum existence. Intrigued and beguiled, Ethan pried open the weathered pages and succumbed to their beckoning whispers.\n" + '\n' + - 'In each tale, he was transported to a realm of enchantment and wonderment, inexorably tugging at the strings of his yearning for peripatetic exploration. Inspired by the narratives he had devoured, Ethan resolved to bid adieu to kinfolk and embark upon a sojourn, with dreams of procuring a firsthand glimpse into the domain of mystique that lay beyond the village\'s circumscribed boundary.\n' + + "In each tale, he was transported to a realm of enchantment and wonderment, inexorably tugging at the strings of his yearning for peripatetic exploration. Inspired by the narratives he had devoured, Ethan resolved to bid adieu to kinfolk and embark upon a sojourn, with dreams of procuring a firsthand glimpse into the domain of mystique that lay beyond the village's circumscribed boundary.\n" + '\n' + 'Thus, he bade tearful farewells, girding himself for a path that guided him to a dense and captivating woodland, whispered of as a sanctuary to mythical beings and clandestine troves of treasures. As Ethan plunged deeper into the heart of the arboreal labyrinth, he felt a palpable surge of electricity, as though the sylvan sentinels whispered enigmatic secrets that only the perceptive ear could discern.\n' + '\n' + - 'It wasn\'t long before his path intertwined with that of a capricious sprite christened Sparkle, bearing an impish grin and eyes sparkling with mischief. Sparkle played the role of Virgil to Ethan\'s Dante, guiding him through the intricate tapestry of arboreal scions, issuing warnings of perils concealed and spinning tales of ancient entities that called this very bosky enclave home.\n' + + "It wasn't long before his path intertwined with that of a capricious sprite christened Sparkle, bearing an impish grin and eyes sparkling with mischief. Sparkle played the role of Virgil to Ethan's Dante, guiding him through the intricate tapestry of arboreal scions, issuing warnings of perils concealed and spinning tales of ancient entities that called this very bosky enclave home.\n" + '\n' + 'Together, they stumbled upon a luminous lake, its shimmering waters imbued with a celestial light. At the center lay a diminutive island, upon which reposed a cottage fashioned from tender petals and verdant leaves. It belonged to an ancient sorceress of considerable wisdom, Celestia by name.\n' + '\n' + - 'Celestia, with her power to bestow a single wish on any intrepid soul who happened upon her abode, met Ethan\'s desire with a congenial nod, his fervor for a grand expedition not lost on her penetrating gaze. In response, she bequeathed unto him a necklace of magical manufacture – adorned with the rare gemstone known as the Eye of Imagination – whose very essence transformed dreams into vivid reality. From that moment forward, not a single cogitation nor nebulous fanciful notion of Ethan\'s ever lacked physicality.\n' + + "Celestia, with her power to bestow a single wish on any intrepid soul who happened upon her abode, met Ethan's desire with a congenial nod, his fervor for a grand expedition not lost on her penetrating gaze. In response, she bequeathed unto him a necklace of magical manufacture – adorned with the rare gemstone known as the Eye of Imagination – whose very essence transformed dreams into vivid reality. From that moment forward, not a single cogitation nor nebulous fanciful notion of Ethan's ever lacked physicality.\n" + '\n' + 'Energized by this newfound potency, Ethan continued his sojourn, encountering mythical creatures, unraveling cerebral enigmas, and braving perils aplenty along the winding roads of destiny. Armed with the Eye of Imagination, he brought forth life from immobile statuary, unlocked forbidding portals, and even tamed the ferocious beasts of yore – their fiery breath reduced to a whisper.\n' + '\n' + - 'As the weeks metamorphosed into months, Ethan grew wiser and more attuned to the ebb and flow of the world enveloping him. He gleaned that true adventure isn\'t solely confined to sating a thirst for adrenaline and conquering the unknown; indeed, it resides in fostering compassion, fostering amicable bonds, and cherishing the beauty entwined within the quotidian veld.\n' + + "As the weeks metamorphosed into months, Ethan grew wiser and more attuned to the ebb and flow of the world enveloping him. He gleaned that true adventure isn't solely confined to sating a thirst for adrenaline and conquering the unknown; indeed, it resides in fostering compassion, fostering amicable bonds, and cherishing the beauty entwined within the quotidian veld.\n" + '\n' + - 'Eventually, Ethan\'s quest drew him homeward, back to his village. Buoying the Eye of Imagination\'s ethereal power, he imbued the hitherto unremarkable settlement with the patina of infinite possibilities. The bounteous fields bloomed into kaleidoscopic gardens, simple instruments transmuting into intricate masterpieces, and the villagers themselves clasped within their hearts a renewed ardor, a conflagration of hope and inspiration.\n' + + "Eventually, Ethan's quest drew him homeward, back to his village. Buoying the Eye of Imagination's ethereal power, he imbued the hitherto unremarkable settlement with the patina of infinite possibilities. The bounteous fields bloomed into kaleidoscopic gardens, simple instruments transmuting into intricate masterpieces, and the villagers themselves clasped within their hearts a renewed ardor, a conflagration of hope and inspiration.\n" + '\n' + - 'Behold Ethan, at present hailed as the Village Magician – a cognomen befitting his sorcery wielded within the confines of the community he adored. His exploits may have become tethered to a geographical locale, but the flame kindled by that premier sojourn never flickered. Occasionally, beneath the veiled twilight canopy, when peering skyward toward the astral canvas bedecked with countless luminescent diamonds, he\'d allow his mind to wander, cognizant of boundless adventures yet to take flight, forever awaiting his indomitable spirit.', + "Behold Ethan, at present hailed as the Village Magician – a cognomen befitting his sorcery wielded within the confines of the community he adored. His exploits may have become tethered to a geographical locale, but the flame kindled by that premier sojourn never flickered. Occasionally, beneath the veiled twilight canopy, when peering skyward toward the astral canvas bedecked with countless luminescent diamonds, he'd allow his mind to wander, cognizant of boundless adventures yet to take flight, forever awaiting his indomitable spirit.", }, { role: 'assistant', content: - 'Beautifully rewritten! It captures the essence of Cormac McCarthy\'s style, with its descriptive language and evocative imagery. The story retains the spirit of adventure and the power of imagination seen in the original. Well done! If you have any more requests or if there\'s anything else I can assist you with, feel free to let me know.', + "Beautifully rewritten! It captures the essence of Cormac McCarthy's style, with its descriptive language and evocative imagery. The story retains the spirit of adventure and the power of imagination seen in the original. Well done! If you have any more requests or if there's anything else I can assist you with, feel free to let me know.", }, { role: 'user', @@ -73,19 +73,19 @@ { role: 'assistant', content: - 'Certainly! Here\'s a short story reflecting Cormac McCarthy\'s style:\n' + + "Certainly! Here's a short story reflecting Cormac McCarthy's style:\n" + '\n' + 'In a desolate wasteland scarred by the sins of mankind, a lone traveler ventured forth, his name forgotten by time, etched upon the shadows of memory. He navigated the barren plains, where the sun beat down, merciless and unrelenting, scorching the parched earth beneath his weary boots.\n' + '\n' + 'Desolation was his only companion, the forsaken landscape a testament to the darkness that had befallen this forsaken realm. The wind whispered secrets long lost, carrying with it the echoes of a civilization long since undone, swallowed by the abyss.\n' + '\n' + - 'Amongst the shattered remnants of fallen cities, he sought solace, a glimmer of hope amidst the desolation. Rusted remnants of steel and concrete stood as sentinels of mankind\'s hubris, their jagged edges a chilling reminder of the fragility of all that was once deemed invincible.\n' + + "Amongst the shattered remnants of fallen cities, he sought solace, a glimmer of hope amidst the desolation. Rusted remnants of steel and concrete stood as sentinels of mankind's hubris, their jagged edges a chilling reminder of the fragility of all that was once deemed invincible.\n" + '\n' + 'As twilight descended, casting a pallid hue upon the lifeless land, he happened upon a dilapidated house, its walls crumbling under the weight of time. Drawn to the desolation, he pushed open the creaking door, its rusty hinges screaming in protest.\n' + '\n' + 'Inside, a world frozen in time awaited him. Dust particles danced through the air, illuminated by slivers of light that pierced the broken windows. Here, the past lay trapped, a melancholic tableau of lives lost and dreams shattered.\n' + '\n' + - 'He wandered through the empty rooms, bare walls whispering stories untold. In the corner, a dilapidated piano stood, its ivory keys long since abandoned by a musician\'s touch. He approached it cautiously, a faint glimmer of anticipation igniting in his weather-worn eyes.\n' + + "He wandered through the empty rooms, bare walls whispering stories untold. In the corner, a dilapidated piano stood, its ivory keys long since abandoned by a musician's touch. He approached it cautiously, a faint glimmer of anticipation igniting in his weather-worn eyes.\n" + '\n' + 'Determined, he carefully brushed away the dust and debris that cloaked the instrument. With trembling hands, he pressed a key, and a discordant note filled the air, mingling with the sighs of forgotten melodies. The sound echoed through the silence, bringing with it the remnants of forgotten symphonies.\n' + '\n' + @@ -103,13 +103,13 @@ { role: 'assistant', content: - 'Thank you! I\'m glad you enjoyed it. If you have any more writing requests or if there\'s anything else I can assist you with, feel free to let me know.', + "Thank you! I'm glad you enjoyed it. If you have any more writing requests or if there's anything else I can assist you with, feel free to let me know.", }, { role: 'user', content: 'you are very helpful' }, { role: 'assistant', content: - 'Thank you for your kind words! I\'m here to assist you in any way I can. If you have any more questions, need further assistance, or just want to chat, feel free to reach out.', + "Thank you for your kind words! I'm here to assist you in any way I can. If you have any more questions, need further assistance, or just want to chat, feel free to reach out.", }, { role: 'user', content: 'no you man' }, ]; diff --git a/api/app/clients/memory/summaryBuffer.demo.js b/api/app/clients/memory/summaryBuffer.demo.js index fc575c3032..b88e6b411c 100644 --- a/api/app/clients/memory/summaryBuffer.demo.js +++ b/api/app/clients/memory/summaryBuffer.demo.js @@ -9,7 +9,7 @@ const chatPromptMemory = new ConversationSummaryBufferMemory({ }); (async () => { - await chatPromptMemory.saveContext({ input: 'hi my name\'s Danny' }, { output: 'whats up' }); + await chatPromptMemory.saveContext({ input: "hi my name's Danny" }, { output: 'whats up' }); await chatPromptMemory.saveContext({ input: 'not much you' }, { output: 'not much' }); await chatPromptMemory.saveContext( { input: 'are you excited for the olympics?' }, diff --git a/api/app/clients/output_parsers/addImages.spec.js b/api/app/clients/output_parsers/addImages.spec.js index 7c5a04137e..8e4e74428a 100644 --- a/api/app/clients/output_parsers/addImages.spec.js +++ b/api/app/clients/output_parsers/addImages.spec.js @@ -74,7 +74,7 @@ describe('addImages', () => { it('should append correctly from a real scenario', () => { responseMessage.text = - 'Here is the generated image based on your request. It depicts a surreal landscape filled with floating musical notes. The style is impressionistic, with vibrant sunset hues dominating the scene. At the center, there\'s a silhouette of a grand piano, adding a dreamy emotion to the overall image. This could serve as a unique and creative music album cover. Would you like to make any changes or generate another image?'; + "Here is the generated image based on your request. It depicts a surreal landscape filled with floating musical notes. The style is impressionistic, with vibrant sunset hues dominating the scene. At the center, there's a silhouette of a grand piano, adding a dreamy emotion to the overall image. This could serve as a unique and creative music album cover. Would you like to make any changes or generate another image?"; const originalText = responseMessage.text; const imageMarkdown = '![generated image](/images/img-RnVWaYo2Yg4x3e0isICiMuf5.png)'; intermediateSteps.push({ observation: imageMarkdown }); diff --git a/api/app/clients/output_parsers/handleOutputs.js b/api/app/clients/output_parsers/handleOutputs.js index b25eaaad80..fc04d73a16 100644 --- a/api/app/clients/output_parsers/handleOutputs.js +++ b/api/app/clients/output_parsers/handleOutputs.js @@ -65,14 +65,14 @@ function buildPromptPrefix({ result, message, functionsAgent }) { const preliminaryAnswer = result.output?.length > 0 ? `Preliminary Answer: "${result.output.trim()}"` : ''; const prefix = preliminaryAnswer - ? 'review and improve the answer you generated using plugins in response to the User Message below. The user hasn\'t seen your answer or thoughts yet.' + ? "review and improve the answer you generated using plugins in response to the User Message below. The user hasn't seen your answer or thoughts yet." : 'respond to the User Message below based on your preliminary thoughts & actions.'; return `As a helpful AI Assistant, ${prefix}${errorMessage}\n${internalActions} ${preliminaryAnswer} Reply conversationally to the User based on your ${ - preliminaryAnswer ? 'preliminary answer, ' : '' -}internal actions, thoughts, and observations, making improvements wherever possible, but do not modify URLs. + preliminaryAnswer ? 'preliminary answer, ' : '' + }internal actions, thoughts, and observations, making improvements wherever possible, but do not modify URLs. ${ preliminaryAnswer ? '' diff --git a/api/app/clients/prompts/addCacheControl.spec.js b/api/app/clients/prompts/addCacheControl.spec.js index c46ffd95e3..7bf43aabcc 100644 --- a/api/app/clients/prompts/addCacheControl.spec.js +++ b/api/app/clients/prompts/addCacheControl.spec.js @@ -6,7 +6,7 @@ describe('addCacheControl', () => { { role: 'user', content: [{ type: 'text', text: 'Hello' }] }, { role: 'assistant', content: [{ type: 'text', text: 'Hi there' }] }, { role: 'user', content: [{ type: 'text', text: 'How are you?' }] }, - { role: 'assistant', content: [{ type: 'text', text: 'I\'m doing well, thanks!' }] }, + { role: 'assistant', content: [{ type: 'text', text: "I'm doing well, thanks!" }] }, { role: 'user', content: [{ type: 'text', text: 'Great!' }] }, ]; @@ -22,7 +22,7 @@ describe('addCacheControl', () => { { role: 'user', content: 'Hello' }, { role: 'assistant', content: 'Hi there' }, { role: 'user', content: 'How are you?' }, - { role: 'assistant', content: 'I\'m doing well, thanks!' }, + { role: 'assistant', content: "I'm doing well, thanks!" }, { role: 'user', content: 'Great!' }, ]; @@ -140,7 +140,7 @@ describe('addCacheControl', () => { { role: 'user', content: 'Hello' }, { role: 'assistant', content: 'Hi there' }, { role: 'user', content: [{ type: 'text', text: 'How are you?' }] }, - { role: 'assistant', content: 'I\'m doing well, thanks!' }, + { role: 'assistant', content: "I'm doing well, thanks!" }, { role: 'user', content: 'Great!' }, ]; @@ -160,7 +160,7 @@ describe('addCacheControl', () => { }, ]); expect(result[1].content).toBe('Hi there'); - expect(result[3].content).toBe('I\'m doing well, thanks!'); + expect(result[3].content).toBe("I'm doing well, thanks!"); }); test('should handle edge case with multiple content types', () => { diff --git a/api/app/clients/prompts/artifacts.js b/api/app/clients/prompts/artifacts.js index b907a16b56..f99a9a74e7 100644 --- a/api/app/clients/prompts/artifacts.js +++ b/api/app/clients/prompts/artifacts.js @@ -3,7 +3,6 @@ const { EModelEndpoint, ArtifactModes } = require('librechat-data-provider'); const { generateShadcnPrompt } = require('~/app/clients/prompts/shadcn-docs/generate'); const { components } = require('~/app/clients/prompts/shadcn-docs/components'); -// eslint-disable-next-line no-unused-vars const artifactsPromptV1 = dedent`The assistant can create and reference artifacts during conversations. Artifacts are for substantial, self-contained content that users might modify or reuse, displayed in a separate UI window for clarity. diff --git a/api/app/clients/prompts/createContextHandlers.js b/api/app/clients/prompts/createContextHandlers.js index 4dcfaf68e4..57847bea3e 100644 --- a/api/app/clients/prompts/createContextHandlers.js +++ b/api/app/clients/prompts/createContextHandlers.js @@ -96,35 +96,35 @@ function createContextHandlers(req, userMessageContent) { resolvedQueries.length === 0 ? '\n\tThe semantic search did not return any results.' : resolvedQueries - .map((queryResult, index) => { - const file = processedFiles[index]; - let contextItems = queryResult.data; + .map((queryResult, index) => { + const file = processedFiles[index]; + let contextItems = queryResult.data; - const generateContext = (currentContext) => - ` + const generateContext = (currentContext) => + ` ${file.filename} ${currentContext} `; - if (useFullContext) { - return generateContext(`\n${contextItems}`); - } + if (useFullContext) { + return generateContext(`\n${contextItems}`); + } - contextItems = queryResult.data - .map((item) => { - const pageContent = item[0].page_content; - return ` + contextItems = queryResult.data + .map((item) => { + const pageContent = item[0].page_content; + return ` `; - }) - .join(''); + }) + .join(''); - return generateContext(contextItems); - }) - .join(''); + return generateContext(contextItems); + }) + .join(''); if (useFullContext) { const prompt = `${header} diff --git a/api/app/clients/prompts/formatAgentMessages.spec.js b/api/app/clients/prompts/formatAgentMessages.spec.js index 360fa00a34..1aee3edf71 100644 --- a/api/app/clients/prompts/formatAgentMessages.spec.js +++ b/api/app/clients/prompts/formatAgentMessages.spec.js @@ -130,7 +130,7 @@ describe('formatAgentMessages', () => { content: [ { type: ContentTypes.TEXT, - [ContentTypes.TEXT]: 'I\'ll search for that information.', + [ContentTypes.TEXT]: "I'll search for that information.", tool_call_ids: ['search_1'], }, { @@ -144,7 +144,7 @@ describe('formatAgentMessages', () => { }, { type: ContentTypes.TEXT, - [ContentTypes.TEXT]: 'Now, I\'ll convert the temperature.', + [ContentTypes.TEXT]: "Now, I'll convert the temperature.", tool_call_ids: ['convert_1'], }, { @@ -156,7 +156,7 @@ describe('formatAgentMessages', () => { output: '23.89°C', }, }, - { type: ContentTypes.TEXT, [ContentTypes.TEXT]: 'Here\'s your answer.' }, + { type: ContentTypes.TEXT, [ContentTypes.TEXT]: "Here's your answer." }, ], }, ]; @@ -171,7 +171,7 @@ describe('formatAgentMessages', () => { expect(result[4]).toBeInstanceOf(AIMessage); // Check first AIMessage - expect(result[0].content).toBe('I\'ll search for that information.'); + expect(result[0].content).toBe("I'll search for that information."); expect(result[0].tool_calls).toHaveLength(1); expect(result[0].tool_calls[0]).toEqual({ id: 'search_1', @@ -187,7 +187,7 @@ describe('formatAgentMessages', () => { ); // Check second AIMessage - expect(result[2].content).toBe('Now, I\'ll convert the temperature.'); + expect(result[2].content).toBe("Now, I'll convert the temperature."); expect(result[2].tool_calls).toHaveLength(1); expect(result[2].tool_calls[0]).toEqual({ id: 'convert_1', @@ -202,7 +202,7 @@ describe('formatAgentMessages', () => { // Check final AIMessage expect(result[4].content).toStrictEqual([ - { [ContentTypes.TEXT]: 'Here\'s your answer.', type: ContentTypes.TEXT }, + { [ContentTypes.TEXT]: "Here's your answer.", type: ContentTypes.TEXT }, ]); }); @@ -217,7 +217,7 @@ describe('formatAgentMessages', () => { role: 'assistant', content: [{ type: ContentTypes.TEXT, [ContentTypes.TEXT]: 'How can I help you?' }], }, - { role: 'user', content: 'What\'s the weather?' }, + { role: 'user', content: "What's the weather?" }, { role: 'assistant', content: [ @@ -240,7 +240,7 @@ describe('formatAgentMessages', () => { { role: 'assistant', content: [ - { type: ContentTypes.TEXT, [ContentTypes.TEXT]: 'Here\'s the weather information.' }, + { type: ContentTypes.TEXT, [ContentTypes.TEXT]: "Here's the weather information." }, ], }, ]; @@ -265,12 +265,12 @@ describe('formatAgentMessages', () => { { [ContentTypes.TEXT]: 'How can I help you?', type: ContentTypes.TEXT }, ]); expect(result[2].content).toStrictEqual([ - { [ContentTypes.TEXT]: 'What\'s the weather?', type: ContentTypes.TEXT }, + { [ContentTypes.TEXT]: "What's the weather?", type: ContentTypes.TEXT }, ]); expect(result[3].content).toBe('Let me check that for you.'); expect(result[4].content).toBe('Sunny, 75°F'); expect(result[5].content).toStrictEqual([ - { [ContentTypes.TEXT]: 'Here\'s the weather information.', type: ContentTypes.TEXT }, + { [ContentTypes.TEXT]: "Here's the weather information.", type: ContentTypes.TEXT }, ]); // Check that there are no consecutive AIMessages diff --git a/api/app/clients/prompts/instructions.js b/api/app/clients/prompts/instructions.js index c630711771..b97b1bfecc 100644 --- a/api/app/clients/prompts/instructions.js +++ b/api/app/clients/prompts/instructions.js @@ -1,8 +1,8 @@ module.exports = { instructions: - 'Remember, all your responses MUST be in the format described. Do not respond unless it\'s in the format described, using the structure of Action, Action Input, etc.', + "Remember, all your responses MUST be in the format described. Do not respond unless it's in the format described, using the structure of Action, Action Input, etc.", errorInstructions: - '\nYou encountered an error in attempting a response. The user is not aware of the error so you shouldn\'t mention it.\nReview the actions taken carefully in case there is a partial or complete answer within them.\nError Message:', + "\nYou encountered an error in attempting a response. The user is not aware of the error so you shouldn't mention it.\nReview the actions taken carefully in case there is a partial or complete answer within them.\nError Message:", imageInstructions: 'You must include the exact image paths from above, formatted in Markdown syntax: ![alt-text](URL)', completionInstructions: diff --git a/api/app/clients/prompts/shadcn-docs/generate.js b/api/app/clients/prompts/shadcn-docs/generate.js index 6cb56f1077..6a4cf8c7e3 100644 --- a/api/app/clients/prompts/shadcn-docs/generate.js +++ b/api/app/clients/prompts/shadcn-docs/generate.js @@ -18,17 +18,17 @@ function generateShadcnPrompt(options) { Here are the components that are available, along with how to import them, and how to use them: ${Object.values(components) - .map((component) => { - if (useXML) { - return dedent` + .map((component) => { + if (useXML) { + return dedent` ${component.componentName} ${component.importDocs} ${component.usageDocs} `; - } else { - return dedent` + } else { + return dedent` # ${component.componentName} ## Import Instructions @@ -37,9 +37,9 @@ function generateShadcnPrompt(options) { ## Usage Instructions ${component.usageDocs} `; - } - }) - .join('\n\n')} + } + }) + .join('\n\n')} `; return systemPrompt; diff --git a/api/app/clients/specs/BaseClient.test.js b/api/app/clients/specs/BaseClient.test.js index d620d5f647..1cd4a80db7 100644 --- a/api/app/clients/specs/BaseClient.test.js +++ b/api/app/clients/specs/BaseClient.test.js @@ -52,7 +52,7 @@ const messageHistory = [ { role: 'user', isCreatedByUser: true, - text: 'What\'s up', + text: "What's up", messageId: '3', parentMessageId: '2', }, @@ -456,7 +456,7 @@ describe('BaseClient', () => { const chatMessages2 = await TestClient.loadHistory(conversationId, '3'); expect(TestClient.currentMessages).toHaveLength(3); - expect(chatMessages2[chatMessages2.length - 1].text).toEqual('What\'s up'); + expect(chatMessages2[chatMessages2.length - 1].text).toEqual("What's up"); }); /* Most of the new sendMessage logic revolving around edited/continued AI messages diff --git a/api/app/clients/specs/OpenAIClient.test.js b/api/app/clients/specs/OpenAIClient.test.js index 579f636eef..8e470727da 100644 --- a/api/app/clients/specs/OpenAIClient.test.js +++ b/api/app/clients/specs/OpenAIClient.test.js @@ -462,17 +462,17 @@ describe('OpenAIClient', () => { role: 'system', name: 'example_user', content: - 'Let\'s circle back when we have more bandwidth to touch base on opportunities for increased leverage.', + "Let's circle back when we have more bandwidth to touch base on opportunities for increased leverage.", }, { role: 'system', name: 'example_assistant', - content: 'Let\'s talk later when we\'re less busy about how to do better.', + content: "Let's talk later when we're less busy about how to do better.", }, { role: 'user', content: - 'This late pivot means we don\'t have time to boil the ocean for the client deliverable.', + "This late pivot means we don't have time to boil the ocean for the client deliverable.", }, ]; diff --git a/api/app/clients/tools/structured/AzureAISearch.js b/api/app/clients/tools/structured/AzureAISearch.js index e25da94426..7432d0722e 100644 --- a/api/app/clients/tools/structured/AzureAISearch.js +++ b/api/app/clients/tools/structured/AzureAISearch.js @@ -18,7 +18,7 @@ class AzureAISearch extends Tool { super(); this.name = 'azure-ai-search'; this.description = - 'Use the \'azure-ai-search\' tool to retrieve search results relevant to your input'; + "Use the 'azure-ai-search' tool to retrieve search results relevant to your input"; /* Used to initialize the Tool without necessary variables. */ this.override = fields.override ?? false; diff --git a/api/app/clients/tools/structured/DALLE3.js b/api/app/clients/tools/structured/DALLE3.js index fc0f1851f6..5ead9ab388 100644 --- a/api/app/clients/tools/structured/DALLE3.js +++ b/api/app/clients/tools/structured/DALLE3.js @@ -11,7 +11,7 @@ const extractBaseURL = require('~/utils/extractBaseURL'); const { logger } = require('~/config'); const displayMessage = - 'DALL-E displayed an image. All generated images are already plainly visible, so don\'t repeat the descriptions in detail. Do not list download links as they are available in the UI already. The user may download the images by clicking on them, but do not mention anything about downloading to the user.'; + "DALL-E displayed an image. All generated images are already plainly visible, so don't repeat the descriptions in detail. Do not list download links as they are available in the UI already. The user may download the images by clicking on them, but do not mention anything about downloading to the user."; class DALLE3 extends Tool { constructor(fields = {}) { super(); diff --git a/api/app/clients/tools/structured/FluxAPI.js b/api/app/clients/tools/structured/FluxAPI.js index 80f9772200..59902fbdd2 100644 --- a/api/app/clients/tools/structured/FluxAPI.js +++ b/api/app/clients/tools/structured/FluxAPI.js @@ -8,7 +8,7 @@ const { FileContext, ContentTypes } = require('librechat-data-provider'); const { logger } = require('~/config'); const displayMessage = - 'Flux displayed an image. All generated images are already plainly visible, so don\'t repeat the descriptions in detail. Do not list download links as they are available in the UI already. The user may download the images by clicking on them, but do not mention anything about downloading to the user.'; + "Flux displayed an image. All generated images are already plainly visible, so don't repeat the descriptions in detail. Do not list download links as they are available in the UI already. The user may download the images by clicking on them, but do not mention anything about downloading to the user."; /** * FluxAPI - A tool for generating high-quality images from text prompts using the Flux API. diff --git a/api/app/clients/tools/structured/OpenAIImageTools.js b/api/app/clients/tools/structured/OpenAIImageTools.js index afea9dfd55..499cda3ea7 100644 --- a/api/app/clients/tools/structured/OpenAIImageTools.js +++ b/api/app/clients/tools/structured/OpenAIImageTools.js @@ -64,7 +64,7 @@ const DEFAULT_IMAGE_EDIT_PROMPT_DESCRIPTION = `Describe the changes, enhancement Always base this prompt on the most recently uploaded reference images.`; const displayMessage = - 'The tool displayed an image. All generated images are already plainly visible, so don\'t repeat the descriptions in detail. Do not list download links as they are available in the UI already. The user may download the images by clicking on them, but do not mention anything about downloading to the user.'; + "The tool displayed an image. All generated images are already plainly visible, so don't repeat the descriptions in detail. Do not list download links as they are available in the UI already. The user may download the images by clicking on them, but do not mention anything about downloading to the user."; /** * Replaces unwanted characters from the input string diff --git a/api/app/clients/tools/structured/OpenWeather.js b/api/app/clients/tools/structured/OpenWeather.js index b84225101c..f92fe522ce 100644 --- a/api/app/clients/tools/structured/OpenWeather.js +++ b/api/app/clients/tools/structured/OpenWeather.js @@ -232,7 +232,7 @@ class OpenWeather extends Tool { if (['current_forecast', 'timestamp', 'daily_aggregation', 'overview'].includes(action)) { if (typeof finalLat !== 'number' || typeof finalLon !== 'number') { - return 'Error: lat and lon are required and must be numbers for this action (or specify \'city\').'; + return "Error: lat and lon are required and must be numbers for this action (or specify 'city')."; } } @@ -243,7 +243,7 @@ class OpenWeather extends Tool { let dt; if (action === 'timestamp') { if (!date) { - return 'Error: For timestamp action, a \'date\' in YYYY-MM-DD format is required.'; + return "Error: For timestamp action, a 'date' in YYYY-MM-DD format is required."; } dt = this.convertDateToUnix(date); } diff --git a/api/app/clients/tools/structured/StableDiffusion.js b/api/app/clients/tools/structured/StableDiffusion.js index 25a9e0abd3..9e67066de0 100644 --- a/api/app/clients/tools/structured/StableDiffusion.js +++ b/api/app/clients/tools/structured/StableDiffusion.js @@ -11,7 +11,7 @@ const paths = require('~/config/paths'); const { logger } = require('~/config'); const displayMessage = - 'Stable Diffusion displayed an image. All generated images are already plainly visible, so don\'t repeat the descriptions in detail. Do not list download links as they are available in the UI already. The user may download the images by clicking on them, but do not mention anything about downloading to the user.'; + "Stable Diffusion displayed an image. All generated images are already plainly visible, so don't repeat the descriptions in detail. Do not list download links as they are available in the UI already. The user may download the images by clicking on them, but do not mention anything about downloading to the user."; class StableDiffusionAPI extends Tool { constructor(fields) { @@ -44,7 +44,7 @@ class StableDiffusionAPI extends Tool { // "negative_prompt":"semi-realistic, cgi, 3d, render, sketch, cartoon, drawing, anime, out of frame, low quality, ugly, mutation, deformed" // - Generate images only once per human query unless explicitly requested by the user`; this.description = - 'You can generate images using text with \'stable-diffusion\'. This tool is exclusively for visual content.'; + "You can generate images using text with 'stable-diffusion'. This tool is exclusively for visual content."; this.schema = z.object({ prompt: z .string() diff --git a/api/app/clients/tools/structured/TraversaalSearch.js b/api/app/clients/tools/structured/TraversaalSearch.js index e8ceeda134..0e6b7fc1c9 100644 --- a/api/app/clients/tools/structured/TraversaalSearch.js +++ b/api/app/clients/tools/structured/TraversaalSearch.js @@ -21,7 +21,7 @@ class TraversaalSearch extends Tool { query: z .string() .describe( - 'A properly written sentence to be interpreted by an AI to search the web according to the user\'s request.', + "A properly written sentence to be interpreted by an AI to search the web according to the user's request.", ), }); @@ -38,7 +38,6 @@ class TraversaalSearch extends Tool { return apiKey; } - // eslint-disable-next-line no-unused-vars async _call({ query }, _runManager) { const body = { query: [query], diff --git a/api/app/clients/tools/structured/YouTube.js b/api/app/clients/tools/structured/YouTube.js index aa19fc211f..d9d3f76733 100644 --- a/api/app/clients/tools/structured/YouTube.js +++ b/api/app/clients/tools/structured/YouTube.js @@ -29,7 +29,7 @@ function parseTranscript(transcriptResponse) { .map((entry) => entry.text.trim()) .filter((text) => text) .join(' ') - .replaceAll('&#39;', '\''); + .replaceAll('&#39;', "'"); } function createYouTubeTools(fields = {}) { diff --git a/api/app/clients/tools/util/fileSearch.js b/api/app/clients/tools/util/fileSearch.js index 54da483362..19d3a79edb 100644 --- a/api/app/clients/tools/util/fileSearch.js +++ b/api/app/clients/tools/util/fileSearch.js @@ -135,7 +135,7 @@ const createFileSearchTool = async ({ req, files, entity_id }) => { query: z .string() .describe( - 'A natural language query to search for relevant information in the files. Be specific and use keywords related to the information you\'re looking for. The query will be used for semantic similarity matching against the file contents.', + "A natural language query to search for relevant information in the files. Be specific and use keywords related to the information you're looking for. The query will be used for semantic similarity matching against the file contents.", ), }), }, diff --git a/api/app/clients/tools/util/handleTools.test.js b/api/app/clients/tools/util/handleTools.test.js index 6538ce9aa4..42be6ce4d2 100644 --- a/api/app/clients/tools/util/handleTools.test.js +++ b/api/app/clients/tools/util/handleTools.test.js @@ -218,7 +218,6 @@ describe('Tool Handlers', () => { try { await loadTool2(); } catch (error) { - // eslint-disable-next-line jest/no-conditional-expect expect(error).toBeDefined(); } }); diff --git a/api/models/ConversationTag.js b/api/models/ConversationTag.js index f0cac8620e..1ebe15e496 100644 --- a/api/models/ConversationTag.js +++ b/api/models/ConversationTag.js @@ -140,13 +140,13 @@ const adjustPositions = async (user, oldPosition, newPosition) => { const position = oldPosition < newPosition ? { - $gt: Math.min(oldPosition, newPosition), - $lte: Math.max(oldPosition, newPosition), - } + $gt: Math.min(oldPosition, newPosition), + $lte: Math.max(oldPosition, newPosition), + } : { - $gte: Math.min(oldPosition, newPosition), - $lt: Math.max(oldPosition, newPosition), - }; + $gte: Math.min(oldPosition, newPosition), + $lt: Math.max(oldPosition, newPosition), + }; await ConversationTag.updateMany( { diff --git a/api/models/Message.spec.js b/api/models/Message.spec.js index a542130b59..7aef843678 100644 --- a/api/models/Message.spec.js +++ b/api/models/Message.spec.js @@ -153,7 +153,7 @@ describe('Message Operations', () => { }); describe('Conversation Hijacking Prevention', () => { - it('should not allow editing a message in another user\'s conversation', async () => { + it("should not allow editing a message in another user's conversation", async () => { const attackerReq = { user: { id: 'attacker123' } }; const victimConversationId = 'victim-convo-123'; const victimMessageId = 'victim-msg-123'; @@ -175,7 +175,7 @@ describe('Message Operations', () => { ); }); - it('should not allow deleting messages from another user\'s conversation', async () => { + it("should not allow deleting messages from another user's conversation", async () => { const attackerReq = { user: { id: 'attacker123' } }; const victimConversationId = 'victim-convo-123'; const victimMessageId = 'victim-msg-123'; @@ -193,7 +193,7 @@ describe('Message Operations', () => { }); }); - it('should not allow inserting a new message into another user\'s conversation', async () => { + it("should not allow inserting a new message into another user's conversation", async () => { const attackerReq = { user: { id: 'attacker123' } }; const victimConversationId = uuidv4(); // Use a valid UUID diff --git a/api/server/controllers/ErrorController.js b/api/server/controllers/ErrorController.js index 234cb90fb3..53dcbfe929 100644 --- a/api/server/controllers/ErrorController.js +++ b/api/server/controllers/ErrorController.js @@ -24,7 +24,6 @@ const handleValidationError = (err, res) => { } }; -// eslint-disable-next-line no-unused-vars module.exports = (err, req, res, next) => { try { if (err.name === 'ValidationError') { diff --git a/api/server/controllers/agents/errors.js b/api/server/controllers/agents/errors.js index fb4de45085..9f3231f83c 100644 --- a/api/server/controllers/agents/errors.js +++ b/api/server/controllers/agents/errors.js @@ -75,7 +75,7 @@ const createErrorHandler = ({ req, res, getContext, originPath = '/assistants/ch } else if (/Files.*are invalid/.test(error.message)) { const errorMessage = `Files are invalid, or may not have uploaded yet.${ endpoint === 'azureAssistants' - ? ' If using Azure OpenAI, files are only available in the region of the assistant\'s model at the time of upload.' + ? " If using Azure OpenAI, files are only available in the region of the assistant's model at the time of upload." : '' }`; return sendResponse(req, res, messageData, errorMessage); diff --git a/api/server/controllers/agents/request.js b/api/server/controllers/agents/request.js index fcee62edc7..24b7822c1f 100644 --- a/api/server/controllers/agents/request.js +++ b/api/server/controllers/agents/request.js @@ -228,7 +228,7 @@ const AgentController = async (req, res, next, initializeClient, addTitle) => { // Save user message if needed if (!client.skipSaveUserMessage) { await saveMessage(req, userMessage, { - context: 'api/server/controllers/agents/request.js - don\'t skip saving user message', + context: "api/server/controllers/agents/request.js - don't skip saving user message", }); } diff --git a/api/server/controllers/assistants/errors.js b/api/server/controllers/assistants/errors.js index a4b880bf04..7a4298e595 100644 --- a/api/server/controllers/assistants/errors.js +++ b/api/server/controllers/assistants/errors.js @@ -78,7 +78,7 @@ const createErrorHandler = ({ req, res, getContext, originPath = '/assistants/ch } else if (/Files.*are invalid/.test(error.message)) { const errorMessage = `Files are invalid, or may not have uploaded yet.${ endpoint === 'azureAssistants' - ? ' If using Azure OpenAI, files are only available in the region of the assistant\'s model at the time of upload.' + ? " If using Azure OpenAI, files are only available in the region of the assistant's model at the time of upload." : '' }`; return sendResponse(req, res, messageData, errorMessage); diff --git a/api/server/controllers/assistants/v1.js b/api/server/controllers/assistants/v1.js index 8fb73167c1..59068f5526 100644 --- a/api/server/controllers/assistants/v1.js +++ b/api/server/controllers/assistants/v1.js @@ -39,12 +39,10 @@ const createAssistant = async (req, res) => { const toolDefinitions = req.app.locals.availableTools; const toolDef = toolDefinitions[tool]; if (!toolDef && manifestToolMap[tool] && manifestToolMap[tool].toolkit === true) { - return ( - Object.entries(toolDefinitions) - .filter(([key]) => key.startsWith(`${tool}_`)) - // eslint-disable-next-line no-unused-vars - .map(([_, val]) => val) - ); + return Object.entries(toolDefinitions) + .filter(([key]) => key.startsWith(`${tool}_`)) + + .map(([_, val]) => val); } return toolDef; @@ -144,12 +142,10 @@ const patchAssistant = async (req, res) => { const toolDefinitions = req.app.locals.availableTools; const toolDef = toolDefinitions[tool]; if (!toolDef && manifestToolMap[tool] && manifestToolMap[tool].toolkit === true) { - return ( - Object.entries(toolDefinitions) - .filter(([key]) => key.startsWith(`${tool}_`)) - // eslint-disable-next-line no-unused-vars - .map(([_, val]) => val) - ); + return Object.entries(toolDefinitions) + .filter(([key]) => key.startsWith(`${tool}_`)) + + .map(([_, val]) => val); } return toolDef; diff --git a/api/server/controllers/assistants/v2.js b/api/server/controllers/assistants/v2.js index 3bf83a626f..f8fde9f92b 100644 --- a/api/server/controllers/assistants/v2.js +++ b/api/server/controllers/assistants/v2.js @@ -36,12 +36,10 @@ const createAssistant = async (req, res) => { const toolDefinitions = req.app.locals.availableTools; const toolDef = toolDefinitions[tool]; if (!toolDef && manifestToolMap[tool] && manifestToolMap[tool].toolkit === true) { - return ( - Object.entries(toolDefinitions) - .filter(([key]) => key.startsWith(`${tool}_`)) - // eslint-disable-next-line no-unused-vars - .map(([_, val]) => val) - ); + return Object.entries(toolDefinitions) + .filter(([key]) => key.startsWith(`${tool}_`)) + + .map(([_, val]) => val); } return toolDef; @@ -131,7 +129,7 @@ const updateAssistant = async ({ req, openai, assistant_id, updateData }) => { if (!actualTool && manifestToolMap[tool] && manifestToolMap[tool].toolkit === true) { actualTool = Object.entries(toolDefinitions) .filter(([key]) => key.startsWith(`${tool}_`)) - // eslint-disable-next-line no-unused-vars + .map(([_, val]) => val); } else if (!actualTool) { continue; diff --git a/api/server/middleware/abortMiddleware.js b/api/server/middleware/abortMiddleware.js index bfc28f513d..94d69004bd 100644 --- a/api/server/middleware/abortMiddleware.js +++ b/api/server/middleware/abortMiddleware.js @@ -327,7 +327,7 @@ const handleAbortError = async (res, req, error, data) => { errorText = `{"type":"${ErrorTypes.INVALID_REQUEST}"}`; } - if (error?.message?.includes('does not support \'system\'')) { + if (error?.message?.includes("does not support 'system'")) { errorText = `{"type":"${ErrorTypes.NO_SYSTEM_MESSAGES}"}`; } diff --git a/api/server/middleware/abortRun.js b/api/server/middleware/abortRun.js index 01b34aacc2..6fec1136f8 100644 --- a/api/server/middleware/abortRun.js +++ b/api/server/middleware/abortRun.js @@ -34,7 +34,7 @@ async function abortRun(req, res) { const [thread_id, run_id] = runValues.split(':'); if (!run_id) { - logger.warn('[abortRun] Couldn\'t find run for cancel request', { thread_id }); + logger.warn("[abortRun] Couldn't find run for cancel request", { thread_id }); return res.status(204).send({ message: 'Run not found' }); } else if (run_id === 'cancelled') { logger.warn('[abortRun] Run already cancelled', { thread_id }); diff --git a/api/server/routes/__tests__/config.spec.js b/api/server/routes/__tests__/config.spec.js index 054e4726f0..7d7d3ea13a 100644 --- a/api/server/routes/__tests__/config.spec.js +++ b/api/server/routes/__tests__/config.spec.js @@ -43,7 +43,6 @@ afterEach(() => { //TODO: This works/passes locally but http request tests fail with 404 in CI. Need to figure out why. -// eslint-disable-next-line jest/no-disabled-tests describe.skip('GET /', () => { it('should return 200 and the correct body', async () => { process.env.APP_TITLE = 'Test Title'; diff --git a/api/server/routes/share.js b/api/server/routes/share.js index e551f4a354..beb959f553 100644 --- a/api/server/routes/share.js +++ b/api/server/routes/share.js @@ -54,9 +54,7 @@ router.get('/', requireJwtAuth, async (req, res) => { sortDirection: ['asc', 'desc'].includes(req.query.sortDirection) ? req.query.sortDirection : 'desc', - search: req.query.search - ? decodeURIComponent(req.query.search.trim()) - : undefined, + search: req.query.search ? decodeURIComponent(req.query.search.trim()) : undefined, }; const result = await getSharedLinks( diff --git a/api/server/routes/types/assistants.js b/api/server/routes/types/assistants.js index 974bf587a8..ae1aae87a9 100644 --- a/api/server/routes/types/assistants.js +++ b/api/server/routes/types/assistants.js @@ -3,7 +3,7 @@ * @readonly * @enum {string} */ -// eslint-disable-next-line no-unused-vars + const Tools = { code_interpreter: 'code_interpreter', retrieval: 'retrieval', diff --git a/api/server/services/Artifacts/update.spec.js b/api/server/services/Artifacts/update.spec.js index 2f5b9d7bf6..d9dc417d0e 100644 --- a/api/server/services/Artifacts/update.spec.js +++ b/api/server/services/Artifacts/update.spec.js @@ -89,9 +89,9 @@ describe('replaceArtifactContent', () => { }; test('should replace content within artifact boundaries', () => { - const original = 'console.log(\'hello\')'; + const original = "console.log('hello')"; const artifact = createTestArtifact(original); - const updated = 'console.log(\'updated\')'; + const updated = "console.log('updated')"; const result = replaceArtifactContent(artifact.text, artifact, original, updated); expect(result).toContain(updated); diff --git a/api/server/services/Config/loadAsyncEndpoints.js b/api/server/services/Config/loadAsyncEndpoints.js index 0282146cd1..b8226294c8 100644 --- a/api/server/services/Config/loadAsyncEndpoints.js +++ b/api/server/services/Config/loadAsyncEndpoints.js @@ -32,14 +32,14 @@ async function loadAsyncEndpoints(req) { const gptPlugins = useAzure || openAIApiKey || azureOpenAIApiKey ? { - availableAgents: ['classic', 'functions'], - userProvide: useAzure ? false : userProvidedOpenAI, - userProvideURL: useAzure - ? false - : config[EModelEndpoint.openAI]?.userProvideURL || + availableAgents: ['classic', 'functions'], + userProvide: useAzure ? false : userProvidedOpenAI, + userProvideURL: useAzure + ? false + : config[EModelEndpoint.openAI]?.userProvideURL || config[EModelEndpoint.azureOpenAI]?.userProvideURL, - azure: useAzurePlugins || useAzure, - } + azure: useAzurePlugins || useAzure, + } : false; return { google, gptPlugins }; diff --git a/api/server/services/Endpoints/azureAssistants/build.js b/api/server/services/Endpoints/azureAssistants/build.js index 54a32e4d3c..53b1dbeb68 100644 --- a/api/server/services/Endpoints/azureAssistants/build.js +++ b/api/server/services/Endpoints/azureAssistants/build.js @@ -3,7 +3,6 @@ const generateArtifactsPrompt = require('~/app/clients/prompts/artifacts'); const { getAssistant } = require('~/models/Assistant'); const buildOptions = async (endpoint, parsedBody) => { - const { promptPrefix, assistant_id, iconURL, greeting, spec, artifacts, ...modelOptions } = parsedBody; const endpointOption = removeNullishValues({ diff --git a/api/server/services/Endpoints/google/initialize.js b/api/server/services/Endpoints/google/initialize.js index b7419a8a87..b6bc2d6a79 100644 --- a/api/server/services/Endpoints/google/initialize.js +++ b/api/server/services/Endpoints/google/initialize.js @@ -25,9 +25,9 @@ const initializeClient = async ({ req, res, endpointOption, overrideModel, optio const credentials = isUserProvided ? userKey : { - [AuthKeys.GOOGLE_SERVICE_KEY]: serviceKey, - [AuthKeys.GOOGLE_API_KEY]: GOOGLE_KEY, - }; + [AuthKeys.GOOGLE_SERVICE_KEY]: serviceKey, + [AuthKeys.GOOGLE_API_KEY]: GOOGLE_KEY, + }; let clientOptions = {}; diff --git a/api/server/services/Endpoints/google/llm.js b/api/server/services/Endpoints/google/llm.js index a64b33480b..12243054b4 100644 --- a/api/server/services/Endpoints/google/llm.js +++ b/api/server/services/Endpoints/google/llm.js @@ -94,7 +94,7 @@ function getLLMConfig(credentials, options = {}) { // Extract from credentials const serviceKeyRaw = creds[AuthKeys.GOOGLE_SERVICE_KEY] ?? {}; const serviceKey = - typeof serviceKeyRaw === 'string' ? JSON.parse(serviceKeyRaw) : serviceKeyRaw ?? {}; + typeof serviceKeyRaw === 'string' ? JSON.parse(serviceKeyRaw) : (serviceKeyRaw ?? {}); const project_id = serviceKey?.project_id ?? null; const apiKey = creds[AuthKeys.GOOGLE_API_KEY] ?? null; diff --git a/api/server/services/Endpoints/gptPlugins/initialize.spec.js b/api/server/services/Endpoints/gptPlugins/initialize.spec.js index 02199c9397..f9cb2750a4 100644 --- a/api/server/services/Endpoints/gptPlugins/initialize.spec.js +++ b/api/server/services/Endpoints/gptPlugins/initialize.spec.js @@ -114,11 +114,11 @@ describe('gptPlugins/initializeClient', () => { test('should initialize PluginsClient with Azure credentials when PLUGINS_USE_AZURE is true', async () => { process.env.AZURE_API_KEY = 'test-azure-api-key'; (process.env.AZURE_OPENAI_API_INSTANCE_NAME = 'some-value'), - (process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME = 'some-value'), - (process.env.AZURE_OPENAI_API_VERSION = 'some-value'), - (process.env.AZURE_OPENAI_API_COMPLETIONS_DEPLOYMENT_NAME = 'some-value'), - (process.env.AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME = 'some-value'), - (process.env.PLUGINS_USE_AZURE = 'true'); + (process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME = 'some-value'), + (process.env.AZURE_OPENAI_API_VERSION = 'some-value'), + (process.env.AZURE_OPENAI_API_COMPLETIONS_DEPLOYMENT_NAME = 'some-value'), + (process.env.AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME = 'some-value'), + (process.env.PLUGINS_USE_AZURE = 'true'); process.env.DEBUG_PLUGINS = 'false'; process.env.OPENAI_SUMMARIZE = 'false'; diff --git a/api/server/services/Endpoints/openAI/initialize.spec.js b/api/server/services/Endpoints/openAI/initialize.spec.js index 16563e4b26..067486b431 100644 --- a/api/server/services/Endpoints/openAI/initialize.spec.js +++ b/api/server/services/Endpoints/openAI/initialize.spec.js @@ -112,11 +112,11 @@ describe('initializeClient', () => { test('should initialize client with Azure credentials when endpoint is azureOpenAI', async () => { process.env.AZURE_API_KEY = 'test-azure-api-key'; (process.env.AZURE_OPENAI_API_INSTANCE_NAME = 'some-value'), - (process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME = 'some-value'), - (process.env.AZURE_OPENAI_API_VERSION = 'some-value'), - (process.env.AZURE_OPENAI_API_COMPLETIONS_DEPLOYMENT_NAME = 'some-value'), - (process.env.AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME = 'some-value'), - (process.env.OPENAI_API_KEY = 'test-openai-api-key'); + (process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME = 'some-value'), + (process.env.AZURE_OPENAI_API_VERSION = 'some-value'), + (process.env.AZURE_OPENAI_API_COMPLETIONS_DEPLOYMENT_NAME = 'some-value'), + (process.env.AZURE_OPENAI_API_EMBEDDINGS_DEPLOYMENT_NAME = 'some-value'), + (process.env.OPENAI_API_KEY = 'test-openai-api-key'); process.env.DEBUG_OPENAI = 'false'; process.env.OPENAI_SUMMARIZE = 'false'; diff --git a/api/server/services/Runs/StreamRunManager.js b/api/server/services/Runs/StreamRunManager.js index 4bab7326bb..e6e8b6ae9d 100644 --- a/api/server/services/Runs/StreamRunManager.js +++ b/api/server/services/Runs/StreamRunManager.js @@ -302,7 +302,7 @@ class StreamRunManager { for (const d of delta[key]) { if (typeof d === 'object' && !Object.prototype.hasOwnProperty.call(d, 'index')) { - logger.warn('Expected an object with an \'index\' for array updates but got:', d); + logger.warn("Expected an object with an 'index' for array updates but got:", d); continue; } diff --git a/api/server/services/Threads/processMessages.spec.js b/api/server/services/Threads/processMessages.spec.js index 673b96bf7c..a89f2b9f5b 100644 --- a/api/server/services/Threads/processMessages.spec.js +++ b/api/server/services/Threads/processMessages.spec.js @@ -255,7 +255,7 @@ describe('processMessages', () => { type: 'text', text: { value: - 'The text you have uploaded is from the book "Harry Potter and the Philosopher\'s Stone" by J.K. Rowling. It follows the story of a young boy named Harry Potter who discovers that he is a wizard on his eleventh birthday. Here are some key points of the narrative:\n\n1. **Discovery and Invitation to Hogwarts**: Harry learns that he is a wizard and receives an invitation to attend Hogwarts School of Witchcraft and Wizardry【11:2†source】【11:4†source】.\n\n2. **Shopping for Supplies**: Hagrid takes Harry to Diagon Alley to buy his school supplies, including his wand from Ollivander\'s【11:9†source】【11:14†source】.\n\n3. **Introduction to Hogwarts**: Harry is introduced to Hogwarts, the magical school where he will learn about magic and discover more about his own background【11:12†source】【11:18†source】.\n\n4. **Meeting Friends and Enemies**: At Hogwarts, Harry makes friends like Ron Weasley and Hermione Granger, and enemies like Draco Malfoy【11:16†source】.\n\n5. **Uncovering the Mystery**: Harry, along with Ron and Hermione, uncovers the mystery of the Philosopher\'s Stone and its connection to the dark wizard Voldemort【11:1†source】【11:10†source】【11:7†source】.\n\nThese points highlight Harry\'s initial experiences in the magical world and set the stage for his adventures at Hogwarts.', + "The text you have uploaded is from the book \"Harry Potter and the Philosopher's Stone\" by J.K. Rowling. It follows the story of a young boy named Harry Potter who discovers that he is a wizard on his eleventh birthday. Here are some key points of the narrative:\n\n1. **Discovery and Invitation to Hogwarts**: Harry learns that he is a wizard and receives an invitation to attend Hogwarts School of Witchcraft and Wizardry【11:2†source】【11:4†source】.\n\n2. **Shopping for Supplies**: Hagrid takes Harry to Diagon Alley to buy his school supplies, including his wand from Ollivander's【11:9†source】【11:14†source】.\n\n3. **Introduction to Hogwarts**: Harry is introduced to Hogwarts, the magical school where he will learn about magic and discover more about his own background【11:12†source】【11:18†source】.\n\n4. **Meeting Friends and Enemies**: At Hogwarts, Harry makes friends like Ron Weasley and Hermione Granger, and enemies like Draco Malfoy【11:16†source】.\n\n5. **Uncovering the Mystery**: Harry, along with Ron and Hermione, uncovers the mystery of the Philosopher's Stone and its connection to the dark wizard Voldemort【11:1†source】【11:10†source】【11:7†source】.\n\nThese points highlight Harry's initial experiences in the magical world and set the stage for his adventures at Hogwarts.", annotations: [ { type: 'file_citation', @@ -424,7 +424,7 @@ These points highlight Harry's initial experiences in the magical world and set type: 'text', text: { value: - 'The text you have uploaded is from the book "Harry Potter and the Philosopher\'s Stone" by J.K. Rowling. It follows the story of a young boy named Harry Potter who discovers that he is a wizard on his eleventh birthday. Here are some key points of the narrative:\n\n1. **Discovery and Invitation to Hogwarts**: Harry learns that he is a wizard and receives an invitation to attend Hogwarts School of Witchcraft and Wizardry【11:2†source】【11:4†source】.\n\n2. **Shopping for Supplies**: Hagrid takes Harry to Diagon Alley to buy his school supplies, including his wand from Ollivander\'s【11:9†source】【11:14†source】.\n\n3. **Introduction to Hogwarts**: Harry is introduced to Hogwarts, the magical school where he will learn about magic and discover more about his own background【11:12†source】【11:18†source】.\n\n4. **Meeting Friends and Enemies**: At Hogwarts, Harry makes friends like Ron Weasley and Hermione Granger, and enemies like Draco Malfoy【11:16†source】.\n\n5. **Uncovering the Mystery**: Harry, along with Ron and Hermione, uncovers the mystery of the Philosopher\'s Stone and its connection to the dark wizard Voldemort【11:1†source】【11:10†source】【11:7†source】.\n\nThese points highlight Harry\'s initial experiences in the magical world and set the stage for his adventures at Hogwarts.', + "The text you have uploaded is from the book \"Harry Potter and the Philosopher's Stone\" by J.K. Rowling. It follows the story of a young boy named Harry Potter who discovers that he is a wizard on his eleventh birthday. Here are some key points of the narrative:\n\n1. **Discovery and Invitation to Hogwarts**: Harry learns that he is a wizard and receives an invitation to attend Hogwarts School of Witchcraft and Wizardry【11:2†source】【11:4†source】.\n\n2. **Shopping for Supplies**: Hagrid takes Harry to Diagon Alley to buy his school supplies, including his wand from Ollivander's【11:9†source】【11:14†source】.\n\n3. **Introduction to Hogwarts**: Harry is introduced to Hogwarts, the magical school where he will learn about magic and discover more about his own background【11:12†source】【11:18†source】.\n\n4. **Meeting Friends and Enemies**: At Hogwarts, Harry makes friends like Ron Weasley and Hermione Granger, and enemies like Draco Malfoy【11:16†source】.\n\n5. **Uncovering the Mystery**: Harry, along with Ron and Hermione, uncovers the mystery of the Philosopher's Stone and its connection to the dark wizard Voldemort【11:1†source】【11:10†source】【11:7†source】.\n\nThese points highlight Harry's initial experiences in the magical world and set the stage for his adventures at Hogwarts.", annotations: [ { type: 'file_citation', @@ -582,7 +582,7 @@ These points highlight Harry's initial experiences in the magical world and set type: 'text', text: { value: - 'This is a test ^1^ with pre-existing citation-like text. Here\'s a real citation【11:2†source】.', + "This is a test ^1^ with pre-existing citation-like text. Here's a real citation【11:2†source】.", annotations: [ { type: 'file_citation', @@ -610,7 +610,7 @@ These points highlight Harry's initial experiences in the magical world and set }); const expectedText = - 'This is a test ^1^ with pre-existing citation-like text. Here\'s a real citation^1^.\n\n^1.^ test.txt'; + "This is a test ^1^ with pre-existing citation-like text. Here's a real citation^1^.\n\n^1.^ test.txt"; expect(result.text).toBe(expectedText); expect(result.edited).toBe(true); diff --git a/api/strategies/appleStrategy.js b/api/strategies/appleStrategy.js index a45f10fc62..4dbac2e364 100644 --- a/api/strategies/appleStrategy.js +++ b/api/strategies/appleStrategy.js @@ -18,17 +18,13 @@ const getProfileDetails = ({ idToken, profile }) => { const decoded = jwt.decode(idToken); - logger.debug( - `Decoded Apple JWT: ${JSON.stringify(decoded, null, 2)}`, - ); + logger.debug(`Decoded Apple JWT: ${JSON.stringify(decoded, null, 2)}`); return { email: decoded.email, id: decoded.sub, avatarUrl: null, // Apple does not provide an avatar URL - username: decoded.email - ? decoded.email.split('@')[0].toLowerCase() - : `user_${decoded.sub}`, + username: decoded.email ? decoded.email.split('@')[0].toLowerCase() : `user_${decoded.sub}`, name: decoded.name ? `${decoded.name.firstName} ${decoded.name.lastName}` : profile.displayName || null, diff --git a/api/strategies/appleStrategy.test.js b/api/strategies/appleStrategy.test.js index c457e15fdc..ecf850d35e 100644 --- a/api/strategies/appleStrategy.test.js +++ b/api/strategies/appleStrategy.test.js @@ -84,9 +84,7 @@ describe('Apple Login Strategy', () => { email: decoded.email, id: decoded.sub, avatarUrl: null, // Apple does not provide an avatar URL - username: decoded.email - ? decoded.email.split('@')[0].toLowerCase() - : `user_${decoded.sub}`, + username: decoded.email ? decoded.email.split('@')[0].toLowerCase() : `user_${decoded.sub}`, name: decoded.name ? `${decoded.name.firstName} ${decoded.name.lastName}` : profile.displayName || null, @@ -96,8 +94,12 @@ describe('Apple Login Strategy', () => { // Mock isEnabled based on environment variable isEnabled.mockImplementation((flag) => { - if (flag === 'true') { return true; } - if (flag === 'false') { return false; } + if (flag === 'true') { + return true; + } + if (flag === 'false') { + return false; + } return false; }); @@ -154,9 +156,7 @@ describe('Apple Login Strategy', () => { }); expect(jwt.decode).toHaveBeenCalledWith('fake_id_token'); - expect(logger.debug).toHaveBeenCalledWith( - expect.stringContaining('Decoded Apple JWT'), - ); + expect(logger.debug).toHaveBeenCalledWith(expect.stringContaining('Decoded Apple JWT')); expect(profileDetails).toEqual({ email: 'john.doe@example.com', id: 'apple-sub-1234', @@ -297,7 +297,7 @@ describe('Apple Login Strategy', () => { appleStrategyInstance._verify( fakeAccessToken, fakeRefreshToken, - null, // idToken is missing + null, // idToken is missing mockProfile, (err, user) => { mockVerifyCallback(err, user); diff --git a/api/strategies/validators.spec.js b/api/strategies/validators.spec.js index 312f06923d..06340fc14c 100644 --- a/api/strategies/validators.spec.js +++ b/api/strategies/validators.spec.js @@ -258,7 +258,7 @@ describe('Zod Schemas', () => { email: 'john@example.com', password: 'password123', confirm_password: 'password123', - extraField: 'I shouldn\'t be here', + extraField: "I shouldn't be here", }); expect(result.success).toBe(true); }); @@ -407,7 +407,7 @@ describe('Zod Schemas', () => { 'john{doe}', // Contains `{` and `}` 'j', // Only one character 'a'.repeat(81), // More than 80 characters - '\' OR \'1\'=\'1\'; --', // SQL Injection + "' OR '1'='1'; --", // SQL Injection '{$ne: null}', // MongoDB Injection '', // Basic XSS '">', // XSS breaking out of an attribute diff --git a/client/src/@types/i18next.d.ts b/client/src/@types/i18next.d.ts index 2d50f5a3cd..82f1ce1a3d 100644 --- a/client/src/@types/i18next.d.ts +++ b/client/src/@types/i18next.d.ts @@ -1,9 +1,9 @@ import { defaultNS, resources } from '~/locales/i18n'; declare module 'i18next' { - interface CustomTypeOptions { - defaultNS: typeof defaultNS; - resources: typeof resources.en; - strictKeyChecks: true - } -} \ No newline at end of file + interface CustomTypeOptions { + defaultNS: typeof defaultNS; + resources: typeof resources.en; + strictKeyChecks: true; + } +} diff --git a/client/src/common/menus.ts b/client/src/common/menus.ts index c46ad3f8bb..4d70f282c2 100644 --- a/client/src/common/menus.ts +++ b/client/src/common/menus.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ export type RenderProp< P = React.HTMLAttributes & { ref?: React.Ref; diff --git a/client/src/components/Artifacts/useDebounceCodeBlock.ts b/client/src/components/Artifacts/useDebounceCodeBlock.ts index 27aaf5bc83..1d895e97d9 100644 --- a/client/src/components/Artifacts/useDebounceCodeBlock.ts +++ b/client/src/components/Artifacts/useDebounceCodeBlock.ts @@ -9,16 +9,17 @@ export function useDebounceCodeBlock() { const setCodeBlocks = useSetRecoilState(codeBlocksState); const setCodeBlockIds = useSetRecoilState(codeBlockIdsState); - const updateCodeBlock = useCallback((codeBlock: CodeBlock) => { - console.log('Updating code block:', codeBlock); - setCodeBlocks((prev) => ({ - ...prev, - [codeBlock.id]: codeBlock, - })); - setCodeBlockIds((prev) => - prev.includes(codeBlock.id) ? prev : [...prev, codeBlock.id], - ); - }, [setCodeBlocks, setCodeBlockIds]); + const updateCodeBlock = useCallback( + (codeBlock: CodeBlock) => { + console.log('Updating code block:', codeBlock); + setCodeBlocks((prev) => ({ + ...prev, + [codeBlock.id]: codeBlock, + })); + setCodeBlockIds((prev) => (prev.includes(codeBlock.id) ? prev : [...prev, codeBlock.id])); + }, + [setCodeBlocks, setCodeBlockIds], + ); const debouncedUpdateCodeBlock = useCallback( debounce((codeBlock: CodeBlock) => { diff --git a/client/src/components/Auth/AuthLayout.tsx b/client/src/components/Auth/AuthLayout.tsx index d90f0d3dfe..e374c1305d 100644 --- a/client/src/components/Auth/AuthLayout.tsx +++ b/client/src/components/Auth/AuthLayout.tsx @@ -87,8 +87,8 @@ function AuthLayout({ {children} {!pathname.includes('2fa') && (pathname.includes('login') || pathname.includes('register')) && ( - - )} + + )}