mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-21 01:44:09 +01:00
* 🚀 feat: Introduce data schemas and refactor models to use @librechat/data-schemas * 🚀 feat: Add installation step for Data Schemas Package in backend review workflow * chore: Add `data-schemas` package to update/rebuild packages scripts * chore: Update Dockerfile to include data-schemas package build process * fix: add missing @rollup/plugin-typescript package * chore: Add GitHub Actions workflow for publishing data-schemas package --------- Co-authored-by: Danny Avila <danny@librechat.ai>
101 lines
2.2 KiB
TypeScript
101 lines
2.2 KiB
TypeScript
import mongoose, { Schema, Document, Types } from 'mongoose';
|
|
import { conversationPreset } from './defaults';
|
|
|
|
// @ts-ignore
|
|
export interface IConversation extends Document {
|
|
conversationId: string;
|
|
title?: string;
|
|
user?: string;
|
|
messages?: Types.ObjectId[];
|
|
agentOptions?: unknown;
|
|
// Fields provided by conversationPreset (adjust types as needed)
|
|
endpoint?: string;
|
|
endpointType?: string;
|
|
model?: string;
|
|
region?: string;
|
|
chatGptLabel?: string;
|
|
examples?: unknown[];
|
|
modelLabel?: string;
|
|
promptPrefix?: string;
|
|
temperature?: number;
|
|
top_p?: number;
|
|
topP?: number;
|
|
topK?: number;
|
|
maxOutputTokens?: number;
|
|
maxTokens?: number;
|
|
presence_penalty?: number;
|
|
frequency_penalty?: number;
|
|
file_ids?: string[];
|
|
resendImages?: boolean;
|
|
promptCache?: boolean;
|
|
thinking?: boolean;
|
|
thinkingBudget?: number;
|
|
system?: string;
|
|
resendFiles?: boolean;
|
|
imageDetail?: string;
|
|
agent_id?: string;
|
|
assistant_id?: string;
|
|
instructions?: string;
|
|
stop?: string[];
|
|
isArchived?: boolean;
|
|
iconURL?: string;
|
|
greeting?: string;
|
|
spec?: string;
|
|
tags?: string[];
|
|
tools?: string[];
|
|
maxContextTokens?: number;
|
|
max_tokens?: number;
|
|
reasoning_effort?: string;
|
|
// Additional fields
|
|
files?: string[];
|
|
expiredAt?: Date;
|
|
createdAt?: Date;
|
|
updatedAt?: Date;
|
|
}
|
|
|
|
const convoSchema: Schema<IConversation> = new Schema(
|
|
{
|
|
conversationId: {
|
|
type: String,
|
|
unique: true,
|
|
required: true,
|
|
index: true,
|
|
meiliIndex: true,
|
|
},
|
|
title: {
|
|
type: String,
|
|
default: 'New Chat',
|
|
meiliIndex: true,
|
|
},
|
|
user: {
|
|
type: String,
|
|
index: true,
|
|
},
|
|
messages: [{ type: mongoose.Schema.Types.ObjectId, ref: 'Message' }],
|
|
agentOptions: {
|
|
type: mongoose.Schema.Types.Mixed,
|
|
},
|
|
...conversationPreset,
|
|
agent_id: {
|
|
type: String,
|
|
},
|
|
tags: {
|
|
type: [String],
|
|
default: [],
|
|
meiliIndex: true,
|
|
},
|
|
files: {
|
|
type: [String],
|
|
},
|
|
expiredAt: {
|
|
type: Date,
|
|
},
|
|
},
|
|
{ timestamps: true },
|
|
);
|
|
|
|
convoSchema.index({ expiredAt: 1 }, { expireAfterSeconds: 0 });
|
|
convoSchema.index({ createdAt: 1, updatedAt: 1 });
|
|
convoSchema.index({ conversationId: 1, user: 1 }, { unique: true });
|
|
|
|
export default convoSchema;
|