From 390bef4ace849de75a7181aeb7f74edabad05449 Mon Sep 17 00:00:00 2001 From: malicious <38064672+malicious@users.noreply.github.com> Date: Sat, 10 Feb 2024 17:39:01 +0000 Subject: [PATCH] Forward Alamofire failures This includes timeouts, which by default seem to be after 60 seconds. Since I'm working with larger models on an older system, I expect requests that can take up to 25 minutes to complete, so this makes the UI unworkable (timeout failure without any indication, just isFinished). --- Sources/OllamaKit/OllamaKit+Chat.swift | 8 ++++++-- Sources/OllamaKit/OllamaKit+Generate.swift | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Sources/OllamaKit/OllamaKit+Chat.swift b/Sources/OllamaKit/OllamaKit+Chat.swift index a728cda..e914c45 100644 --- a/Sources/OllamaKit/OllamaKit+Chat.swift +++ b/Sources/OllamaKit/OllamaKit+Chat.swift @@ -42,8 +42,12 @@ extension OllamaKit { case .failure(let error): subject.send(completion: .failure(error)) } - case .complete(_): - subject.send(completion: .finished) + case .complete(let completion): + if completion.error != nil { + subject.send(completion: .failure(completion.error!)) + } else { + subject.send(completion: .finished) + } } } diff --git a/Sources/OllamaKit/OllamaKit+Generate.swift b/Sources/OllamaKit/OllamaKit+Generate.swift index 778d84d..44bbe78 100644 --- a/Sources/OllamaKit/OllamaKit+Generate.swift +++ b/Sources/OllamaKit/OllamaKit+Generate.swift @@ -42,8 +42,12 @@ extension OllamaKit { case .failure(let error): subject.send(completion: .failure(error)) } - case .complete(_): - subject.send(completion: .finished) + case .complete(let completion): + if completion.error != nil { + subject.send(completion: .failure(completion.error!)) + } else { + subject.send(completion: .finished) + } } }