List indexed knowledge sources directly from chat
This commit is contained in:
@@ -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.")
|
||||
|
||||
Reference in New Issue
Block a user