feat: show backend optimization progress

This commit is contained in:
Codex
2026-06-21 23:43:03 +08:00
parent 5a627bcaa8
commit 21aa75d240
15 changed files with 549 additions and 43 deletions
+25
View File
@@ -142,6 +142,31 @@ describe("generateValidatedJson", () => {
expect(warnSpy).not.toHaveBeenCalled();
});
it("does not duplicate start and response logs when using the default JSON generator", async () => {
process.env.LLM_PROVIDER = "deepseek";
process.env.DEEPSEEK_API_KEY = "test-key";
const infoSpy = vi.spyOn(console, "info").mockImplementation(() => {});
client.setChatCompletionForTesting(async () => ({
choices: [{ message: { content: '{"value":"from-llm"}' } }],
}));
const result = await client.generateValidatedJson({
schema: z.object({ value: z.string() }),
prompt: "Return JSON.",
task: "article_optimizer",
});
expect(result).toEqual({ value: "from-llm" });
const startLogs = infoSpy.mock.calls
.map((call) => call[0])
.filter((line) => line.startsWith("[llm:start]"));
const responseLogs = infoSpy.mock.calls
.map((call) => call[0])
.filter((line) => line.startsWith("[llm:response]"));
expect(startLogs).toHaveLength(1);
expect(responseLogs).toHaveLength(1);
});
it("logs validation failure without leaking provider secrets", async () => {
process.env.LLM_PROVIDER = "deepseek";
process.env.DEEPSEEK_API_KEY = "super-secret-key";