Files
railseek6/test_ollama_client.py
2026-01-12 22:31:11 +08:00

32 lines
861 B
Python

import asyncio
import ollama
import sys
async def test():
# mimic the exact call from ollama_embed
api_key = ""
headers = {
"Content-Type": "application/json",
"User-Agent": f"LightRAG/0.1.0"
}
if api_key:
headers["Authorization"] = f"Bearer {api_key}"
host = None # default localhost:11434
timeout = None
ollama_client = ollama.AsyncClient(host=host, timeout=timeout, headers=headers)
try:
options = {}
data = await ollama_client.embed(
model="snowflake-arctic-embed:latest",
input=["test"],
options=options
)
print("Success:", data.keys())
except Exception as e:
print(f"Error: {e}")
import traceback
traceback.print_exc()
finally:
await ollama_client._client.aclose()
asyncio.run(test())