Transcript
Represents a session's conversation history. Used to export and restore sessions.
Accessing
Every session exposes its transcript:
const transcript = session.transcript;WARNING
Access the transcript before calling session.dispose(). The transcript reads from the native session pointer.
Methods
toJson()
Export the transcript as a JSON string.
toJson(): stringtoDict()
Export the transcript as a dictionary object.
toDict(): objectdispose()
Release the C object backing a standalone transcript.
dispose(): voidTranscripts from Transcript.fromJson() / fromDict() are independent C objects that are not freed by disposing any session, so dispose them when you are done:
const transcript = Transcript.fromJson(savedJson);
try {
console.log(transcript.entries());
} finally {
transcript.dispose();
}Symbol.dispose is supported, so using handles it for you:
using transcript = Transcript.fromJson(savedJson);Safe to call more than once, and a no-op on the transcript reached through session.transcript — the session owns that pointer and frees it in session.dispose(). A FinalizationRegistry releases anything you miss, but that runs at the garbage collector's discretion, so prefer disposing explicitly. Reading a disposed transcript throws rather than dereferencing freed memory.
Static Methods
fromJson()
Create a transcript from a JSON string.
static fromJson(json: string): TranscriptfromDict()
Create a transcript from a dictionary object.
static fromDict(dict: object): TranscriptRestoring a Session
const transcript = Transcript.fromJson(savedJson);
const session = LanguageModelSession.fromTranscript(transcript);See LanguageModelSession.fromTranscript() for full options.