Add: Json Parsing to solve Hallucination Errors (#3013)
This commit is contained in:
@@ -4,6 +4,7 @@ from typing import Dict, List, Optional
|
||||
|
||||
from mem0.configs.llms.base import BaseLlmConfig
|
||||
from mem0.llms.base import LLMBase
|
||||
from mem0.memory.utils import extract_json
|
||||
|
||||
|
||||
class VllmLLM(LLMBase):
|
||||
@@ -39,7 +40,7 @@ class VllmLLM(LLMBase):
|
||||
for tool_call in response.choices[0].message.tool_calls:
|
||||
processed_response["tool_calls"].append({
|
||||
"name": tool_call.function.name,
|
||||
"arguments": json.loads(tool_call.function.arguments),
|
||||
"arguments": json.loads(extract_json(tool_call.function.arguments)),
|
||||
})
|
||||
|
||||
return processed_response
|
||||
|
||||
Reference in New Issue
Block a user