List indexed knowledge sources directly from chat

This commit is contained in:
Mark Gregory
2026-11-17 10:24:17 +00:00
parent d0f04ecd3a
commit e4f9b5d42d
3 changed files with 132 additions and 1 deletions
+27
View File
@@ -867,6 +867,33 @@ final class ConnectedChatTests: XCTestCase {
XCTAssertEqual(try Store(url: url).conversations().map(\.id), [second])
}
@MainActor
func testLiveKnowledgeInventoryAnswersWithoutModel() async throws {
guard let path = ProcessInfo.processInfo.environment["AISTUDIO_TEST_REAL_MCP_CONFIG"] else {
throw XCTSkip("Set a local knowledge MCP configuration to verify its inventory.")
}
let config = try MCPServerConfiguration.File.read(URL(fileURLWithPath: path))
let profile = try XCTUnwrap(config.mcpServers["local-knowledge"])
let folder = FileManager.default.temporaryDirectory.appending(path: UUID().uuidString)
defer { try? FileManager.default.removeItem(at: folder) }
let studio = StudioModel()
studio.open(databaseURL: folder.appending(path: "studio.sqlite"))
studio.connectMCP(.profile("local-knowledge"), name: "local-knowledge") { try profile.makeClient() }
studio.prompt = "List all topics in our knowledge base"
studio.send(endpoint: "", model: "", mlxPath: "", thinking: .off, failover: false,
mlxOnly: false, compatible: false, recall: false, useDocuments: false,
instructions: "", settings: GenerationSettings())
let deadline = ContinuousClock.now + .seconds(30)
while studio.running && ContinuousClock.now < deadline { try await Task.sleep(for: .milliseconds(50)) }
XCTAssertFalse(studio.running)
let reply = try XCTUnwrap(studio.messages.last)
XCTAssertEqual(reply.role, .assistant, studio.knowledgeStatus)
XCTAssertEqual(reply.backend, "Knowledge Inventory · local-knowledge")
let listed = reply.content.split(separator: "\n").filter { $0.hasPrefix("• ") }
XCTAssertGreaterThan(listed.count, 200)
XCTAssertEqual(Set(listed).count, listed.count)
}
func testLiveLocalKnowledgeSearch() async throws {
guard let path = ProcessInfo.processInfo.environment["AISTUDIO_TEST_REAL_MCP_CONFIG"] else {
throw XCTSkip("Set the installed MCP configuration to verify knowledge search.")