Select web passages by topic and verify live Ollama chat

This commit is contained in:
Mark Gregory
2026-11-16 17:01:26 +00:00
parent 74c726e2d5
commit a2ccafa613
2 changed files with 65 additions and 7 deletions
+30
View File
@@ -616,6 +616,13 @@ final class BuiltInToolsetTests: XCTestCase {
}
final class ToolboxRepairTests: XCTestCase {
func testWebExcerptIncludesRelevantSectionAfterNavigation() {
let navigation = String(repeating: "Home · Releases · Upgrade\n", count: 100)
let passage = "Service Container\nThe container resolves dependencies."
let excerpt = ChatWebLookup.excerpt(navigation + passage, matching: ["service", "container"], limit: 100)
XCTAssertTrue(excerpt.contains(passage))
}
func testChatWebLookupResolvesTypedURLAndExplicitSearch() async throws {
guard let endpoint = ProcessInfo.processInfo.environment["AISTUDIO_TEST_WEB_URL"],
let base = URL(string: endpoint)?.deletingLastPathComponent() else {
@@ -819,6 +826,29 @@ final class ConnectedChatTests: XCTestCase {
XCTAssertEqual(studio.messages.last?.content, "Page received.")
}
@MainActor
func testLiveOllamaChatUsesRetrievedPage() async throws {
guard let model = ProcessInfo.processInfo.environment["AISTUDIO_TEST_REAL_OLLAMA_MODEL"] else {
throw XCTSkip("Choose a local Ollama model to verify live chat.")
}
let directory = FileManager.default.temporaryDirectory.appending(path: UUID().uuidString)
defer { try? FileManager.default.removeItem(at: directory) }
let studio = StudioModel()
studio.open(databaseURL: directory.appending(path: "studio.sqlite"))
studio.prompt = "Read https://laravel.com and reply with the name of the framework and the source URL."
var settings = GenerationSettings()
settings.maxTokens = "128"
studio.send(endpoint: "http://127.0.0.1:11434", model: model, mlxPath: "",
thinking: .off, failover: false, mlxOnly: false, compatible: false,
recall: false, useDocuments: false, instructions: "", settings: settings)
let deadline = ContinuousClock.now + .seconds(60)
while studio.running && ContinuousClock.now < deadline { try await Task.sleep(for: .milliseconds(100)) }
XCTAssertFalse(studio.running)
XCTAssertTrue(studio.webDiagnostics.contains { $0.contains("Fetched laravel.com") })
XCTAssertEqual(studio.messages.last?.role, .assistant)
XCTAssertTrue(studio.messages.last?.content.contains("https://laravel.com") == true, studio.status)
}
func testLiveConnectedGiteaRepositoryLookup() async throws {
let env = ProcessInfo.processInfo.environment
guard let path = env["AISTUDIO_TEST_REAL_MCP_CONFIG"], env["AISTUDIO_TEST_REAL_GITEA"] == "1" else {