Same order assistant in both frameworks against a local fake OpenAI server: starter bean collision, wire differences, tool failure and loop bounds, observability meters, MCP-first tools, and a compile check of the 2025 article's snippets and Maven coordinates. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01G8ikz8xdWuTP5yun8DZ1hk
44 lines
1.2 KiB
Java
44 lines
1.2 KiB
Java
package com.ankurm.interop;
|
|
|
|
import java.io.IOException;
|
|
import java.io.PrintWriter;
|
|
import java.io.StringWriter;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
|
|
/** Writes a numbered transcript under {@code output/} and echoes it. Every console block in the article is one of these files. */
|
|
final class Transcript implements AutoCloseable {
|
|
|
|
private final Path path;
|
|
private final StringWriter buffer = new StringWriter();
|
|
private final PrintWriter out = new PrintWriter(buffer);
|
|
|
|
Transcript(String fileName, String title) {
|
|
this.path = Path.of("output", fileName);
|
|
out.println("# " + title);
|
|
out.println();
|
|
}
|
|
|
|
Transcript line(String format, Object... args) {
|
|
out.println(args.length == 0 ? format : String.format(format, args));
|
|
return this;
|
|
}
|
|
|
|
Transcript blank() {
|
|
out.println();
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public void close() {
|
|
out.flush();
|
|
try {
|
|
Files.createDirectories(path.getParent());
|
|
Files.writeString(path, buffer.toString());
|
|
} catch (IOException e) {
|
|
throw new IllegalStateException("could not write " + path, e);
|
|
}
|
|
System.out.print(buffer);
|
|
}
|
|
}
|