commit | b51717c214bd53f2bcc50594318698e7e6e1e40c | [log] [tgz] |
---|---|---|
author | Gearless <77921223+Creeprime@users.noreply.github.com> | Mon Jul 07 21:15:46 2025 +0800 |
committer | GitHub <noreply@github.com> | Mon Jul 07 21:15:46 2025 +0800 |
tree | 3e1788567433d431403e080eb76088c46128fed4 | |
parent | 52a666efabc879d704edc6aad3837358b2d486c1 [diff] |
feat(llm): support semi-automated generated graph schema (#274) ## Overview This PR implements a semi‑automated graph schema generation feature. The system collects raw data samples provided by the user, along with user‑provided or default built‑in Query Examples and Few‑Shot templates, sends them to the LLM to generate an initial schema draft for user reference. After users review and adjust the draft in the UI, the final Graph Schema is applied to the HugeGraph instance. ## Main Changes 1. **New Operator: `schema_builder.py`** - Adds `SchemaBuilder` operator responsible for prompt construction, invoking the LLM, and parsing the returned schema JSON. 2. **Built‑in Prompt Configuration: `prompt_config.py`** - Preloads default Query Examples and Few‑Shot schema templates in `prompt_config.py`; users can directly use these default templates for schema generation. 3. **UI & Workflow Updates** - Updates files such as `vector_graph_block.py` and `kg_construction_task.py` to add a collapsible "Advanced Schema Options" section in the “Build RAG Index” module for triggering the semi‑automated graph schema generation. --------- Co-authored-by: imbajin <jin@apache.org>
hugegraph-ai
integrates HugeGraph with artificial intelligence capabilities, providing comprehensive support for developers to build AI-powered graph applications.
[!NOTE] For a complete deployment guide and detailed examples, please refer to hugegraph-llm/README.md
# Clone the repository git clone https://github.com/apache/incubator-hugegraph-ai.git cd incubator-hugegraph-ai # Set up environment and start services cp docker/env.template docker/.env # Edit docker/.env to set your PROJECT_PATH cd docker docker-compose -f docker-compose-network.yml up -d # Access services: # - HugeGraph Server: http://localhost:8080 # - RAG Service: http://localhost:8001
# 1. Start HugeGraph Server docker run -itd --name=server -p 8080:8080 hugegraph/hugegraph # 2. Clone and set up the project git clone https://github.com/apache/incubator-hugegraph-ai.git cd incubator-hugegraph-ai/hugegraph-llm # 3. Install dependencies uv venv && source .venv/bin/activate uv pip install -e . # 4. Start the demo python -m hugegraph_llm.demo.rag_demo.app # Visit http://127.0.0.1:8001
from hugegraph_llm.operators.graph_rag_task import RAGPipeline # Initialize RAG pipeline graph_rag = RAGPipeline() # Ask questions about your graph result = (graph_rag .extract_keywords(text="Tell me about Al Pacino.") .keywords_to_vid() .query_graphdb(max_deep=2, max_graph_items=30) .synthesize_answer() .run())
from hugegraph_llm.models.llms.init_llm import LLMs from hugegraph_llm.operators.kg_construction_task import KgBuilder # Build KG from text TEXT = "Your text content here..." builder = KgBuilder(LLMs().get_chat_llm()) (builder .import_schema(from_hugegraph="hugegraph") .chunk_split(TEXT) .extract_info(extract_type="property_graph") .commit_to_hugegraph() .run())
from pyhugegraph.client import PyHugeClient # Connect to HugeGraph and run ML algorithms # See hugegraph-ml documentation for detailed examples
Large language model integration for graph applications:
Graph machine learning with 20+ implemented algorithms:
Python client for HugeGraph operations:
We welcome contributions! Please see our contribution guidelines for details.
Development Setup:
./style/code_format_and_analysis.sh
before submitting PRshugegraph-ai is licensed under Apache 2.0 License.