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
Copy file name to clipboardExpand all lines: llama-cpp-2/src/context/session.rs
+22-7Lines changed: 22 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,15 @@ pub enum LoadSessionError {
35
35
/// failed to convert path to str
36
36
#[error("failed to convert path {0} to str")]
37
37
PathToStrError(PathBuf),
38
+
39
+
/// Insufficient max length
40
+
#[error("max_length is not large enough to hold {n_out} (was {max_tokens})")]
41
+
InsufficientMaxLength{
42
+
/// The length of the session file
43
+
n_out:usize,
44
+
/// The maximum length
45
+
max_tokens:usize,
46
+
},
38
47
}
39
48
40
49
implLlamaContext<'_>{
@@ -44,9 +53,9 @@ impl LlamaContext<'_> {
44
53
///
45
54
/// * `path_session` - The file to save to.
46
55
/// * `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.
47
-
///
56
+
///
48
57
/// # Errors
49
-
///
58
+
///
50
59
/// Fails if the path is not a valid utf8, is not a valid c string, or llama.cpp fails to save the session file.
/// * `path_session` - The file to load from. It must be a session file from a compatible context, otherwise the function will error.
83
92
/// * `max_tokens` - The maximum token length of the loaded session. If the session was saved with a longer length, the function will error.
84
-
///
93
+
///
85
94
/// # Errors
86
-
///
95
+
///
87
96
/// Fails if the path is not a valid utf8, is not a valid c string, or llama.cpp fails to load the session file. (e.g. the file does not exist, is not a session file, etc.)
88
97
pubfnload_session_file(
89
98
&mutself,
@@ -103,11 +112,17 @@ impl LlamaContext<'_> {
103
112
if llama_cpp_sys_2::llama_load_session_file(
104
113
self.context.as_ptr(),
105
114
cstr.as_ptr(),
106
-
tokens.as_mut_ptr().cast::<i32>(),
115
+
// cast is valid as LlamaToken is repr(transparent)
0 commit comments