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 @@ -210,9 +210,9 @@ struct AssistantConfigurationDemoView: View {
@State private var parameters = AssistantParameters(action: .create(model: Model.gpt41106Preview.value))
@State private var isAvatarLoading = false
@State private var showAvatarFlow = false
@State private var fileIDS: [String] = []
@State private var fileIDS = [String]()
/// Used mostly to display already uploaded files if any.
@State private var filePickerInitialActions: [FilePickerAction] = []
@State private var filePickerInitialActions = [FilePickerAction]()

private let service: OpenAIService
}
Expand All @@ -229,7 +229,7 @@ extension Binding where Value == String? {
AssistantConfigurationDemoView(service: OpenAIServiceFactory.service(apiKey: ""))
}

// MARK: InputView
// MARK: - InputView

struct InputView<Content: View>: View {
let content: Content
Expand All @@ -251,6 +251,8 @@ struct InputView<Content: View>: View {
@Environment(\.inputViewStyle) private var style: InputViewStyle
}

// MARK: - InputViewStyle

struct InputViewStyle {
let verticalPadding: CGFloat

Expand All @@ -259,6 +261,8 @@ struct InputViewStyle {
}
}

// MARK: - InputViewStyleKey

struct InputViewStyleKey: EnvironmentKey {
static let defaultValue = InputViewStyle()
}
Expand All @@ -276,6 +280,8 @@ extension View {
}
}

// MARK: - CheckboxView

struct CheckboxView: View {
@Binding var isChecked: Bool

Expand All @@ -291,6 +297,8 @@ struct CheckboxView: View {
}
}

// MARK: - CheckboxRow

struct CheckboxRow: View {
let title: String
@Binding var isChecked: Bool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AssistantConfigurationProvider {
}

var assistant: AssistantObject?
var assistants: [AssistantObject] = []
var assistants = [AssistantObject]()
var avatarURL: URL?
var assistantDeletionStatus: DeletionStatus?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ChatProvider {
self.service = service
}

var messages: [String] = []
var messages = [String]()
var errorMessage = ""
var message = ""
var usage: ChatUsage?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ChatFunctionCallProvider {
// MARK: - Public Properties

/// To be used for UI purposes.
var chatDisplayMessages: [ChatMessageDisplayModel] = []
var chatDisplayMessages = [ChatMessageDisplayModel]()

@MainActor
func generateImage(arguments: String) async throws -> String {
Expand Down Expand Up @@ -174,8 +174,8 @@ class ChatFunctionCallProvider {
private let service: OpenAIService
private var lastDisplayedMessageID: UUID?
/// To be used for a new request
private var chatMessageParameters: [ChatCompletionParameters.Message] = []
private var availableFunctions: [FunctionCallDefinition: @MainActor (String) async throws -> String] = [:]
private var chatMessageParameters = [ChatCompletionParameters.Message]()
private var availableFunctions = [FunctionCallDefinition: @MainActor (String) async throws -> String]()

// MARK: - Private Methods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ChatFunctionsCallStreamProvider {
// MARK: - Public Properties

/// To be used for UI purposes.
var chatDisplayMessages: [ChatMessageDisplayModel] = []
var chatDisplayMessages = [ChatMessageDisplayModel]()

@MainActor
func generateImage(arguments: String) async throws -> String {
Expand Down Expand Up @@ -163,7 +163,7 @@ class ChatFunctionsCallStreamProvider {
}

func createAssistantMessage() -> ChatCompletionParameters.Message {
var toolCalls: [ToolCall] = []
var toolCalls = [ToolCall]()
for (_, functionCallStreamedResponse) in functionCallsMap {
let toolCall = functionCallStreamedResponse.toolCall
// Intentionally force unwrapped to catch errrors quickly on demo. // This should be properly handled.
Expand All @@ -178,7 +178,7 @@ class ChatFunctionsCallStreamProvider {
func createToolsMessages() async throws
-> [ChatCompletionParameters.Message]
{
var toolMessages: [ChatCompletionParameters.Message] = []
var toolMessages = [ChatCompletionParameters.Message]()
for (key, functionCallStreamedResponse) in functionCallsMap {
let name = functionCallStreamedResponse.name
let id = functionCallStreamedResponse.id
Expand Down Expand Up @@ -222,9 +222,9 @@ class ChatFunctionsCallStreamProvider {
private let service: OpenAIService
private var lastDisplayedMessageID: UUID?
/// To be used for a new request
private var chatMessageParameters: [ChatCompletionParameters.Message] = []
private var functionCallsMap: [FunctionCallDefinition: FunctionCallStreamedResponse] = [:]
private var availableFunctions: [FunctionCallDefinition: @MainActor (String) async throws -> String] = [:]
private var chatMessageParameters = [ChatCompletionParameters.Message]()
private var functionCallsMap = [FunctionCallDefinition: FunctionCallStreamedResponse]()
private var availableFunctions = [FunctionCallDefinition: @MainActor (String) async throws -> String]()

// MARK: - Private Methods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ChatFluidConversationProvider {
// MARK: - Public Properties

/// A collection of messages for display in the UI, representing the conversation.
var chatMessages: [ChatDisplayMessage] = []
var chatMessages = [ChatDisplayMessage]()

// MARK: - Public Methods

Expand Down Expand Up @@ -94,9 +94,9 @@ class ChatFluidConversationProvider {
/// Tracks the identifier of the last message displayed, enabling updates in the from the streaming API response.
private var lastDisplayedMessageID: UUID?
/// Stores the initial chat message's delta, which uniquely includes metadata like `role`.
private var firstChatMessageResponseDelta: [String: ChatCompletionChunkObject.ChatChoice.Delta] = [:]
private var firstChatMessageResponseDelta = [String: ChatCompletionChunkObject.ChatChoice.Delta]()
/// Builds a history of messages sent and received, enhancing the chat's context for future requests.
private var parameterMessages: [ChatCompletionParameters.Message] = []
private var parameterMessages = [ChatCompletionParameters.Message]()

// MARK: - Private Methods

Expand Down
Loading