Merge pull request #608 from ParisNeo/main
Browse filesTemporary fix to introduced problem in ollama and lollm
- lightrag/llm.py +12 -6
lightrag/llm.py
CHANGED
@@ -350,7 +350,10 @@ async def ollama_model_if_cache(
|
|
350 |
timeout = kwargs.pop("timeout", None)
|
351 |
kwargs.pop("hashing_kv", None)
|
352 |
api_key = kwargs.pop("api_key", None)
|
353 |
-
headers = {
|
|
|
|
|
|
|
354 |
ollama_client = ollama.AsyncClient(host=host, timeout=timeout, headers=headers)
|
355 |
messages = []
|
356 |
if system_prompt:
|
@@ -383,7 +386,10 @@ async def lollms_model_if_cache(
|
|
383 |
|
384 |
stream = True if kwargs.get("stream") else False
|
385 |
api_key = kwargs.pop("api_key", None)
|
386 |
-
headers = {
|
|
|
|
|
|
|
387 |
|
388 |
# Extract lollms specific parameters
|
389 |
request_data = {
|
@@ -1154,9 +1160,9 @@ async def ollama_embedding(texts: list[str], embed_model, **kwargs) -> np.ndarra
|
|
1154 |
async def ollama_embed(texts: list[str], embed_model, **kwargs) -> np.ndarray:
|
1155 |
api_key = kwargs.pop("api_key", None)
|
1156 |
headers = (
|
1157 |
-
{"
|
1158 |
if api_key
|
1159 |
-
else
|
1160 |
)
|
1161 |
kwargs["headers"] = headers
|
1162 |
ollama_client = ollama.Client(**kwargs)
|
@@ -1181,9 +1187,9 @@ async def lollms_embed(
|
|
1181 |
"""
|
1182 |
api_key = kwargs.pop("api_key", None)
|
1183 |
headers = (
|
1184 |
-
{"
|
1185 |
if api_key
|
1186 |
-
else
|
1187 |
)
|
1188 |
async with aiohttp.ClientSession(headers=headers) as session:
|
1189 |
embeddings = []
|
|
|
350 |
timeout = kwargs.pop("timeout", None)
|
351 |
kwargs.pop("hashing_kv", None)
|
352 |
api_key = kwargs.pop("api_key", None)
|
353 |
+
headers = {
|
354 |
+
"Content-Type": "application/json",
|
355 |
+
"Authorization": f"Bearer {api_key}"
|
356 |
+
} if api_key else {"Content-Type": "application/json"}
|
357 |
ollama_client = ollama.AsyncClient(host=host, timeout=timeout, headers=headers)
|
358 |
messages = []
|
359 |
if system_prompt:
|
|
|
386 |
|
387 |
stream = True if kwargs.get("stream") else False
|
388 |
api_key = kwargs.pop("api_key", None)
|
389 |
+
headers = {
|
390 |
+
"Content-Type": "application/json",
|
391 |
+
"Authorization": f"Bearer {api_key}"
|
392 |
+
} if api_key else {"Content-Type": "application/json"}
|
393 |
|
394 |
# Extract lollms specific parameters
|
395 |
request_data = {
|
|
|
1160 |
async def ollama_embed(texts: list[str], embed_model, **kwargs) -> np.ndarray:
|
1161 |
api_key = kwargs.pop("api_key", None)
|
1162 |
headers = (
|
1163 |
+
{"Content-Type": "application/json", "Authorization": api_key}
|
1164 |
if api_key
|
1165 |
+
else {"Content-Type": "application/json"}
|
1166 |
)
|
1167 |
kwargs["headers"] = headers
|
1168 |
ollama_client = ollama.Client(**kwargs)
|
|
|
1187 |
"""
|
1188 |
api_key = kwargs.pop("api_key", None)
|
1189 |
headers = (
|
1190 |
+
{"Content-Type": "application/json", "Authorization": api_key}
|
1191 |
if api_key
|
1192 |
+
else {"Content-Type": "application/json"}
|
1193 |
)
|
1194 |
async with aiohttp.ClientSession(headers=headers) as session:
|
1195 |
embeddings = []
|