* Remove ensure_ascii configuration parameter - Changed to_prompt_json default from ensure_ascii=True to False - Removed ensure_ascii parameter from Graphiti.__init__ and GraphitiClients - Removed ensure_ascii from all function signatures and context dictionaries - Removed ensure_ascii from all test files - All JSON serialization now preserves Unicode characters by default 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * format --------- Co-authored-by: Claude <noreply@anthropic.com>
24 lines
814 B
Python
24 lines
814 B
Python
import json
|
|
from typing import Any
|
|
|
|
DO_NOT_ESCAPE_UNICODE = '\nDo not escape unicode characters.\n'
|
|
|
|
|
|
def to_prompt_json(data: Any, ensure_ascii: bool = False, indent: int = 2) -> str:
|
|
"""
|
|
Serialize data to JSON for use in prompts.
|
|
|
|
Args:
|
|
data: The data to serialize
|
|
ensure_ascii: If True, escape non-ASCII characters. If False (default), preserve them.
|
|
indent: Number of spaces for indentation
|
|
|
|
Returns:
|
|
JSON string representation of the data
|
|
|
|
Notes:
|
|
By default (ensure_ascii=False), non-ASCII characters (e.g., Korean, Japanese, Chinese)
|
|
are preserved in their original form in the prompt, making them readable
|
|
in LLM logs and improving model understanding.
|
|
"""
|
|
return json.dumps(data, ensure_ascii=ensure_ascii, indent=indent)
|