Fixed missing imports bug and fixed linting

This commit is contained in:
Saifeddine ALOUI
2025-01-25 00:55:07 +01:00
parent e060fa6abb
commit 06c9e4e454
20 changed files with 59 additions and 90 deletions

View File

@@ -41,11 +41,12 @@ __author__ = "lightrag Team"
__status__ = "Production"
import sys
if sys.version_info < (3, 9):
from typing import AsyncIterator
else:
from collections.abc import AsyncIterator
import pipmaster as pm # Pipmaster for dynamic library install
import pipmaster as pm # Pipmaster for dynamic library install
# install specific modules
if not pm.is_installed("ollama"):
@@ -114,6 +115,7 @@ async def ollama_model_if_cache(
else:
return response["message"]["content"]
async def ollama_model_complete(
prompt, system_prompt=None, history_messages=[], keyword_extraction=False, **kwargs
) -> Union[str, AsyncIterator[str]]:
@@ -129,6 +131,7 @@ async def ollama_model_complete(
**kwargs,
)
async def ollama_embedding(texts: list[str], embed_model, **kwargs) -> np.ndarray:
"""
Deprecated in favor of `embed`.
@@ -152,4 +155,4 @@ async def ollama_embed(texts: list[str], embed_model, **kwargs) -> np.ndarray:
kwargs["headers"] = headers
ollama_client = ollama.Client(**kwargs)
data = ollama_client.embed(model=embed_model, input=texts)
return data["embeddings"]
return data["embeddings"]