Use connected knowledge and Gitea from chat

This commit is contained in:
Mark Gregory
2026-11-16 16:03:22 +00:00
parent f7b1083f39
commit 00ea78671b
7 changed files with 187 additions and 66 deletions
+32 -54
View File
@@ -196,26 +196,6 @@ struct ChatView: View {
private var composer: some View {
VStack(alignment: .leading, spacing: 8) {
HStack {
Label(mlxOnly ? "MLX on this Mac" : "\(backendName) · \(activeModel.isEmpty ? "Choose a model" : activeModel)",
systemImage: mlxOnly ? "cpu" : "server.rack")
.font(.caption)
if !mlxOnly {
Text(activeEndpoint).font(.caption).foregroundStyle(.secondary).lineLimit(1)
}
Spacer()
if (!mlxOnly && !compatibleEnabled) || (mlxOnly && MLXThinking.supports(mlxPath)) {
let modes: [Thinking] = mlxOnly ? [.automatic, .off, .on] : Thinking.allCases
Picker("Thinking", selection: Binding(
get: { modes.contains(thinking) ? thinking : .automatic },
set: { thinking = $0 }
)) {
ForEach(modes) { Text($0.rawValue.capitalized).tag($0) }
}
.fixedSize()
.disabled(studio.running)
}
}
if !studio.documents.isEmpty {
Toggle(mlxOnly ? "Include matching document excerpts" :
"Send matching document excerpts to \(backendName)", isOn: $useDocuments)
@@ -231,38 +211,10 @@ struct ChatView: View {
}
.font(.caption)
}
HStack(spacing: 10) {
Button {
showingToolbox = true
} label: {
let count = studio.activeToolsets.count
Label(count == 0 ? "Toolbox" : count == 1 ? "1 Active Toolset" : "\(count) Active Toolsets",
systemImage: "wrench.and.screwdriver")
}
.buttonStyle(.bordered)
if !studio.activeToolsets.isEmpty {
let servers = studio.activeToolsets.map { $0.toolset.name }.joined(separator: ", ")
Text(servers).lineLimit(2).foregroundStyle(.secondary).help(servers)
}
if studio.activeStack != nil || studio.activeSkill != nil ||
studio.activeContext != nil || studio.activeWebClip != nil {
Button("Active Resources", systemImage: "square.stack") { showingWorkspace = true }
.buttonStyle(.borderless)
}
Spacer()
}
.font(.caption)
if studio.connectedKnowledge != nil {
Toggle("Search connected knowledge index for this chat", isOn: $studio.useExternalKnowledge)
.font(.caption).disabled(studio.running)
}
if !studio.knowledgeStatus.isEmpty {
Label(studio.knowledgeStatus, systemImage: "books.vertical")
.font(.caption).foregroundStyle(.secondary).textSelection(.enabled)
}
if !studio.webStatus.isEmpty {
Label(studio.webStatus, systemImage: "globe")
.font(.caption).foregroundStyle(.secondary).textSelection(.enabled)
let activity = [studio.knowledgeStatus, studio.webStatus, studio.status].filter { !$0.isEmpty }
if !activity.isEmpty {
Text(activity.joined(separator: " · "))
.font(.caption).foregroundStyle(.secondary).lineLimit(2).textSelection(.enabled)
}
ChatComposerInput(text: $studio.prompt, canSend: !studio.running, spellCheck: spellCheck,
autoCorrect: autoCorrect, font: chatFont.appKit(size: chatSize), send: sendMessage)
@@ -271,8 +223,34 @@ struct ChatView: View {
.background(.background, in: RoundedRectangle(cornerRadius: 8))
.overlay(RoundedRectangle(cornerRadius: 8).strokeBorder(.quaternary))
HStack {
Text(studio.status).font(.caption).foregroundStyle(.secondary).textSelection(.enabled)
Button {
showingToolbox = true
} label: {
let count = studio.activeToolsets.count
Label(count == 0 ? "Tools" : "Tools \(count)", systemImage: "wrench.and.screwdriver")
}
.buttonStyle(.bordered)
.help(studio.activeToolsets.map { $0.toolset.name }.joined(separator: ", "))
if studio.activeStack != nil || studio.activeSkill != nil ||
studio.activeContext != nil || studio.activeWebClip != nil {
Button("Resources", systemImage: "square.stack") { showingWorkspace = true }
.buttonStyle(.borderless)
}
Label(mlxOnly ? "MLX" : activeModel.isEmpty ? "Choose a model" : activeModel,
systemImage: mlxOnly ? "cpu" : "server.rack")
.font(.caption).foregroundStyle(.secondary).lineLimit(1)
.help(mlxOnly ? "On-device MLX" : "\(backendName) · \(activeEndpoint)")
Spacer()
if (!mlxOnly && !compatibleEnabled) || (mlxOnly && MLXThinking.supports(mlxPath)) {
let modes: [Thinking] = mlxOnly ? [.automatic, .off, .on] : Thinking.allCases
Picker("Thinking", selection: Binding(
get: { modes.contains(thinking) ? thinking : .automatic },
set: { thinking = $0 }
)) {
ForEach(modes) { Text($0.rawValue.capitalized).tag($0) }
}
.fixedSize().disabled(studio.running)
}
if studio.running {
Button("Stop", systemImage: "stop.fill") { studio.stop() }
} else {
@@ -324,7 +302,7 @@ struct MessageView: View {
}
}
if !message.content.isEmpty {
if message.role == .assistant && !streaming {
if message.role == .assistant {
ChatMarkdown(text: message.content)
} else {
Text(message.content).textSelection(.enabled)