Skip to content

Commit c6179bf

Browse files
committed
Add documentation to load_session_file and save_session_file
1 parent b8fad09 commit c6179bf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

llama-cpp-2/src/context/session.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ pub enum LoadSessionError {
3030
}
3131

3232
impl LlamaContext<'_> {
33+
/// Save the current session to a file.
34+
///
35+
/// # Parameters
36+
///
37+
/// * `path_session` - The file to save to.
38+
/// * `tokens` - The tokens to associate the session with. This should be a prefix of a sequence of tokens that the context has processed, so that the relevant KV caches are already filled.
3339
pub fn save_session_file(&self, path_session: impl AsRef<Path>, tokens: &[LlamaToken]) -> Result<(), SaveSessionError> {
3440
let path = path_session.as_ref();
3541
let path = path
@@ -50,6 +56,12 @@ impl LlamaContext<'_> {
5056
Err(SaveSessionError::FailedToSave)
5157
}
5258
}
59+
/// Load a session file into the current context.
60+
///
61+
/// # Parameters
62+
///
63+
/// * `path_session` - The file to load from. It must be a session file from a compatible context, otherwise the function will error.
64+
/// * `max_tokens` - The maximum token length of the loaded session. If the session was saved with a longer length, the function will error.
5365
pub fn load_session_file(&mut self, path_session: impl AsRef<Path>, max_tokens: usize) -> Result<Vec<LlamaToken>, LoadSessionError> {
5466
let path = path_session.as_ref();
5567
let path = path

0 commit comments

Comments
 (0)