From 18e86a18256dc7c50735a547ce0f0dfbf7a15072 Mon Sep 17 00:00:00 2001 From: partoneplay Date: Tue, 3 Dec 2024 08:41:12 +0800 Subject: [PATCH] `embedding` deprecated in favor of `embed` --- lightrag/llm.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lightrag/llm.py b/lightrag/llm.py index 7dc8b886..18b5ddd2 100644 --- a/lightrag/llm.py +++ b/lightrag/llm.py @@ -745,6 +745,9 @@ async def hf_embedding(texts: list[str], tokenizer, embed_model) -> np.ndarray: async def ollama_embedding(texts: list[str], embed_model, **kwargs) -> np.ndarray: + """ + Deprecated in favor of `embed`. + """ embed_text = [] ollama_client = ollama.Client(**kwargs) for text in texts: @@ -754,6 +757,12 @@ async def ollama_embedding(texts: list[str], embed_model, **kwargs) -> np.ndarra return embed_text +async def ollama_embed(texts: list[str], embed_model, **kwargs) -> np.ndarray: + ollama_client = ollama.Client(**kwargs) + data = ollama_client.embed(model=embed_model, input=texts) + return data["embeddings"] + + class Model(BaseModel): """ This is a Pydantic model class named 'Model' that is used to define a custom language model.