refactor: 🔨 Mostly working Ollama migration, few tweaks left
This commit is contained in:
+3
-2
@@ -10,7 +10,7 @@ API_VERSION = CFG["api"]["api_version"]
|
||||
|
||||
class LocalLMEmbeddings(Embeddings):
|
||||
def __init__(self, model: str, base_url: str = API_BASE, batch_size: int = 32):
|
||||
self.url = f"{base_url}/{API_VERSION}embeddings"
|
||||
self.url = f"{base_url}/api/embed"
|
||||
self.model = model
|
||||
self.batch_size = batch_size
|
||||
|
||||
@@ -22,10 +22,11 @@ class LocalLMEmbeddings(Embeddings):
|
||||
response = requests.post(
|
||||
self.url, json=payload, timeout=120
|
||||
) # Longer timeout for batches
|
||||
# print(response)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
# print(data)
|
||||
return [item["embedding"] for item in data["data"]]
|
||||
return data["embeddings"]
|
||||
except Exception as e:
|
||||
print(f"❌ Batch request failed: {e}")
|
||||
# Returning empty lists to maintain index integrity if needed,
|
||||
|
||||
Reference in New Issue
Block a user