Skip to content

Commit

Permalink
style: formats source code
Browse files Browse the repository at this point in the history
  • Loading branch information
micheleriva committed Jul 24, 2024
1 parent 5fcfa73 commit 0438312
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions Sources/oramacloud-client/answer-session.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,27 +150,27 @@ class AnswerSession<Doc: Codable> {
}

public func regenerateLast(stream: Bool = true) async throws -> MaybeStream {
if state.isEmpty || self.messages.isEmpty {
if state.isEmpty || messages.isEmpty {
throw OramaClientError.runtimeError("No messages to regenerate")
}

let isLastMessageAssistant = self.messages.last?.role == .assistant
let isLastMessageAssistant = messages.last?.role == .assistant

if !isLastMessageAssistant {
throw OramaClientError.runtimeError("Last message is not an assistant message")
}

if self.lastInteractionParams == nil {
if lastInteractionParams == nil {
throw OramaClientError.runtimeError("Cannot find last interaction params")
}

self.messages.removeLast()
self.state.removeLast()
messages.removeLast()
state.removeLast()

if stream {
return .stream(try await fetchAnswer(params: self.lastInteractionParams!))
return try .stream(await fetchAnswer(params: lastInteractionParams!))
} else {
return .string(try await ask(params: self.lastInteractionParams!))
return try .string(await ask(params: lastInteractionParams!))
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/oramacloud-client/types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ struct SearchRequestPayload: Encodable {

enum OramaClientError: Error {
case runtimeError(String)
}
}
2 changes: 1 addition & 1 deletion Tests/oramacloud-clientTests/oramacloud_clientTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,6 @@ extension oramacloud_clientTests {
("testOnMessageLoading", testOnMessageLoading),
("testAsyncE2EAnswerSession", testAsyncE2EAnswerSession),
("testE2ERegenerateLastAnswer", testE2ERegenerateLastAnswer),
("testE2EIndexManager", testE2EIndexManager)
("testE2EIndexManager", testE2EIndexManager),
]
}

0 comments on commit 0438312

Please sign in to comment.