- Implement dual-agent architecture supporting both Chat Completions and Responses API - Add comprehensive file upload functionality for responses agents with image and PDF support - Integrate OpenAI Conversations API for persistent file context across messages - Add compact UI design with reduced font sizes and tighter spacing for better chat focus - Include vector store management, document upload system, and admin dashboard enhancements - Fix conversation persistence ensuring uploaded files remain accessible in follow-up questions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
91 lines
No EOL
2.1 KiB
JavaScript
91 lines
No EOL
2.1 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
|
const { sequelize } = require('../config/database');
|
|
|
|
const Document = sequelize.define('Document', {
|
|
id: {
|
|
type: DataTypes.UUID,
|
|
defaultValue: DataTypes.UUIDV4,
|
|
primaryKey: true,
|
|
},
|
|
openaiFileId: {
|
|
type: DataTypes.STRING,
|
|
allowNull: true,
|
|
unique: true,
|
|
comment: 'OpenAI file ID from their API'
|
|
},
|
|
name: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false,
|
|
},
|
|
originalName: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false,
|
|
comment: 'Original filename when uploaded'
|
|
},
|
|
filePath: {
|
|
type: DataTypes.TEXT,
|
|
allowNull: true,
|
|
comment: 'Local file path if stored locally'
|
|
},
|
|
fileSize: {
|
|
type: DataTypes.BIGINT,
|
|
allowNull: false,
|
|
},
|
|
mimeType: {
|
|
type: DataTypes.STRING(100),
|
|
allowNull: false,
|
|
},
|
|
purpose: {
|
|
type: DataTypes.ENUM('file-search', 'code-interpreter', 'assistants'),
|
|
defaultValue: 'file-search',
|
|
allowNull: false,
|
|
},
|
|
status: {
|
|
type: DataTypes.ENUM('uploading', 'processed', 'error'),
|
|
defaultValue: 'uploading',
|
|
allowNull: false,
|
|
},
|
|
vectorStoreId: {
|
|
type: DataTypes.UUID,
|
|
allowNull: true,
|
|
references: {
|
|
model: 'vector_stores',
|
|
key: 'id',
|
|
},
|
|
onUpdate: 'CASCADE',
|
|
onDelete: 'SET NULL',
|
|
},
|
|
assistantId: {
|
|
type: DataTypes.UUID,
|
|
allowNull: true,
|
|
references: {
|
|
model: 'assistants',
|
|
key: 'id',
|
|
},
|
|
onUpdate: 'CASCADE',
|
|
onDelete: 'CASCADE',
|
|
},
|
|
uploadedByUserId: {
|
|
type: DataTypes.UUID,
|
|
allowNull: true,
|
|
comment: 'User who uploaded the document'
|
|
},
|
|
metadata: {
|
|
type: DataTypes.JSONB,
|
|
defaultValue: {},
|
|
},
|
|
}, {
|
|
tableName: 'documents',
|
|
timestamps: true,
|
|
indexes: [
|
|
{ fields: ['openaiFileId'], unique: true },
|
|
{ fields: ['vectorStoreId'] },
|
|
{ fields: ['assistantId'] },
|
|
{ fields: ['uploadedByUserId'] },
|
|
{ fields: ['status'] },
|
|
{ fields: ['purpose'] },
|
|
{ fields: ['createdAt'] },
|
|
],
|
|
});
|
|
|
|
module.exports = Document; |