fix: enforce internal embeddings contract
This commit is contained in:
@@ -33,7 +33,12 @@ class OllamaInternalEmbeddings:
|
||||
raise EmbeddingsError(
|
||||
f"internal Ollama embeddings request failed for model {self.model}"
|
||||
) from exc
|
||||
payload = response.json()
|
||||
try:
|
||||
payload = response.json()
|
||||
except ValueError as exc:
|
||||
raise EmbeddingsError("internal Ollama returned an invalid JSON response") from exc
|
||||
if not isinstance(payload, dict):
|
||||
raise EmbeddingsError("internal Ollama returned a non-object response payload")
|
||||
embeddings = payload.get("embeddings")
|
||||
if not isinstance(embeddings, list):
|
||||
raise EmbeddingsError("internal Ollama response is missing embeddings")
|
||||
|
||||
Reference in New Issue
Block a user