Merge pull request #608 from ParisNeo/main

Temporary fix to introduced problem in ollama and lollm
This commit is contained in:
zrguo
2025-01-20 17:23:28 +08:00
committed by GitHub

View File

@@ -350,7 +350,10 @@ async def ollama_model_if_cache(
timeout = kwargs.pop("timeout", None)
kwargs.pop("hashing_kv", None)
api_key = kwargs.pop("api_key", None)
headers = {"Authorization": f"Bearer {api_key}"} if api_key else None
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
} if api_key else {"Content-Type": "application/json"}
ollama_client = ollama.AsyncClient(host=host, timeout=timeout, headers=headers)
messages = []
if system_prompt:
@@ -383,7 +386,10 @@ async def lollms_model_if_cache(
stream = True if kwargs.get("stream") else False
api_key = kwargs.pop("api_key", None)
headers = {"Authorization": f"Bearer {api_key}"} if api_key else None
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
} if api_key else {"Content-Type": "application/json"}
# Extract lollms specific parameters
request_data = {
@@ -1154,9 +1160,9 @@ async def ollama_embedding(texts: list[str], embed_model, **kwargs) -> np.ndarra
async def ollama_embed(texts: list[str], embed_model, **kwargs) -> np.ndarray:
api_key = kwargs.pop("api_key", None)
headers = (
{"Authorization": api_key, "Content-Type": "application/json"}
{"Content-Type": "application/json", "Authorization": api_key}
if api_key
else None
else {"Content-Type": "application/json"}
)
kwargs["headers"] = headers
ollama_client = ollama.Client(**kwargs)
@@ -1181,9 +1187,9 @@ async def lollms_embed(
"""
api_key = kwargs.pop("api_key", None)
headers = (
{"Authorization": api_key, "Content-Type": "application/json"}
{"Content-Type": "application/json", "Authorization": api_key}
if api_key
else None
else {"Content-Type": "application/json"}
)
async with aiohttp.ClientSession(headers=headers) as session:
embeddings = []