workspace working
This commit is contained in:
32
test_ollama_client.py
Normal file
32
test_ollama_client.py
Normal file
@@ -0,0 +1,32 @@
|
||||
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())
|
||||
Reference in New Issue
Block a user