Skip to content

Commit d97f4f6

Browse files
committed
more fixes
Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
1 parent 46ba864 commit d97f4f6

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

context_chat_backend/controller.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,11 @@ def _(sources: list[UploadFile]):
322322
# wait for 10 minutes before failing the request
323323
semres = doc_parse_semaphore.acquire(block=True, timeout=10*60)
324324
if not semres:
325-
return JSONResponse('Document parser worker limit reached, try again in some time', 503)
325+
return JSONResponse(
326+
'Document parser worker limit reached, try again in some time',
327+
503,
328+
headers={'cc-retry': 'true'}
329+
)
326330
added_sources = exec_in_proc(target=embed_sources, args=(vectordb_loader, app.extra['CONFIG'], sources))
327331
doc_parse_semaphore.release()
328332

context_chat_backend/vectordb/pgvector.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,18 @@ def decl_update_access(self, user_ids: list[str], source_id: str, session_: orm.
198198
session.execute(stmt)
199199
session.commit()
200200

201-
access = [
202-
AccessListStore(
203-
uid=user_id,
204-
source_id=source_id,
205-
)
206-
for user_id in user_ids
207-
]
208-
session.add_all(access)
201+
stmt = (
202+
sa.dialects.postgresql.insert(AccessListStore)
203+
.values([
204+
{
205+
'uid': user_id,
206+
'source_id': source_id,
207+
}
208+
for user_id in user_ids
209+
])
210+
.on_conflict_do_nothing(index_elements=['uid', 'source_id'])
211+
)
212+
session.execute(stmt)
209213
session.commit()
210214

211215
if session_ is None:

0 commit comments

Comments
 (0)