You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Persist and restore session transcripts, and prewarm sessions #23
A session lives only as long as its JS object. Chat apps cannot restore a conversation after the app restarts. The first request also pays a 1–2 s cold start that apps could hide.
Transcript is Codable, and LanguageModelSession(model:tools:transcript:) restores a session from it. prewarm(promptPrefix:) loads the model ahead of the first request.
Proposal
constsaved=session.transcript// JSON string (Transcript encoded with JSONEncoder)awaitstorage.set('chat',saved)constrestored=newLanguageModelSession({transcript: awaitstorage.get('chat'), tools })session.prewarm('You are a travel assistant')
transcript getter returns the encoded transcript as an opaque JSON string. The format belongs to Apple, so the library does not promise a stable shape beyond "round-trips through new LanguageModelSession({ transcript })".
A restored session takes its instructions from the transcript. Passing both instructions and transcript is a type error.
prewarm(promptPrefix?) forwards to LanguageModelSession.prewarm(promptPrefix:).
An invalid transcript fails with INVALID_TRANSCRIPT.
Activity
feat(session): export and restore transcripts, and prewarm