feat(documents): 支持文档上传与本地RAG入库

This commit is contained in:
2026-05-30 00:10:05 +08:00
parent 7a6c110103
commit 4a831ee2c5
13 changed files with 403 additions and 0 deletions

23
apps/documents/models.py Normal file
View File

@@ -0,0 +1,23 @@
from django.db import models
class UploadedDocument(models.Model):
STATUS_UPLOADED = "uploaded"
STATUS_INDEXED = "indexed"
STATUS_FAILED = "failed"
scenario_id = models.CharField(max_length=100, db_index=True)
original_name = models.CharField(max_length=255)
file = models.FileField(upload_to="documents/%Y%m%d/")
file_type = models.CharField(max_length=20)
size = models.PositiveIntegerField(default=0)
status = models.CharField(max_length=20, default=STATUS_UPLOADED, db_index=True)
error_message = models.TextField(blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
ordering = ["-created_at"]
def __str__(self) -> str:
return self.original_name