Skip to content

Commit 79a8635

Browse files
committed
fix(vocab): update vocab_type to use self.vocab and add None checks
Signed-off-by: JamePeng <jame_peng@sina.com>
1 parent 8b38e72 commit 79a8635

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

llama_cpp/_internals.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,13 @@ def __del__(self):
100100
self.close()
101101

102102
def vocab_type(self) -> int:
103-
return llama_cpp.llama_vocab_type(self.model)
103+
if self.vocab is None:
104+
raise RuntimeError("LlamaModel.vocab_type: vocab is None")
105+
return llama_cpp.llama_vocab_type(self.vocab)
104106

105107
def n_vocab(self) -> int:
108+
if self.vocab is None:
109+
raise RuntimeError("LlamaModel.n_vocab: vocab is None")
106110
return llama_cpp.llama_vocab_n_tokens(self.vocab)
107111

108112
def n_ctx_train(self) -> int:

0 commit comments

Comments
 (0)