Add: Json Parsing to solve Hallucination Errors (#3013)

This commit is contained in:
Akshat Jain
2025-06-23 21:50:16 +05:30
committed by GitHub
parent eb24b92227
commit 2bb0653e67
15 changed files with 44 additions and 17 deletions

View File

@@ -11,6 +11,7 @@ import numpy as np
from mem0.configs.embeddings.base import BaseEmbedderConfig
from mem0.embeddings.base import EmbeddingBase
from mem0.memory.utils import extract_json
class AWSBedrockEmbedding(EmbeddingBase):
@@ -74,7 +75,7 @@ class AWSBedrockEmbedding(EmbeddingBase):
contentType="application/json",
)
response_body = json.loads(response.get("body").read())
response_body = json.loads(extract_json(response.get("body").read()))
if provider == "cohere":
embeddings = response_body.get("embeddings")[0]