We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7d1977e commit ae004ebCopy full SHA for ae004eb
1 file changed
llama_cpp/llama.py
@@ -262,6 +262,17 @@ def create_embedding(self, input: str) -> Embedding:
262
},
263
}
264
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
276
def _create_completion(
277
self,
278
prompt: str,
@@ -341,7 +352,7 @@ def _create_completion(
341
352
"model": self.model_path,
342
353
"choices": [
343
354
{
344
- "text": text[start :].decode("utf-8"),
355
+ "text": text[start:].decode("utf-8"),
345
356
"index": 0,
346
357
"logprobs": None,
347
358
"finish_reason": None,
0 commit comments