Run model downloads and split conversations independently
This commit is contained in:
@@ -74,6 +74,7 @@ struct ChatView: View {
|
||||
@State private var showingPerformance = false
|
||||
@State private var showingComparison = false
|
||||
@State private var comparisonChat: UUID?
|
||||
@StateObject private var splitStudio = StudioModel()
|
||||
@State private var showingWorkspace = false
|
||||
@State private var showingToolbox = false
|
||||
@AppStorage("chatDebugOutput") private var showDebugOutput = false
|
||||
@@ -126,24 +127,24 @@ struct ChatView: View {
|
||||
}
|
||||
}
|
||||
.searchable(text: $search, placement: .sidebar, prompt: "Search Chats")
|
||||
.disabled(studio.running)
|
||||
.disabled(studio.running || splitStudio.running)
|
||||
.navigationSplitViewColumnWidth(min: 180, ideal: 235)
|
||||
.toolbar {
|
||||
Button("New Chat", systemImage: "square.and.pencil") {
|
||||
search = ""
|
||||
studio.newChat()
|
||||
}
|
||||
.disabled(studio.running)
|
||||
.disabled(studio.running || splitStudio.running)
|
||||
Button("Rename Chat", systemImage: "pencil") {
|
||||
newTitle = studio.conversations.first(where: { $0.id == studio.selected })?.title ?? ""
|
||||
renaming = true
|
||||
}
|
||||
.disabled(studio.running || studio.selected == nil)
|
||||
.disabled(studio.running || splitStudio.running || studio.selected == nil)
|
||||
Button("Delete Chat", systemImage: "trash") {
|
||||
chatToDelete = studio.conversations.first { $0.id == studio.selected }
|
||||
confirmDelete = chatToDelete != nil
|
||||
}
|
||||
.disabled(studio.running || studio.selected == nil)
|
||||
.disabled(studio.running || splitStudio.running || studio.selected == nil)
|
||||
}
|
||||
} detail: {
|
||||
VStack(spacing: 0) {
|
||||
@@ -167,9 +168,13 @@ struct ChatView: View {
|
||||
Button("Workspace", systemImage: "square.stack.3d.up") { showingWorkspace = true }
|
||||
Button("Compare Chats", systemImage: "rectangle.split.2x1") {
|
||||
showingComparison.toggle()
|
||||
if showingComparison { comparisonChat = studio.conversations.first { $0.id != studio.selected }?.id }
|
||||
if showingComparison {
|
||||
splitStudio.open()
|
||||
comparisonChat = studio.conversations.first { $0.id != studio.selected }?.id
|
||||
splitStudio.selected = comparisonChat
|
||||
}
|
||||
}
|
||||
.disabled(studio.conversations.count < 2 && !showingComparison)
|
||||
.disabled(splitStudio.running || (studio.conversations.count < 2 && !showingComparison))
|
||||
Button("Performance", systemImage: "chart.xyaxis.line") { showingPerformance = true }
|
||||
}
|
||||
}
|
||||
@@ -270,15 +275,40 @@ struct ChatView: View {
|
||||
}
|
||||
}
|
||||
.padding(10)
|
||||
.disabled(splitStudio.running)
|
||||
.onChange(of: comparisonChat) { _, value in
|
||||
splitStudio.selected = value
|
||||
splitStudio.prompt = ""
|
||||
}
|
||||
Divider()
|
||||
if let comparisonChat, comparisonChat != studio.selected,
|
||||
studio.conversations.contains(where: { $0.id == comparisonChat }) {
|
||||
ScrollView {
|
||||
LazyVStack(alignment: .leading, spacing: 12) {
|
||||
ForEach(studio.conversationMessages(comparisonChat)) { MessageView(message: $0) }
|
||||
ForEach(splitStudio.messages) { MessageView(message: $0) }
|
||||
if let partial = splitStudio.partial { MessageView(message: partial, streaming: true) }
|
||||
}.padding(12)
|
||||
}
|
||||
.font(chatFont.font(size: chatSize))
|
||||
Divider()
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
let feedback = [splitStudio.knowledgeStatus, splitStudio.webStatus, splitStudio.status]
|
||||
.filter { !$0.isEmpty }.joined(separator: " · ")
|
||||
if !feedback.isEmpty { Text(feedback).font(.caption).foregroundStyle(.secondary) }
|
||||
ChatComposerInput(text: $splitStudio.prompt, canSend: !splitStudio.running, spellCheck: spellCheck,
|
||||
autoCorrect: autoCorrect, font: chatFont.appKit(size: chatSize), send: sendSplitMessage)
|
||||
.frame(height: 54)
|
||||
HStack {
|
||||
Spacer()
|
||||
if splitStudio.running {
|
||||
Button("Stop", systemImage: "stop.fill") { splitStudio.stop() }
|
||||
} else {
|
||||
Button("Send", systemImage: "arrow.up", action: sendSplitMessage)
|
||||
.disabled(splitStudio.prompt.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(10)
|
||||
} else {
|
||||
ContentUnavailableView("Choose a conversation", systemImage: "rectangle.split.2x1")
|
||||
}
|
||||
@@ -442,6 +472,15 @@ struct ChatView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private func sendSplitMessage() {
|
||||
guard splitStudio.selected != nil, splitStudio.selected != studio.selected else { return }
|
||||
splitStudio.copyInferenceCredentials(from: studio)
|
||||
splitStudio.send(endpoint: activeEndpoint, model: activeModel, mlxPath: mlxPath, thinking: thinking,
|
||||
failover: failover, mlxOnly: mlxOnly, compatible: compatibleEnabled, recall: recall, useDocuments: false,
|
||||
instructions: promptMode.instructions(custom: customPrompt),
|
||||
settings: GenerationSettings.read(generationSettings))
|
||||
}
|
||||
|
||||
private func sendMessage() {
|
||||
let draft = studio.prompt
|
||||
if draft.lowercased().hasPrefix("/write ") {
|
||||
|
||||
Reference in New Issue
Block a user