From 7813c3316f3f2412fed504a8c7b712ac38032d6c Mon Sep 17 00:00:00 2001 From: Doug Danat Date: Thu, 4 Apr 2024 23:57:32 +0200 Subject: [PATCH 1/2] remove deprecated /api from ollama base url --- kubernetes/helm/templates/_helpers.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kubernetes/helm/templates/_helpers.tpl b/kubernetes/helm/templates/_helpers.tpl index 0647a42ae..3f42735a6 100644 --- a/kubernetes/helm/templates/_helpers.tpl +++ b/kubernetes/helm/templates/_helpers.tpl @@ -7,7 +7,7 @@ ollama {{- end -}} {{- define "ollama.url" -}} -{{- printf "http://%s.%s.svc.cluster.local:%d/api" (include "ollama.name" .) (.Release.Namespace) (.Values.ollama.service.port | int) }} +{{- printf "http://%s.%s.svc.cluster.local:%d/" (include "ollama.name" .) (.Release.Namespace) (.Values.ollama.service.port | int) }} {{- end }} {{- define "chart.name" -}} From e61e1b079f0593336a713881e1d51e1f09da3a51 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Thu, 4 Apr 2024 17:38:59 -0700 Subject: [PATCH 2/2] fix: file upload issue --- backend/apps/rag/main.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/backend/apps/rag/main.py b/backend/apps/rag/main.py index e7433f649..671429bb5 100644 --- a/backend/apps/rag/main.py +++ b/backend/apps/rag/main.py @@ -448,25 +448,11 @@ def store_doc( log.info(f"file.content_type: {file.content_type}") try: - is_valid_filename = True unsanitized_filename = file.filename - if re.search(r'[\\/:"\*\?<>|\n\t ]', unsanitized_filename) is not None: - is_valid_filename = False + filename = os.path.basename(unsanitized_filename) - unvalidated_file_path = f"{UPLOAD_DIR}/{unsanitized_filename}" - dereferenced_file_path = str(Path(unvalidated_file_path).resolve(strict=False)) - if not dereferenced_file_path.startswith(UPLOAD_DIR): - is_valid_filename = False + file_path = f"{UPLOAD_DIR}/{filename}" - if is_valid_filename: - file_path = dereferenced_file_path - else: - raise HTTPException( - status_code=status.HTTP_400_BAD_REQUEST, - detail=ERROR_MESSAGES.DEFAULT(), - ) - - filename = file.filename contents = file.file.read() with open(file_path, "wb") as f: f.write(contents) @@ -477,7 +463,7 @@ def store_doc( collection_name = calculate_sha256(f)[:63] f.close() - loader, known_type = get_loader(file.filename, file.content_type, file_path) + loader, known_type = get_loader(filename, file.content_type, file_path) data = loader.load() try: