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
import { Schema } from 'mongoose';
import { Constants, PromptGroupSources } from 'librechat-data-provider';
import type { IPromptGroupDocument } from '~/types';
const promptGroupSchema: Schema<IPromptGroupDocument> = new Schema<IPromptGroupDocument>(
{
name: {
type: String,
required: true,
index: true,
},
numberOfGenerations: {
type: Number,
default: 0,
},
oneliner: {
type: String,
default: '',
},
category: {
type: String,
default: '',
index: true,
},
productionId: {
type: Schema.Types.ObjectId,
ref: 'Prompt',
required: function (this: IPromptGroupDocument) {
return (this.source ?? PromptGroupSources.native) === PromptGroupSources.native;
},
index: true,
},
author: {
type: Schema.Types.ObjectId,
ref: 'User',
required: true,
index: true,
},
authorName: {
type: String,
required: true,
},
command: {
type: String,
index: true,
validate: {
validator: function (v: string | undefined | null): boolean {
return v === undefined || v === null || v === '' || /^[a-z0-9-]+$/.test(v);
},
message: (props: { value?: string } | undefined) =>
`${props?.value ?? 'Value'} is not a valid command. Only lowercase alphanumeric characters and hyphens are allowed.`,
},
maxlength: [
Constants.COMMANDS_MAX_LENGTH as number,
`Command cannot be longer than ${Constants.COMMANDS_MAX_LENGTH} characters`,
],
}, // Casting here bypasses the type error for the command field.
/**
* Provenance of this prompt group.
*
* - `native` — authored directly inside LibreChat.
* - `langfuse` — mirrored from a configured Langfuse prompt.
*/
source: {
type: String,
enum: Object.values(PromptGroupSources),
default: PromptGroupSources.native,
},
/** Name of the prompt in its Langfuse project. */
sourcePromptName: {
type: String,
required: function (this: IPromptGroupDocument) {
return this.source === PromptGroupSources.langfuse;
},
},
/** Langfuse project ID the prompt was mirrored from. */
sourceProjectId: {
type: String,
required: function (this: IPromptGroupDocument) {
return this.source === PromptGroupSources.langfuse;
},
},
/** Tenant's Langfuse destination key (e.g. `eu`) the prompt was mirrored from. */
sourceDestination: {
type: String,
required: function (this: IPromptGroupDocument) {
return this.source === PromptGroupSources.langfuse;
},
},
tenantId: {
type: String,
index: true,
},
},
{
timestamps: true,
},
);
promptGroupSchema.index({ numberOfGenerations: -1, updatedAt: -1, _id: 1 });
promptGroupSchema.index(
{ tenantId: 1, sourceDestination: 1, sourceProjectId: 1, sourcePromptName: 1 },
{
unique: true,
partialFilterExpression: { sourcePromptName: { $exists: true } },
},
);
// Serves the same lookup when no tenant context is active (env-mode sync, tenantId unset).
promptGroupSchema.index(
{ sourceDestination: 1, sourceProjectId: 1, sourcePromptName: 1 },
{ partialFilterExpression: { sourcePromptName: { $exists: true } } },
);
export default promptGroupSchema;