feat: show backend optimization progress
This commit is contained in:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user