This is an automated email from the ASF dual-hosted git repository.
jin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph-ai.git
The following commit(s) were added to refs/heads/main by this push:
new 434d691 refactor(llm): basic compatible in text2gremlin generation
(#261)
434d691 is described below
commit 434d691e4918f11603933a566c18ad6a41b6a60f
Author: SoJGooo <[email protected]>
AuthorDate: Tue May 27 19:58:46 2025 +0800
refactor(llm): basic compatible in text2gremlin generation (#261)
---
.../src/hugegraph_llm/operators/llm_op/gremlin_generate.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git
a/hugegraph-llm/src/hugegraph_llm/operators/llm_op/gremlin_generate.py
b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/gremlin_generate.py
index 09e01e5..81aef30 100644
--- a/hugegraph-llm/src/hugegraph_llm/operators/llm_op/gremlin_generate.py
+++ b/hugegraph-llm/src/hugegraph_llm/operators/llm_op/gremlin_generate.py
@@ -41,10 +41,12 @@ class GremlinGenerateSynthesize:
self.vertices = vertices
self.gremlin_prompt = gremlin_prompt or prompt.gremlin_generate_prompt
+ # TODO: Tag is used to standardize gql output, maybe remove it in future
def _extract_response(self, response: str, label: str = "gremlin") -> str:
match = re.search(f"```{label}(.*?)```", response, re.DOTALL)
- assert match is not None, f"No {label} found in response: {response}"
- return match.group(1).strip()
+ if match:
+ return match.group(1).strip()
+ return response.strip()
def _format_examples(self, examples: Optional[List[Dict[str, str]]]) ->
Optional[str]:
if not examples: