Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
ba85fbc
feat(llm):improve some RAG function UT(tests)
yanchaomei Mar 5, 2025
aabac09
Merge branch 'main' into main
imbajin Mar 5, 2025
a012cb2
add hugegraph-llm.yml
yanchaomei Mar 6, 2025
da5b6c0
Merge branch 'main' of github.com:yanchaomei/incubator-hugegraph-ai
yanchaomei Mar 6, 2025
ae1511c
Merge branch 'main' into main
imbajin Apr 24, 2025
fc67aa9
fix ci build error & pylint
yanchaomei Apr 28, 2025
5db19ec
fix ci bugs
yanchaomei Apr 29, 2025
d1421a7
Merge branch 'main' into main
imbajin May 22, 2025
50d4852
fix ci file
yanchaomei Jun 5, 2025
cba0502
fix ci file
yanchaomei Jun 5, 2025
4919b4b
fix ci file
yanchaomei Jun 5, 2025
f756bec
add init
yanchaomei Jun 5, 2025
2381c3b
fix method name bug
yanchaomei Jun 5, 2025
8819689
fix method name bug
yanchaomei Jun 5, 2025
0e28c89
remove py 3.12
yanchaomei Jun 5, 2025
a7e9b9b
fix pylint
yanchaomei Jun 12, 2025
bfffa16
fix pylint
yanchaomei Jun 12, 2025
2a0b616
fix ci&ptlint
yanchaomei Jun 12, 2025
be12bb3
Merge branch 'main' into main
imbajin Jun 12, 2025
20e360b
Merge branch 'main' into main
imbajin Jun 16, 2025
5fdf1b7
Update .github/workflows/hugegraph-llm.yml
yanchaomei Jul 8, 2025
402b9ba
fix issues
yanchaomei Jul 8, 2025
2a86265
fix issues
yanchaomei Jul 9, 2025
d0ac13e
fix pylints
yanchaomei Jul 9, 2025
04b2f76
fix pylints
yanchaomei Jul 9, 2025
51bae93
fix
yanchaomei Jul 28, 2025
fa67eff
fix
yanchaomei Jul 28, 2025
843d8e8
fix
yanchaomei Jul 28, 2025
9254a0a
fix
yanchaomei Jul 30, 2025
6897b3e
fix
yanchaomei Jul 30, 2025
9e40542
fix
yanchaomei Jul 30, 2025
4b8f247
fix
yanchaomei Jul 30, 2025
1a5a784
fix
yanchaomei Jul 30, 2025
8f4358f
fix
yanchaomei Jul 30, 2025
db02f9d
fix
yanchaomei Jul 30, 2025
63f36f1
fix
yanchaomei Jul 30, 2025
87744a2
fix
yanchaomei Jul 30, 2025
fe8cecb
fix
yanchaomei Jul 30, 2025
46f6ba5
fix
yanchaomei Aug 7, 2025
93e95e5
fix
yanchaomei Aug 7, 2025
09d09b5
Merge branch 'main' into main
yanchaomei Aug 7, 2025
5bc64c1
fix
yanchaomei Aug 7, 2025
dbcad5f
merged
yanchaomei Aug 7, 2025
2c3702b
Resolve merge conflicts and fix BuildGremlinExampleIndex
yanchaomei Aug 7, 2025
232d8d0
Update CI configuration to handle environment-specific test failures
yanchaomei Aug 7, 2025
c0c037c
fix
yanchaomei Aug 7, 2025
d30ad5a
add head
yanchaomei Aug 7, 2025
9117b1b
fix
yanchaomei Aug 7, 2025
ff25472
Merge branch 'main' of https://github.com/apache/incubator-hugegraph-ai
actions-user Aug 11, 2025
073a46c
Merge branch 'main' of https://github.com/apache/incubator-hugegraph-ai
actions-user Aug 11, 2025
159bfd2
Merge branch 'main' of https://github.com/apache/incubator-hugegraph-ai
actions-user Sep 11, 2025
76e6192
Merge branch 'main' of https://github.com/apache/incubator-hugegraph-ai
actions-user Oct 21, 2025
f5f9318
fix ci
yanchaomei Oct 23, 2025
6d6ceb6
fix
yanchaomei Oct 23, 2025
533e179
fix
yanchaomei Oct 23, 2025
b490f8b
fix
yanchaomei Oct 23, 2025
10cff6a
fix
yanchaomei Oct 23, 2025
119336d
fix
yanchaomei Oct 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/hugegraph-llm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: HugeGraph-LLM CI

on:
push:
branches:
- 'release-*'
pull_request:

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- name: Prepare HugeGraph Server Environment
run: |
docker run -d --name=graph -p 8080:8080 -e PASSWORD=admin hugegraph/hugegraph:1.3.0
sleep 10

- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH

- name: Cache dependencies
id: cache-deps
uses: actions/cache@v4
with:
path: |
.venv
~/.cache/uv
~/.cache/pip
key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('hugegraph-llm/requirements.txt') }}
restore-keys: |
${{ runner.os }}-venv-${{ matrix.python-version }}-
${{ runner.os }}-venv-

- name: Install dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
uv venv
source .venv/bin/activate
uv pip install pytest pytest-cov
uv pip install -r ./hugegraph-llm/requirements.txt

