Skip to content

Commit 9ae6f41

Browse files
committed
added docs
1 parent b2284b7 commit 9ae6f41

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,34 @@ use crate::token::LlamaToken;
55
use std::ffi::{CString, NulError};
66
use std::path::{Path, PathBuf};
77

8+
/// Failed to save a Session file
89
#[derive(Debug, Eq, PartialEq, thiserror::Error)]
910
pub enum SaveSessionError {
11+
/// llama.cpp failed to save the session file
1012
#[error("Failed to save session file")]
1113
FailedToSave,
1214

15+
/// null byte in string
1316
#[error("null byte in string {0}")]
1417
NullError(#[from] NulError),
1518

19+
/// failed to convert path to str
1620
#[error("failed to convert path {0} to str")]
1721
PathToStrError(PathBuf),
1822
}
1923

24+
/// Failed to load a Session file
2025
#[derive(Debug, Eq, PartialEq, thiserror::Error)]
2126
pub enum LoadSessionError {
27+
/// llama.cpp failed to load the session file
2228
#[error("Failed to load session file")]
2329
FailedToLoad,
2430

31+
/// null byte in string
2532
#[error("null byte in string {0}")]
2633
NullError(#[from] NulError),
2734

35+
/// failed to convert path to str
2836
#[error("failed to convert path {0} to str")]
2937
PathToStrError(PathBuf),
3038
}

simple/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ enum Model {
5858

5959
impl Model {
6060
/// Convert the model to a path - may download from huggingface
61-
fn to_path(self) -> Result<PathBuf> {
61+
fn as_path(self) -> Result<PathBuf> {
6262
match self {
6363
Model::Local { path } => Ok(path),
6464
Model::HuggingFace { model, repo } => ApiBuilder::new()
@@ -97,7 +97,7 @@ fn main() -> Result<()> {
9797
};
9898

9999
let model_path = model
100-
.to_path()
100+
.as_path()
101101
.with_context(|| "failed to get model from args")?;
102102

103103
let model = LlamaModel::load_from_file(&backend, model_path, &model_params)
@@ -116,7 +116,7 @@ fn main() -> Result<()> {
116116

117117
let tokens_list = model
118118
.str_to_token(&prompt, AddBos::Always)
119-
.with_context(|| format!("failed to tokenize {}", prompt))?;
119+
.with_context(|| format!("failed to tokenize {prompt}"))?;
120120

121121
let n_cxt = ctx.n_ctx() as i32;
122122
let n_kv_req = tokens_list.len() as i32 + (n_len - tokens_list.len() as i32);

0 commit comments

Comments
 (0)