Skip to content

Conversation

@tasumu
Copy link
Contributor

@tasumu tasumu commented Dec 28, 2025

Summary

Add optional replace_existing parameter to document upload endpoints. When set to true, existing documents with the same name are deleted before uploading, preventing duplicate filenames with (1), (2) suffixes.

  • Add replace_existing parameter to FileService.upload_document()
  • Expose parameter in SDK API (POST /datasets/{id}/documents)
  • Expose parameter in WebUI API (POST /upload)
  • Add tests for replace_existing functionality

What problem does this PR solve?

Motivation: We use a helper script to recursively upload only changed files from a directory to keep the RAG system up-to-date with the latest information.

Problem: When updating files, old versions are not deleted and new versions are added with names like file(1).pdf. This causes:

  • Old information mixed in search results, reducing RAG accuracy
  • Wasted storage space

Solution: This PR adds a replace_existing parameter that allows users to replace existing documents with the same name instead of creating duplicates.

Type of change

  • New Feature (non-breaking change which adds functionality)
@tasumu tasumu force-pushed the feature/replace-existing-on-upload branch from d9e0b66 to f4f25f9 Compare December 28, 2025 06:12
@tasumu tasumu marked this pull request as ready for review December 28, 2025 07:24
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. 🐖api The modified files are located under directory 'api/apps/sdk' 💞 feature Feature request, pull request that fullfill a new feature. labels Dec 28, 2025
@tasumu tasumu marked this pull request as draft December 28, 2025 10:22
Add optional replace_existing parameter to document upload endpoints.
When set to true, existing documents with the same name are deleted
before uploading, preventing duplicate filenames with (1), (2) suffixes.

- Add replace_existing parameter to FileService.upload_document()
- Delete storage file when replacing to prevent location collision
- Expose parameter in SDK API (POST /datasets/{id}/documents)
- Expose parameter in WebUI API (POST /upload)
- Add tests for replace_existing functionality
@tasumu tasumu force-pushed the feature/replace-existing-on-upload branch from 8a21de0 to f7c01df Compare December 28, 2025 10:25
@tasumu tasumu marked this pull request as ready for review December 28, 2025 11:04
@KevinHuSh KevinHuSh requested a review from asiroliu December 29, 2025 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐖api The modified files are located under directory 'api/apps/sdk' 💞 feature Feature request, pull request that fullfill a new feature. size:M This PR changes 30-99 lines, ignoring generated files.

1 participant