Skip to content

Commit ae004eb

Browse files
committed
1 parent 7d1977e commit ae004eb

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

llama_cpp/llama.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,17 @@ def create_embedding(self, input: str) -> Embedding:
262262
},
263263
}
264264

265+
def embed(self, input: str) -> List[float]:
266+
"""Embed a string.
267+
268+
Args:
269+
input: The utf-8 encoded string to embed.
270+
271+
Returns:
272+
A list of embeddings
273+
"""
274+
return list(map(float, self.create_embedding(input)["data"][0]["embedding"]))
275+
265276
def _create_completion(
266277
self,
267278
prompt: str,
@@ -341,7 +352,7 @@ def _create_completion(
341352
"model": self.model_path,
342353
"choices": [
343354
{
344-
"text": text[start :].decode("utf-8"),
355+
"text": text[start:].decode("utf-8"),
345356
"index": 0,
346357
"logprobs": None,
347358
"finish_reason": None,

0 commit comments

Comments
 (0)