diff --git a/graphiti_core/graphiti.py b/graphiti_core/graphiti.py index 56e3469c..8e58a5ae 100644 --- a/graphiti_core/graphiti.py +++ b/graphiti_core/graphiti.py @@ -123,7 +123,7 @@ class Graphiti: store_raw_episode_content: bool = True, graph_driver: GraphDriver | None = None, max_coroutines: int | None = None, - ensure_ascii: bool = True, + ensure_ascii: bool = False, ): """ Initialize a Graphiti instance. @@ -157,7 +157,7 @@ class Graphiti: The maximum number of concurrent operations allowed. Overrides SEMAPHORE_LIMIT set in the environment. If not set, the Graphiti default is used. ensure_ascii : bool, optional - Whether to escape non-ASCII characters in JSON serialization for prompts. Defaults to True. + Whether to escape non-ASCII characters in JSON serialization for prompts. Defaults to False. Set to False to preserve non-ASCII characters (e.g., Korean, Japanese, Chinese) in their original form, making them readable in LLM logs and improving model understanding. diff --git a/graphiti_core/graphiti_types.py b/graphiti_core/graphiti_types.py index 87b56c77..8d140597 100644 --- a/graphiti_core/graphiti_types.py +++ b/graphiti_core/graphiti_types.py @@ -27,6 +27,6 @@ class GraphitiClients(BaseModel): llm_client: LLMClient embedder: EmbedderClient cross_encoder: CrossEncoderClient - ensure_ascii: bool = True + ensure_ascii: bool = False model_config = ConfigDict(arbitrary_types_allowed=True) diff --git a/graphiti_core/prompts/dedupe_edges.py b/graphiti_core/prompts/dedupe_edges.py index beb59163..84d25f4e 100644 --- a/graphiti_core/prompts/dedupe_edges.py +++ b/graphiti_core/prompts/dedupe_edges.py @@ -67,11 +67,11 @@ def edge(context: dict[str, Any]) -> list[Message]: Given the following context, determine whether the New Edge represents any of the edges in the list of Existing Edges. - {to_prompt_json(context['related_edges'], ensure_ascii=context.get('ensure_ascii', True), indent=2)} + {to_prompt_json(context['related_edges'], ensure_ascii=context.get('ensure_ascii', False), indent=2)} - {to_prompt_json(context['extracted_edges'], ensure_ascii=context.get('ensure_ascii', True), indent=2)} + {to_prompt_json(context['extracted_edges'], ensure_ascii=context.get('ensure_ascii', False), indent=2)} Task: @@ -98,7 +98,7 @@ def edge_list(context: dict[str, Any]) -> list[Message]: Given the following context, find all of the duplicates in a list of facts: Facts: - {to_prompt_json(context['edges'], ensure_ascii=context.get('ensure_ascii', True), indent=2)} + {to_prompt_json(context['edges'], ensure_ascii=context.get('ensure_ascii', False), indent=2)} Task: If any facts in Facts is a duplicate of another fact, return a new fact with one of their uuid's. diff --git a/graphiti_core/prompts/dedupe_nodes.py b/graphiti_core/prompts/dedupe_nodes.py index fba6f645..5e2507c4 100644 --- a/graphiti_core/prompts/dedupe_nodes.py +++ b/graphiti_core/prompts/dedupe_nodes.py @@ -64,20 +64,20 @@ def node(context: dict[str, Any]) -> list[Message]: role='user', content=f""" - {to_prompt_json([ep for ep in context['previous_episodes']], ensure_ascii=context.get('ensure_ascii', True), indent=2)} + {to_prompt_json([ep for ep in context['previous_episodes']], ensure_ascii=context.get('ensure_ascii', False), indent=2)} {context['episode_content']} - {to_prompt_json(context['extracted_node'], ensure_ascii=context.get('ensure_ascii', True), indent=2)} + {to_prompt_json(context['extracted_node'], ensure_ascii=context.get('ensure_ascii', False), indent=2)} - {to_prompt_json(context['entity_type_description'], ensure_ascii=context.get('ensure_ascii', True), indent=2)} + {to_prompt_json(context['entity_type_description'], ensure_ascii=context.get('ensure_ascii', False), indent=2)} - {to_prompt_json(context['existing_nodes'], ensure_ascii=context.get('ensure_ascii', True), indent=2)} + {to_prompt_json(context['existing_nodes'], ensure_ascii=context.get('ensure_ascii', False), indent=2)} Given the above EXISTING ENTITIES and their attributes, MESSAGE, and PREVIOUS MESSAGES; Determine if the NEW ENTITY extracted from the conversation diff --git a/graphiti_core/prompts/eval.py b/graphiti_core/prompts/eval.py index 09e874e6..5c3fa64e 100644 --- a/graphiti_core/prompts/eval.py +++ b/graphiti_core/prompts/eval.py @@ -68,7 +68,7 @@ def query_expansion(context: dict[str, Any]) -> list[Message]: Bob is asking Alice a question, are you able to rephrase the question into a simpler one about Alice in the third person that maintains the relevant context? - {to_prompt_json(context['query'], ensure_ascii=context.get('ensure_ascii', True))} + {to_prompt_json(context['query'], ensure_ascii=context.get('ensure_ascii', False))} """ return [ @@ -84,10 +84,10 @@ def qa_prompt(context: dict[str, Any]) -> list[Message]: Your task is to briefly answer the question in the way that you think Alice would answer the question. You are given the following entity summaries and facts to help you determine the answer to your question. - {to_prompt_json(context['entity_summaries'], ensure_ascii=context.get('ensure_ascii', True))} + {to_prompt_json(context['entity_summaries'], ensure_ascii=context.get('ensure_ascii', False))} - {to_prompt_json(context['facts'], ensure_ascii=context.get('ensure_ascii', True))} + {to_prompt_json(context['facts'], ensure_ascii=context.get('ensure_ascii', False))} {context['query']} diff --git a/graphiti_core/prompts/extract_edges.py b/graphiti_core/prompts/extract_edges.py index 573984e4..f2a981a2 100644 --- a/graphiti_core/prompts/extract_edges.py +++ b/graphiti_core/prompts/extract_edges.py @@ -73,7 +73,7 @@ def edge(context: dict[str, Any]) -> list[Message]: -{to_prompt_json([ep for ep in context['previous_episodes']], ensure_ascii=context.get('ensure_ascii', True), indent=2)} +{to_prompt_json([ep for ep in context['previous_episodes']], ensure_ascii=context.get('ensure_ascii', False), indent=2)} @@ -132,7 +132,7 @@ def reflexion(context: dict[str, Any]) -> list[Message]: user_prompt = f""" -{to_prompt_json([ep for ep in context['previous_episodes']], ensure_ascii=context.get('ensure_ascii', True), indent=2)} +{to_prompt_json([ep for ep in context['previous_episodes']], ensure_ascii=context.get('ensure_ascii', False), indent=2)} {context['episode_content']} @@ -166,7 +166,7 @@ def extract_attributes(context: dict[str, Any]) -> list[Message]: content=f""" - {to_prompt_json(context['episode_content'], ensure_ascii=context.get('ensure_ascii', True), indent=2)} + {to_prompt_json(context['episode_content'], ensure_ascii=context.get('ensure_ascii', False), indent=2)} {context['reference_time']} diff --git a/graphiti_core/search/search_helpers.py b/graphiti_core/search/search_helpers.py index 245d17a5..2e3a1c50 100644 --- a/graphiti_core/search/search_helpers.py +++ b/graphiti_core/search/search_helpers.py @@ -25,7 +25,7 @@ def format_edge_date_range(edge: EntityEdge) -> str: def search_results_to_context_string( - search_results: SearchResults, ensure_ascii: bool = True + search_results: SearchResults, ensure_ascii: bool = False ) -> str: """Reformats a set of SearchResults into a single string to pass directly to an LLM as context""" fact_json = [ diff --git a/graphiti_core/utils/maintenance/node_operations.py b/graphiti_core/utils/maintenance/node_operations.py index f0184aeb..d911e569 100644 --- a/graphiti_core/utils/maintenance/node_operations.py +++ b/graphiti_core/utils/maintenance/node_operations.py @@ -48,7 +48,7 @@ async def extract_nodes_reflexion( episode: EpisodicNode, previous_episodes: list[EpisodicNode], node_names: list[str], - ensure_ascii: bool = True, + ensure_ascii: bool = False, ) -> list[str]: # Prepare context for LLM context = { @@ -331,7 +331,7 @@ async def extract_attributes_from_node( episode: EpisodicNode | None = None, previous_episodes: list[EpisodicNode] | None = None, entity_type: type[BaseModel] | None = None, - ensure_ascii: bool = True, + ensure_ascii: bool = False, ) -> EntityNode: node_context: dict[str, Any] = { 'name': node.name, diff --git a/graphiti_core/utils/maintenance/temporal_operations.py b/graphiti_core/utils/maintenance/temporal_operations.py index dd73eca1..b53ec2f8 100644 --- a/graphiti_core/utils/maintenance/temporal_operations.py +++ b/graphiti_core/utils/maintenance/temporal_operations.py @@ -35,7 +35,7 @@ async def extract_edge_dates( edge: EntityEdge, current_episode: EpisodicNode, previous_episodes: list[EpisodicNode], - ensure_ascii: bool = True, + ensure_ascii: bool = False, ) -> tuple[datetime | None, datetime | None]: context = { 'edge_fact': edge.fact, @@ -75,7 +75,7 @@ async def get_edge_contradictions( llm_client: LLMClient, new_edge: EntityEdge, existing_edges: list[EntityEdge], - ensure_ascii: bool = True, + ensure_ascii: bool = False, ) -> list[EntityEdge]: start = time() diff --git a/pyproject.toml b/pyproject.toml index 64e28f70..d0b864ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "graphiti-core" description = "A temporal graph building library" -version = "0.18.4" +version = "0.18.5" authors = [ { name = "Paul Paliychuk", email = "paul@getzep.com" }, { name = "Preston Rasmussen", email = "preston@getzep.com" },