This commit is contained in:
Timothy Jaeryang Baek
2024-12-12 22:32:28 -08:00
parent 1197c640c4
commit 9a081c8593
3 changed files with 19 additions and 7 deletions

View File

@@ -242,6 +242,7 @@ class KnowledgeFileIdForm(BaseModel):
@router.post("/{id}/file/add", response_model=Optional[KnowledgeFilesResponse])
def add_file_to_knowledge_by_id(
request: Request,
id: str,
form_data: KnowledgeFileIdForm,
user=Depends(get_verified_user),
@@ -274,7 +275,9 @@ def add_file_to_knowledge_by_id(
# Add content to the vector database
try:
process_file(ProcessFileForm(file_id=form_data.file_id, collection_name=id))
process_file(
request, ProcessFileForm(file_id=form_data.file_id, collection_name=id)
)
except Exception as e:
log.debug(e)
raise HTTPException(
@@ -318,6 +321,7 @@ def add_file_to_knowledge_by_id(
@router.post("/{id}/file/update", response_model=Optional[KnowledgeFilesResponse])
def update_file_from_knowledge_by_id(
request: Request,
id: str,
form_data: KnowledgeFileIdForm,
user=Depends(get_verified_user),
@@ -349,7 +353,9 @@ def update_file_from_knowledge_by_id(
# Add content to the vector database
try:
process_file(ProcessFileForm(file_id=form_data.file_id, collection_name=id))
process_file(
request, ProcessFileForm(file_id=form_data.file_id, collection_name=id)
)
except Exception as e:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,