This is an automated email from the ASF dual-hosted git repository. jin pushed a commit to branch dev in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph-ai.git
commit 76212e15170544056a78cbf6d7a0da26f9631878 Author: imbajin <[email protected]> AuthorDate: Tue Nov 26 19:30:23 2024 +0800 fix: text2gremlin schema miss --- .../src/hugegraph_llm/demo/rag_demo/text2gremlin_block.py | 6 ++++-- .../src/hugegraph_llm/operators/hugegraph_op/graph_rag_query.py | 7 ++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/hugegraph-llm/src/hugegraph_llm/demo/rag_demo/text2gremlin_block.py b/hugegraph-llm/src/hugegraph_llm/demo/rag_demo/text2gremlin_block.py index 0c39d8d..4a0607b 100644 --- a/hugegraph-llm/src/hugegraph_llm/demo/rag_demo/text2gremlin_block.py +++ b/hugegraph-llm/src/hugegraph_llm/demo/rag_demo/text2gremlin_block.py @@ -25,6 +25,7 @@ from hugegraph_llm.config import prompt from hugegraph_llm.models.embeddings.init_embedding import Embeddings from hugegraph_llm.models.llms.init_llm import LLMs from hugegraph_llm.operators.gremlin_generate_task import GremlinGenerator +from hugegraph_llm.operators.hugegraph_op.schema_manager import SchemaManager from hugegraph_llm.utils.log import log @@ -59,8 +60,9 @@ def gremlin_generate(inp, example_num, schema) -> Tuple[str, str]: except json.JSONDecodeError as e: log.error("Invalid JSON schema provided: %s", e) return "Invalid JSON schema, please check the format carefully.", "" - - context = generator.example_index_query(example_num).gremlin_generate(schema).run(query=inp) + # FIXME: schema is not used in gremlin_generate() step, no context for it (enhance the logic here) + updated_schema = SchemaManager(graph_name=schema).schema.getSchema() + context = generator.example_index_query(example_num).gremlin_generate(updated_schema).run(query=inp) return context.get("match_result", "No Results"), context["result"] diff --git a/hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/graph_rag_query.py b/hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/graph_rag_query.py index 1ce5c60..40f2670 100644 --- a/hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/graph_rag_query.py +++ b/hugegraph-llm/src/hugegraph_llm/operators/hugegraph_op/graph_rag_query.py @@ -131,10 +131,7 @@ class GraphRAGQuery: if not context.get("graph_result"): context = self._subgraph_query(context) - verbose = context.get("verbose") or False - if verbose: - log.debug("\033[93mKnowledge from Graph:\n%s\033[0m", "\n".join(context["graph_result"])) - + log.debug("\033[93mKnowledge from Graph:\n%s\033[0m", "\n".join(context["graph_result"])) return context def _gremlin_generate_query(self, context: Dict[str, Any]) -> Dict[str, Any]: @@ -242,7 +239,7 @@ class GraphRAGQuery: context["knowledge_with_degree"] = knowledge_with_degree context["graph_context_head"] = ( f"The following are graph knowledge in {self._max_deep} depth, e.g:\n" - "`vertexA --[links]--> vertexB <--[links]-- vertexC ...`" + "`vertexA--[links]-->vertexB<--[links]--vertexC ...`" "extracted based on key entities as subject:\n" ) return context
