Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(llm):improve some RAG function UT(tests) #192

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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)

106 changes: 0 additions & 106 deletions hugegraph-llm/run_tests.py

This file was deleted.

17 changes: 17 additions & 0 deletions hugegraph-llm/src/tests/data/prompts/test_prompts.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# 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.
Expand Down