|
19 | 19 | VectorParams, |
20 | 20 | ) |
21 | 21 | from sqlalchemy import Integer, cast, delete, distinct, func, insert, or_, select, update |
22 | | -from sqlalchemy.exc import IntegrityError, NoResultFound |
| 22 | +from sqlalchemy.exc import NoResultFound |
23 | 23 | from sqlalchemy.ext.asyncio import AsyncSession |
24 | 24 |
|
25 | 25 | from app.clients.model import BaseModelClient as ModelClient |
|
36 | 36 | from app.sql.models import User as UserTable |
37 | 37 | from app.utils.exceptions import ( |
38 | 38 | ChunkingFailedException, |
39 | | - CollectionAlreadyExistsException, |
40 | 39 | CollectionNotFoundException, |
41 | 40 | DocumentNotFoundException, |
42 | 41 | NotImplementedException, |
@@ -75,16 +74,13 @@ def __init__( |
75 | 74 | async def create_collection( |
76 | 75 | self, session: AsyncSession, user_id: int, name: str, visibility: CollectionVisibility, description: Optional[str] = None |
77 | 76 | ) -> int: |
78 | | - try: |
79 | | - result = await session.execute( |
80 | | - statement=insert(table=CollectionTable) |
81 | | - .values(name=name, user_id=user_id, visibility=visibility, description=description) |
82 | | - .returning(CollectionTable.id) |
83 | | - ) |
84 | | - collection_id = result.scalar_one() |
85 | | - await session.commit() |
86 | | - except IntegrityError as e: |
87 | | - raise CollectionAlreadyExistsException() |
| 77 | + result = await session.execute( |
| 78 | + statement=insert(table=CollectionTable) |
| 79 | + .values(name=name, user_id=user_id, visibility=visibility, description=description) |
| 80 | + .returning(CollectionTable.id) |
| 81 | + ) |
| 82 | + collection_id = result.scalar_one() |
| 83 | + await session.commit() |
88 | 84 |
|
89 | 85 | await self.qdrant.create_collection( |
90 | 86 | collection_name=str(collection_id), |
|
0 commit comments