- name: Run unit tests
run: |
source .venv/bin/activate
export PYTHONPATH=$(pwd)/hugegraph-llm/src
export SKIP_EXTERNAL_SERVICES=true
cd hugegraph-llm
python -m pytest src/tests/operators/hugegraph_op/ src/tests/config/ src/tests/document/ src/tests/middleware/ -v

- name: Run integration tests
run: |
source .venv/bin/activate
export PYTHONPATH=$(pwd)/hugegraph-llm/src
export SKIP_EXTERNAL_SERVICES=true
cd hugegraph-llm
python -m pytest src/tests/integration/test_graph_rag_pipeline.py -v
Copy link
Member

@imbajin imbajin Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note each file should have a EOF line (U could config it in your IDE's settings)

image

So as others files

Copy link
Member

@imbajin imbajin Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/apache/incubator-hugegraph-ai/actions/runs/13693587346/job/38291894859?pr=192

And could check the CI status here (U could submit a PR in your own repo, select the upstream branch like
yanchaomei:main to test it separately)

image

Also better not use main/master as your default branch, keep it clean & it could sync the code with upstream
easily(one-click), if u want to modify some code u could checkout a new branch from main like dev-xx (This can avoid many potential conflicts and inconsistencies in the future, and also maintain clarity in using Git)

47 changes: 47 additions & 0 deletions hugegraph-llm/src/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

import os
import sys
import pytest
import nltk

# 获取项目根目录
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
# 添加到 Python 路径
sys.path.insert(0, project_root)

# 添加 src 目录到 Python 路径
src_path = os.path.join(project_root, "src")
sys.path.insert(0, src_path)

# 下载 NLTK 资源
def download_nltk_resources():
try:
nltk.data.find("corpora/stopwords")
except LookupError:
print("下载 NLTK stopwords 资源...")
nltk.download('stopwords', quiet=True)

# 在测试开始前下载 NLTK 资源
download_nltk_resources()

# 设置环境变量,跳过外部服务测试
os.environ['SKIP_EXTERNAL_SERVICES'] = 'true'

# 打印当前 Python 路径,用于调试
print("Python path:", sys.path)
6 changes: 6 additions & 0 deletions hugegraph-llm/src/tests/data/documents/sample.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Alice is 25 years old and works as a software engineer at TechCorp.
Bob is 30 years old and is a data scientist at DataInc.
Alice and Bob are colleagues and they collaborate on AI projects.
They are working on a knowledge graph project that uses natural language processing.
The project aims to extract structured information from unstructured text.
TechCorp and DataInc are partner companies in the technology sector.
42 changes: 42 additions & 0 deletions hugegraph-llm/src/tests/data/kg/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"vertices": [
{
"vertex_label": "person",
"properties": ["name", "age", "occupation"]
},
{
"vertex_label": "company",
"properties": ["name", "industry"]
},
{
"vertex_label": "project",
"properties": ["name", "technology"]
}
],
"edges": [
{
"edge_label": "works_at",
"source_vertex_label": "person",
"target_vertex_label": "company",
"properties": []
},
{
"edge_label": "colleague",
"source_vertex_label": "person",
"target_vertex_label": "person",
"properties": []
},
{
"edge_label": "works_on",
"source_vertex_label": "person",
"target_vertex_label": "project",
"properties": []
},
{
"edge_label": "partner",
"source_vertex_label": "company",
"target_vertex_label": "company",
"properties": []
}
]
}
53 changes: 53 additions & 0 deletions hugegraph-llm/src/tests/data/prompts/test_prompts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

rag_prompt:
system: |
You are a helpful assistant that answers questions based on the provided context.
Use only the information from the context to answer the question.
If you don't know the answer, say "I don't know" or "I don't have enough information".
user: |
Context:
{context}

Question:
{query}

Answer:

kg_extraction_prompt:
system: |
You are a knowledge graph extraction assistant. Your task is to extract entities and relationships from the given text according to the provided schema.
Output the extracted information in a structured format that can be used to build a knowledge graph.
user: |
Text:
{text}

Schema:
{schema}

Extract entities and relationships from the text according to the schema:

summarization_prompt:
system: |
You are a summarization assistant. Your task is to create a concise summary of the provided text.
The summary should capture the main points and key information.
user: |
Text:
{text}

Please provide a concise summary:
54 changes: 54 additions & 0 deletions hugegraph-llm/src/tests/document/test_document.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

import unittest
import importlib


class TestDocumentModule(unittest.TestCase):
def test_import_document_module(self):
"""Test that the document module can be imported."""
try:
import hugegraph_llm.document
self.assertTrue(True)
except ImportError:
self.fail("Failed to import hugegraph_llm.document module")

def test_import_chunk_split(self):
"""Test that the chunk_split module can be imported."""
try:
from hugegraph_llm.document import chunk_split
self.assertTrue(True)
except ImportError:
self.fail("Failed to import chunk_split module")

def test_chunk_splitter_class_exists(self):
"""Test that the ChunkSplitter class exists in the chunk_split module."""
try:
from hugegraph_llm.document.chunk_split import ChunkSplitter
self.assertTrue(True)
except ImportError:
self.fail("ChunkSplitter class not found in chunk_split module")

def test_module_reload(self):
"""Test that the document module can be reloaded."""
try:
import hugegraph_llm.document
importlib.reload(hugegraph_llm.document)
self.assertTrue(True)
except Exception as e:
self.fail(f"Failed to reload document module: {e}")
Loading
Loading