Add dedicated quick question API
TestFlight / Build and upload (push) Successful in 1m42s

This commit is contained in:
2026-08-27 19:31:23 -07:00
parent 5f9fc82b86
commit 922172fc60
13 changed files with 269 additions and 44 deletions
@@ -183,6 +183,29 @@ actor SybilAPIClient: SybilAPIClienting {
SybilLog.info(SybilLog.network, "Chat stream completed")
}
func runQuickQuestionStream(
body: QuickQuestionStreamRequest,
onEvent: @escaping @Sendable (CompletionStreamEvent) async -> Void
) async throws {
let request = try makeRequest(
path: "/v1/quick-questions/stream",
method: "POST",
body: AnyEncodable(body),
acceptsSSE: true
)
SybilLog.info(
SybilLog.network,
"Starting quick question stream POST \(request.url?.absoluteString ?? "<unknown>")"
)
try await stream(request: request) { eventName, dataText in
try await Self.handleCompletionStreamEvent(eventName: eventName, dataText: dataText, onEvent: onEvent)
}
SybilLog.info(SybilLog.network, "Quick question stream completed")
}
func attachCompletionStream(
chatID: String,
onEvent: @escaping @Sendable (CompletionStreamEvent) async -> Void
@@ -664,6 +687,12 @@ struct CompletionStreamRequest: Codable, Sendable {
var userLocation: String? = nil
}
struct QuickQuestionStreamRequest: Codable, Sendable {
var provider: Provider
var model: String
var question: String
}
private struct ChatCreateBody: Encodable {
var title: String?
var provider: Provider?
@@ -27,6 +27,10 @@ protocol SybilAPIClienting: Sendable {
body: CompletionStreamRequest,
onEvent: @escaping @Sendable (CompletionStreamEvent) async -> Void
) async throws
func runQuickQuestionStream(
body: QuickQuestionStreamRequest,
onEvent: @escaping @Sendable (CompletionStreamEvent) async -> Void
) async throws
func attachCompletionStream(
chatID: String,
onEvent: @escaping @Sendable (CompletionStreamEvent) async -> Void
@@ -1162,13 +1162,11 @@ final class SybilViewModel {
let streamStatus = CompletionStreamStatus()
do {
try await client().runCompletionStream(
body: CompletionStreamRequest(
chatId: nil,
persist: false,
try await client().runQuickQuestionStream(
body: QuickQuestionStreamRequest(
provider: provider,
model: model,
messages: [CompletionRequestMessage(role: .user, content: prompt)]
question: prompt
)
) { [weak self] event in
guard let self else { return }