Use saved web and Gitea access from a fresh chat
This commit is contained in:
@@ -40,6 +40,13 @@ class Handler(BaseHTTPRequestHandler):
|
||||
payload = ''.join(f'data: {json.dumps(frame)}\n\n' for frame in frames)
|
||||
self.reply(200, (payload + 'data: [DONE]\n\n').encode(), 'text/event-stream')
|
||||
return
|
||||
if self.path == '/chat-web/api/chat':
|
||||
system, user = message['messages']
|
||||
if system['role'] != 'system' or 'Test passage.' not in system['content'] or '/article' not in user['content']:
|
||||
self.reply(400)
|
||||
return
|
||||
self.reply(200, b'{"message":{"content":"Page received."},"done":true}\n', 'application/x-ndjson')
|
||||
return
|
||||
if self.path == '/chat-tools/api/chat':
|
||||
system, user = message['messages']
|
||||
valid = (system['role'] == 'system' and 'fixture/visible-repo' in system['content']
|
||||
|
||||
+22
-3
@@ -632,6 +632,7 @@ final class ToolboxRepairTests: XCTestCase {
|
||||
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")
|
||||
}
|
||||
|
||||
func testLiveLaravelRetrieval() async throws {
|
||||
@@ -787,14 +788,32 @@ final class ConnectedChatTests: XCTestCase {
|
||||
XCTAssertEqual(studio.webStatus, "Gitea repositories checked.")
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testChatRetrievesPageWithoutToolboxConnection() async throws {
|
||||
guard let address = ProcessInfo.processInfo.environment["AISTUDIO_TEST_WEB_URL"],
|
||||
let base = URL(string: address)?.deletingLastPathComponent() else {
|
||||
throw XCTSkip("Run Scripts/test.sh to configure the fixture.")
|
||||
}
|
||||
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 = "Can you read \(base.appending(path: "article").absoluteString)?"
|
||||
studio.send(endpoint: base.appending(path: "chat-web").absoluteString, model: "fixture", mlxPath: "",
|
||||
thinking: .off, failover: false, mlxOnly: false, compatible: false, recall: false,
|
||||
useDocuments: false, instructions: "", settings: GenerationSettings())
|
||||
let deadline = ContinuousClock.now + .seconds(8)
|
||||
while studio.running && ContinuousClock.now < deadline { try await Task.sleep(for: .milliseconds(10)) }
|
||||
XCTAssertTrue(studio.activeToolsets.isEmpty)
|
||||
XCTAssertEqual(studio.messages.last?.content, "Page received.")
|
||||
}
|
||||
|
||||
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 {
|
||||
throw XCTSkip("Enable the installed Gitea smoke test explicitly.")
|
||||
}
|
||||
let file = try MCPServerConfiguration.File.read(URL(fileURLWithPath: path))
|
||||
let client = try XCTUnwrap(file.mcpServers["absdev-gitea"]).makeClient()
|
||||
_ = try await client.listTools()
|
||||
let client = try await GiteaRepositoryLookup.configuredClient(pathOverride: path)
|
||||
let result = try await GiteaRepositoryLookup.references(client: client)
|
||||
XCTAssertFalse(result.contains("Gitea returned no repository entries."))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user