General Introduction
Knowledge Graph Studio (KGS) is an open source platform designed to simplify the process of creating and managing RAG-native knowledge graphs. The platform provides rule-based entity parsing, modular graph construction, flexible data ingestion, and API-first design to support developers via an SDK. Whether dealing with structured or unstructured data, Knowledge Graph Studio provides users with scalable and flexible solutions for experimental and large-scale applications. Built on a NoSQL database, the platform supports fast data retrieval and easy traversal of complex relationships, and is committed to becoming a database-agnostic solution.
Function List
- Rule-based entity resolution
- Modular mapping construction
- Flexible data ingestion
- API-first design with SDK support
- Support for structured and unstructured data
- Scalable and flexible solutions
- Fast Data Retrieval and Complex Relational Traversal
- Support for multiple databases
Using Help
Installation process
- Cloning Warehouse:
git clone git@github.com:whyhow-ai/knowledge-graph-studio.git
cd knowledge-graph-studio
- Install the dependencies:
pip install .
- Developer Installation:
pip install -e .[dev,docs]
Quick Start
- Preparation:
- OpenAI API Key
- MongoDB Account
- Creating Projects and Clusters in MongoDB Atlas
- Configure environment variables:
cp .env.sample .env
update.env
values in the file:
WHYHOW__EMBEDDING__OPENAI__API_KEY=<你的OpenAI API密钥>
WHYHOW__GENERATIVE__OPENAI__API_KEY=<你的OpenAI API密钥>
WHYHOW__MONGODB__USERNAME=<你的MongoDB用户名>
WHYHOW__MONGODB__PASSWORD=<你的MongoDB密码>
WHYHOW__MONGODB__DATABASE_NAME=main
WHYHOW__MONGODB__HOST=<你的MongoDB主机>
- Create databases and collections:
cd src/whyhow_api/cli/
python admin.py setup-collections --config-file collection_index_config.json
- Create user and API keys:
python admin.py create-user --email <你的邮箱地址> --openai-key <你的OpenAI API密钥>
- Start the API server:
uvicorn src.whyhow_api.main:app
Using the SDK
- Install the Python SDK:
pip install whyhow
- Configure the WhyHow client:
from whyhow import WhyHow
client = WhyHow(api_key='<你的WhyHow API密钥>', base_url="http://localhost:8000")
- Create workspaces and maps:
workspace = client.workspaces.create(name="Demo Workspace")
chunk = client.chunks.create(workspace_id=workspace.workspace_id, chunks=[Chunk(content="示例内容")])
triples = [Triple(head=Node(name="示例节点", label="示例标签"), relation=Relation(name="示例关系"), tail=Node(name="示例尾节点", label="示例尾标签"), chunk_ids=[c.chunk_id for c in chunk])]
graph = client.graphs.create_graph_from_triples(name="Demo Graph", workspace_id=workspace.workspace_id, triples=triples)
- Query Mapping:
query = client.graphs.query_unstructured(graph_id=graph.graph_id, query="示例查询")
Using Docker
- Build the mirror image:
docker build --platform=linux/amd64 -t kg_engine:v1 .
- Run the image:
docker run -it --rm -p 1234:8000 kg_engine:v1