8000 Add runtime check to ensure embedding is enabled if trying to generat… · lapnd/llama-cpp-python@cefc69e · GitHub
[go: up one dir, main page]

Skip to content

Commit cefc69e

Browse files
committed
Add runtime check to ensure embedding is enabled if trying to generate embeddings
1 parent 5c50af7 commit cefc69e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

llama_cpp/llama.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ def create_embedding(self, input: str) -> Embedding:
242242
"""
243243
assert self.ctx is not None
244244

245+
if self.params.embedding == False:
246+
raise RuntimeError(
247+
"Llama model must be created with embedding=True to call this method"
248+
)
249+
245250
if self.verbose:
246251
llama_cpp.llama_reset_timings(self.ctx)
247252

0 commit comments

Comments
 (0)
0