Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions iOSClient/Assistant/Chat/NCAssistantChatModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ class NCAssistantChatModel {
showRetryResponseGenerationButton = false
currentSession = nil

await loadAllMessages()
currentSession = await checkChatSession(sessionId: selectedConversation.id)
chatMessageTaskId = currentSession?.messageTaskId
await loadAllMessages()
currentSession = await checkChatSession(sessionId: selectedConversation.id)
chatMessageTaskId = currentSession?.messageTaskId

if messages.last?.isFromHuman == true, chatMessageTaskId == nil, isSending == false {
showRetryResponseGenerationButton = true
} else if chatMessageTaskId != nil {
startPollingForResponse()
}
if messages.last?.isFromHuman == true, chatMessageTaskId == nil, isSending == false {
showRetryResponseGenerationButton = true
} else if chatMessageTaskId != nil {
startPollingForResponse()
}
}

func generateChatSession() async {
Expand Down Expand Up @@ -110,7 +110,8 @@ class NCAssistantChatModel {

let result = await NextcloudKit.shared.checkAssistantChatGeneration(taskId: chatMessageTaskId, sessionId: selectedConversation?.id ?? 0, account: ncSession.account)

if result.error != .success {
// API sends expectation failed error (417) when a message is not ready yet. We should continue polling.
if result.error != .success, result.error.errorCode != NCGlobal.shared.errorExpectationFailed {
stopPolling()
await showErrorBanner(windowScene: windowScene, title: "_error_", text: "_assistant_error_generate_response_", errorCode: result.error.errorCode)
return
Expand Down
1 change: 1 addition & 0 deletions iOSClient/NCGlobal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ final class NCGlobal: Sendable {
let errorConflict: Int = 409
let errorPreconditionFailed: Int = 412
let errorUnsupportedMediaType: Int = 415
let errorExpectationFailed: Int = 417
let errorInternalServerError: Int = 500
let errorMaintenance: Int = 503
let errorQuota: Int = 507
Expand Down
Loading