Collection : with assistant flag and additional enhancements#412
Merged
Collection : with assistant flag and additional enhancements#412
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Target issue is #398 and also covering this issue - #231 since this is just for writing test cases for existing router endpoints
Checklist
Before submitting a pull request, please ensure that you mark these task.
fastapi run --reload app/main.pyordocker compose upin the repository root and test.Notes
for reference of request bodies of the job related endpoints of this module you can check this document out.
Create job (create_collection.execute_job) :
Introduced with_assistant flag: when model & instructions are both present, create an Assistant backed by a Vector Store; otherwise only create a Vector Store.
We now close the DB session before making external API calls—and reopen a fresh session only to persist results—so we don’t hold connections or risk transaction locks. Same is being done during deletion of collection.
Delete job (delete_collection.execute_job) :
Detects service type from collection.llm_service_name (Assistant vs Vector Store) and chooses the correct CRUD (OpenAIAssistantCrud / OpenAIVectorStoreCrud) to use delete method of that specific CRUD class.
Calls local deletion via CollectionCrud.delete_by_id() once remote deletion succeeds.
CRUD refactors :
CollectionCrud.delete_by_id() sets deleted_at=now() and persists.
Document→Collection cascade delete now excludes already-deleted collections (deleted_at IS NULL).
API route :
/collections/create: determines with_assistant by checking both model and instructions. Returns metadata note when creating vector-store-only.
Validation: if only one of model or instructions is provided, responds 422 with a clear message.
Additional :
Removed ResponsePayload class because we are now returning collection job object in response of create and delete collections, we use the collection job object for the callback URL as well.
Rephrased the endpoint docs to remove the indication that user can use any specific endpoint for polling.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests