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

@@ -10,6 +10,7 @@ except ImportError:
from mem0.configs.llms.base import BaseLlmConfig
from mem0.llms.base import LLMBase
from mem0.memory.utils import extract_json
PROVIDERS = ["ai21", "amazon", "anthropic", "cohere", "meta", "mistral", "stability", "writer"]
@@ -101,7 +102,7 @@ class AWSBedrockLLM(LLMBase):
return processed_response
response_body = response.get("body").read().decode()
response_json = json.loads(response_body)
response_json = json.loads(extract_json(response_body))
return response_json.get("content", [{"text": ""}])[0].get("text", "")
def _prepare_input(