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