Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🐛 fix: Move MemoryEntry and PluginAuth model retrieval inside methods for Runtime Usage
Danny Avila799f0e581020
diff --git a/packages/data-schemas/src/methods/memory.ts b/packages/data-schemas/src/methods/memory.tsindex 021354eab2..becb063f3d 100644--- a/packages/data-schemas/src/methods/memory.ts+++ b/packages/data-schemas/src/methods/memory.ts@@ -11,8 +11,6 @@ const formatDate = (date: Date): string => {// Factory function that takes mongoose instance and returns the methodsexport function createMemoryMethods(mongoose: typeof import('mongoose')) {- const MemoryEntry = mongoose.models.MemoryEntry;-/*** Creates a new memory entry for a user* Throws an error if a memory with the same key already exists@@ -28,6 +26,7 @@ export function createMemoryMethods(mongoose: typeof import('mongoose')) {return { ok: false };}+ const MemoryEntry = mongoose.models.MemoryEntry;const existingMemory = await MemoryEntry.findOne({ userId, key });if (existingMemory) {throw new Error('Memory with this key already exists');@@ -63,6 +62,7 @@ export function createMemoryMethods(mongoose: typeof import('mongoose')) {return { ok: false };}+ const MemoryEntry = mongoose.models.MemoryEntry;await MemoryEntry.findOneAndUpdate({ userId, key },{@@ -89,6 +89,7 @@ export function createMemoryMethods(mongoose: typeof import('mongoose')) {*/async function deleteMemory({ userId, key }: t.DeleteMemoryParams): Promise<t.MemoryResult> {try {+ const MemoryEntry = mongoose.models.MemoryEntry;const result = await MemoryEntry.findOneAndDelete({ userId, key });return { ok: !!result };} catch (error) {@@ -105,6 +106,7 @@ export function createMemoryMethods(mongoose: typeof import('mongoose')) {userId: string | Types.ObjectId,): Promise<t.IMemoryEntryLean[]> {try {+ const MemoryEntry = mongoose.models.MemoryEntry;return (await MemoryEntry.find({ userId }).lean()) as t.IMemoryEntryLean[];} catch (error) {throw new Error(diff --git a/packages/data-schemas/src/methods/pluginAuth.ts b/packages/data-schemas/src/methods/pluginAuth.tsindex f0256f859f..5355fec50c 100644--- a/packages/data-schemas/src/methods/pluginAuth.ts+++ b/packages/data-schemas/src/methods/pluginAuth.ts@@ -1,16 +1,14 @@import type { DeleteResult, Model } from 'mongoose';-import type { IPluginAuth } from '~/schema/pluginAuth';import type {FindPluginAuthsByKeysParams,UpdatePluginAuthParams,DeletePluginAuthParams,FindPluginAuthParams,+ IPluginAuth,} from '~/types';// Factory function that takes mongoose instance and returns the methodsexport function createPluginAuthMethods(mongoose: typeof import('mongoose')) {- const PluginAuth: Model<IPluginAuth> = mongoose.models.PluginAuth;-/*** Finds a single plugin auth entry by userId and authField*/@@ -19,6 +17,7 @@ export function createPluginAuthMethods(mongoose: typeof import('mongoose')) {authField,}: FindPluginAuthParams): Promise<IPluginAuth | null> {try {+ const PluginAuth: Model<IPluginAuth> = mongoose.models.PluginAuth;return await PluginAuth.findOne({ userId, authField }).lean();} catch (error) {throw new Error(@@ -39,6 +38,7 @@ export function createPluginAuthMethods(mongoose: typeof import('mongoose')) {return [];}+ const PluginAuth: Model<IPluginAuth> = mongoose.models.PluginAuth;return await PluginAuth.find({userId,pluginKey: { $in: pluginKeys },@@ -60,6 +60,7 @@ export function createPluginAuthMethods(mongoose: typeof import('mongoose')) {value,}: UpdatePluginAuthParams): Promise<IPluginAuth> {try {+ const PluginAuth: Model<IPluginAuth> = mongoose.models.PluginAuth;const existingAuth = await PluginAuth.findOne({ userId, pluginKey, authField }).lean();if (existingAuth) {@@ -95,6 +96,7 @@ export function createPluginAuthMethods(mongoose: typeof import('mongoose')) {all = false,}: DeletePluginAuthParams): Promise<DeleteResult> {try {+ const PluginAuth: Model<IPluginAuth> = mongoose.models.PluginAuth;if (all) {const filter: DeletePluginAuthParams = { userId };if (pluginKey) {@@ -120,6 +122,7 @@ export function createPluginAuthMethods(mongoose: typeof import('mongoose')) {*/async function deleteAllUserPluginAuths(userId: string): Promise<DeleteResult> {try {+ const PluginAuth: Model<IPluginAuth> = mongoose.models.PluginAuth;return await PluginAuth.deleteMany({ userId });} catch (error) {throw new Error(