Retrieve live web search results and show chat diagnostics
This commit is contained in:
@@ -121,6 +121,12 @@ class Handler(BaseHTTPRequestHandler):
|
||||
{'url': 'file:///etc/hosts', 'title': 'Invalid'},
|
||||
{'url': page, 'title': 'Duplicate'}]})
|
||||
return
|
||||
if self.path == '/follow-root':
|
||||
self.reply(200, b'<h1>Index</h1><a href="/follow-detail">Tides documentation</a>', 'text/html')
|
||||
return
|
||||
if self.path == '/follow-detail':
|
||||
self.reply(200, b'<p>The tides documentation was followed.</p>', 'text/html')
|
||||
return
|
||||
if self.path == '/article':
|
||||
self.reply(200, b'<h1>Moon and tides</h1><script>ignored()</script><p>Test passage.</p>', 'text/html')
|
||||
return
|
||||
|
||||
@@ -587,15 +587,15 @@ final class WebToolsTests: XCTestCase {
|
||||
}
|
||||
|
||||
final class BuiltInToolsetTests: XCTestCase {
|
||||
func testDiscoveryAndSetupErrorWithoutExternalServer() async throws {
|
||||
func testDiscoveryAndEmptyQueryValidationWithoutExternalServer() async throws {
|
||||
let client = BuiltInWebTools(searchEndpoint: "")
|
||||
let tools = try await client.listTools()
|
||||
XCTAssertEqual(tools.map(\.name), ["retrieve_page", "web_search"])
|
||||
do {
|
||||
_ = try await client.callTool("web_search", argumentsJSON: Data(#"{"query":"tides"}"#.utf8))
|
||||
XCTFail("Expected a configuration error")
|
||||
_ = try await client.callTool("web_search", argumentsJSON: Data(#"{}"#.utf8))
|
||||
XCTFail("Expected a missing query error")
|
||||
} catch let error as StudioError {
|
||||
XCTAssertTrue(error.message.contains("SearXNG"))
|
||||
XCTAssertTrue(error.message.contains("query"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -629,10 +629,11 @@ final class ToolboxRepairTests: XCTestCase {
|
||||
XCTAssertTrue(result.reference.contains(page.absoluteString))
|
||||
let search = try XCTUnwrap(ChatWebLookup(message: "Search the web for tides & moon"))
|
||||
let found = try await search.resolve(searchEndpoint: endpoint)
|
||||
XCTAssertTrue(found.reference.contains("A fixture & summary"))
|
||||
let unavailable = try await search.resolve(searchEndpoint: "")
|
||||
XCTAssertTrue(unavailable.status.contains("SearXNG"))
|
||||
XCTAssertEqual(unavailable.browserFallback?.host, "duckduckgo.com")
|
||||
XCTAssertTrue(found.reference.contains("Test passage."))
|
||||
let follow = try XCTUnwrap(ChatWebLookup(message: "Find tides documentation at \(base.appending(path: "follow-root"))"))
|
||||
let followed = try await follow.resolve(searchEndpoint: "", prompt: "Find tides documentation")
|
||||
XCTAssertTrue(followed.reference.contains("The tides documentation was followed."))
|
||||
XCTAssertTrue(followed.reference.contains("/follow-detail"))
|
||||
}
|
||||
|
||||
func testLiveLaravelRetrieval() async throws {
|
||||
|
||||
Reference in New Issue
Block a user