Spaces:
Sleeping
Sleeping
Update kig_core/graph_operations.py
Browse files
kig_core/graph_operations.py
CHANGED
|
@@ -103,12 +103,12 @@ def generate_cypher_guided(question: str, plan_step: int) -> str:
|
|
| 103 |
# Construct Cypher query
|
| 104 |
# Ensure selected_concept is properly escaped if needed, though parameters are safer
|
| 105 |
|
| 106 |
-
cypher = f"MATCH (c:Concept {{name: $conceptName}})-[:RELATED_TO]-{target} OPTIONAL MATCH (s:Solution)-[:SOLUTION_OF]->{target} WHERE {target}:KeyIssue RETURN {fields},s.summary
|
| 107 |
# We return the query and the parameters separately for safe execution
|
| 108 |
# However, the planner currently expects just the string. Let's construct it directly for now.
|
| 109 |
# Be cautious about injection if concept names can contain special chars. Binding is preferred.
|
| 110 |
escaped_concept = selected_concept.replace("'", "\\'") # Basic escaping
|
| 111 |
-
cypher = f"MATCH (c:Concept {{name: '{escaped_concept}'}})-[:RELATED_TO]-{target} OPTIONAL MATCH (s:Solution)-[:SOLUTION_OF]->{target} WHERE {target}:KeyIssue RETURN {fields},s.summary
|
| 112 |
|
| 113 |
logger.info(f"Generated guided Cypher: {cypher}")
|
| 114 |
return cypher
|
|
|
|
| 103 |
# Construct Cypher query
|
| 104 |
# Ensure selected_concept is properly escaped if needed, though parameters are safer
|
| 105 |
|
| 106 |
+
cypher = f"MATCH (c:Concept {{name: $conceptName}})-[:RELATED_TO]-{target} OPTIONAL MATCH (s:Solution)-[:SOLUTION_OF]->{target} WHERE {target}:KeyIssue RETURN {fields},s.summary"
|
| 107 |
# We return the query and the parameters separately for safe execution
|
| 108 |
# However, the planner currently expects just the string. Let's construct it directly for now.
|
| 109 |
# Be cautious about injection if concept names can contain special chars. Binding is preferred.
|
| 110 |
escaped_concept = selected_concept.replace("'", "\\'") # Basic escaping
|
| 111 |
+
cypher = f"MATCH (c:Concept {{name: '{escaped_concept}'}})-[:RELATED_TO]-{target} OPTIONAL MATCH (s:Solution)-[:SOLUTION_OF]->{target} WHERE {target}:KeyIssue RETURN {fields},s.summary"
|
| 112 |
|
| 113 |
logger.info(f"Generated guided Cypher: {cypher}")
|
| 114 |
return cypher
|