update max query length

This commit is contained in:
prestonrasmussen 2025-07-21 19:39:31 -04:00
parent d31ea2d8eb
commit f4dc7e2fba
6 changed files with 21 additions and 16 deletions

View file

@ -46,7 +46,9 @@ class GraphDriverSession(ABC):
class GraphDriver(ABC):
provider: str
fulltext_syntax: str = '' # Neo4j (default) syntax does not require a prefix for fulltext queries
fulltext_syntax: str = (
'' # Neo4j (default) syntax does not require a prefix for fulltext queries
)
@abstractmethod
def execute_query(self, cypher_query_: str, **kwargs: Any) -> Coroutine:

View file

@ -98,7 +98,6 @@ class FalkorDriver(GraphDriver):
self._database = database
self.fulltext_syntax = '@' # FalkorDB uses a redisearch-like syntax for fulltext queries see https://redis.io/docs/latest/develop/ai/search-and-query/query/full-text/
def _get_graph(self, graph_name: str | None) -> FalkorGraph:
# FalkorDB requires a non-None database name for multi-tenant graphs; the default is "default_db"

View file

@ -51,6 +51,7 @@ def parse_db_date(neo_date: neo4j_time.DateTime | str | None) -> datetime | None
else None
)
def get_default_group_id(db_type: str) -> str:
"""
This function differentiates the default group id based on the database type.
@ -61,6 +62,7 @@ def get_default_group_id(db_type: str) -> str:
else:
return ''
def lucene_sanitize(query: str) -> str:
# Escape special characters from a query before passing into Lucene
# + - && || ! ( ) { } [ ] ^ " ~ * ? : \ /

View file

@ -57,12 +57,14 @@ RELEVANT_SCHEMA_LIMIT = 10
DEFAULT_MIN_SCORE = 0.6
DEFAULT_MMR_LAMBDA = 0.5
MAX_SEARCH_DEPTH = 3
MAX_QUERY_LENGTH = 32
MAX_QUERY_LENGTH = 128
def fulltext_query(query: str, group_ids: list[str] | None = None, fulltext_syntax: str = ''):
group_ids_filter_list = (
[fulltext_syntax + f"group_id:'{lucene_sanitize(g)}'" for g in group_ids] if group_ids is not None else []
[fulltext_syntax + f"group_id:'{lucene_sanitize(g)}'" for g in group_ids]
if group_ids is not None
else []
)
group_ids_filter = ''
for f in group_ids_filter_list:
@ -293,12 +295,12 @@ async def edge_bfs_search(
query = (
"""
UNWIND $bfs_origin_node_uuids AS origin_uuid
MATCH path = (origin:Entity|Episodic {uuid: origin_uuid})-[:RELATES_TO|MENTIONS]->{1,3}(n:Entity)
UNWIND relationships(path) AS rel
MATCH (n:Entity)-[r:RELATES_TO]-(m:Entity)
WHERE r.uuid = rel.uuid
"""
UNWIND $bfs_origin_node_uuids AS origin_uuid
MATCH path = (origin:Entity|Episodic {uuid: origin_uuid})-[:RELATES_TO|MENTIONS]->{1,3}(n:Entity)
UNWIND relationships(path) AS rel
MATCH (n:Entity)-[r:RELATES_TO]-(m:Entity)
WHERE r.uuid = rel.uuid
"""
+ filter_query
+ """
RETURN DISTINCT
@ -441,10 +443,10 @@ async def node_bfs_search(
query = (
"""
UNWIND $bfs_origin_node_uuids AS origin_uuid
MATCH (origin:Entity|Episodic {uuid: origin_uuid})-[:RELATES_TO|MENTIONS]->{1,3}(n:Entity)
WHERE n.group_id = origin.group_id
"""
UNWIND $bfs_origin_node_uuids AS origin_uuid
MATCH (origin:Entity|Episodic {uuid: origin_uuid})-[:RELATES_TO|MENTIONS]->{1,3}(n:Entity)
WHERE n.group_id = origin.group_id
"""
+ filter_query
+ ENTITY_NODE_RETURN
+ """

View file

@ -1,7 +1,7 @@
[project]
name = "graphiti-core"
description = "A temporal graph building library"
version = "0.17.6"
version = "0.17.7"
authors = [
{ "name" = "Paul Paliychuk", "email" = "paul@getzep.com" },
{ "name" = "Preston Rasmussen", "email" = "preston@getzep.com" },

2
uv.lock generated
View file

@ -746,7 +746,7 @@ wheels = [
[[package]]
name = "graphiti-core"
version = "0.17.5"
version = "0.17.6"
source = { editable = "." }
dependencies = [
{ name = "diskcache" },