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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SwiftUI
struct AttachmentView: View {
let fileName: String
@Binding var actionTrigger: Bool

let isLoading: Bool

var body: some View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ struct ResponseStreamDemoView: View {

struct MessageBubbleView: View {
let message: ResponseStreamProvider.ResponseMessage

@Environment(\.colorScheme) var colorScheme

var body: some View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import SwiftUI

struct LoadingView: View {
@State private var dotsCount = 0

let timer = Timer.publish(every: 0.5, on: .main, in: .common).autoconnect()

var body: some View {
Expand All @@ -28,4 +26,7 @@ struct LoadingView: View {
func getDots() -> String {
String(repeating: ".", count: dotsCount)
}

@State private var dotsCount = 0

}
10 changes: 5 additions & 5 deletions Sources/OpenAI/Private/Audio/MicrophonePCMSampleVendorAT.swift
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,11 @@ class MicrophonePCMSampleVendorAT: MicrophonePCMSampleVendor {
/// This @RealtimeActor annotation is a lie.
@RealtimeActor private let audioRenderCallback: AURenderCallback = {
inRefCon,
ioActionFlags,
inTimeStamp,
inBusNumber,
inNumberFrames,
_ in
ioActionFlags,
inTimeStamp,
inBusNumber,
inNumberFrames,
_ in
let microphonePCMSampleVendor = Unmanaged<MicrophonePCMSampleVendorAT>
.fromOpaque(inRefCon)
.takeUnretainedValue()
Expand Down
9 changes: 9 additions & 0 deletions Sources/OpenAI/Private/Realtime/OpenAIRealtimeSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,15 @@ open class OpenAIRealtimeSession {

continuation?.yield(.mcpListToolsFailed(fullError))

case "response.mcp_call.completed":
let eventId = json["event_id"] as? String
let itemId = json["item_id"] as? String
let outputIndex = json["output_index"] as? Int
continuation?.yield(.responseMcpCallCompleted(eventId: eventId, itemId: itemId, outputIndex: outputIndex))

case "response.mcp_call.in_progress":
continuation?.yield(.responseMcpCallInProgress)

case "response.done":
// Handle response completion (may contain errors like insufficient_quota)
if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public enum OpenAIRealtimeMessage: Sendable {
case mcpListToolsInProgress // "mcp_list_tools.in_progress"
case mcpListToolsCompleted([String: Any]) // "mcp_list_tools.completed" with tools data
case mcpListToolsFailed(String?) // "mcp_list_tools.failed" with error details

/// Response completion with potential errors
case responseDone(status: String, statusDetails: [String: Any]?) // "response.done"

Expand All @@ -42,6 +41,10 @@ public enum OpenAIRealtimeMessage: Sendable {
case responseContentPartAdded(type: String) // "response.content_part.added"
case responseContentPartDone(type: String, text: String?) // "response.content_part.done"

// MCP response
case responseMcpCallCompleted(eventId: String?, itemId: String?, outputIndex: Int?)
case responseMcpCallInProgress

/// Conversation item
case conversationItemCreated(itemId: String, type: String, role: String?) // "conversation.item.created"
}
3 changes: 3 additions & 0 deletions Sources/OpenAI/Public/Service/OpenAIService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1419,9 +1419,11 @@ extension OpenAIService {
case .threadMessageDelta:
let decoded = try self.decoder.decode(MessageDeltaObject.self, from: data)
continuation.yield(.threadMessageDelta(decoded))

case .threadRunStepDelta:
let decoded = try self.decoder.decode(RunStepDeltaObject.self, from: data)
continuation.yield(.threadRunStepDelta(decoded))

case .threadRun:
// We expect a object of type "thread.run.SOME_STATE" in the data object
// However what we get is a `thread.run` object but we can check the status
Expand Down Expand Up @@ -1454,6 +1456,7 @@ extension OpenAIService {
}
#endif
}

default:
#if DEBUG
if debugEnabled {
Expand Down
Loading