Skip to content

Commit

Permalink
Closes #79
Browse files Browse the repository at this point in the history
  • Loading branch information
gotsysdba committed Jan 17, 2025
1 parent d45ab30 commit 83f049c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/server/embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def split_document(
##################################
# Splitters - End
##################################
match extension:
match extension.lower():
case "pdf":
doc_split = text_splitter.split_documents(document)
case "html":
Expand Down Expand Up @@ -151,7 +151,7 @@ def load_and_split_documents(
stat = os.stat(file)
extension = os.path.splitext(file)[1][1:]
logger.info("Loading %s (%i bytes)", name, stat.st_size)
match extension:
match extension.lower():
case "pdf":
loader = document_loaders.PyPDFLoader(file)
case "html":
Expand All @@ -161,7 +161,7 @@ def load_and_split_documents(
case "csv":
loader = document_loaders.CSVLoader(file)
case _:
logger.error("Un-supported file extension: %s", extension)
raise ValueError(f"{extension} is not a supported file extension")

loaded_doc = loader.load()
logger.info("Loaded Pages: %i", len(loaded_doc))
Expand Down
2 changes: 2 additions & 0 deletions app/server/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,8 @@ async def split_embed(
)
return_files = list({doc.metadata["filename"] for doc in split_docos if "filename" in doc.metadata})
return schema.Response[list](data=return_files, msg=f"{len(split_docos)} chunks embedded.")
except ValueError as ex:
raise HTTPException(status_code=500, detail=str(ex)) from ex
except Exception as ex:
logger.error("An exception occurred: %s", ex)
raise HTTPException(status_code=500, detail="Unexpected error") from ex
Expand Down

0 comments on commit 83f049c

Please sign in to comment.