Whyhow KG SDK
Project description
WhyHow Knowledge Graph Creation SDK
The WhyHow Knowledge Graph Creation SDK enables you to quickly and easily build automated knowledge graphs tailored to your unique worldview. Instantly build, extend, and query well-scoped KGs using a raw PDF and simple seed concepts in natural language. This version leverages OpenAI for embeddings and NLP, Pinecone serverless for scalable vector search and storage, and Neo4j for graph data storage and management.
Installation
Prerequisites
- Python 3.10 or higher
- OpenAI API key
- Pinecone API key
- Neo4j credentials (username, password, and URL)
Install from PyPI
You can install the SDK directly from PyPI using pip:
pip install whyhow
export OPENAI_API_KEY=<your openai api key>
export PINECONE_API_KEY=<your pinecone api key>
export NEO4J_URL=<your neo4j url>
export NEO4J_USERNAME=<your neo4j username>
export NEO4J_PASSWORD=<your neo4j password>
Install from Github
Alternatively, you can clone the repo and install the package
git clone git@github.com:whyhow-ai/whyhow.git
cd whyhow
pip install .
export OPENAI_API_KEY=<your openai api key>
export PINECONE_API_KEY=<your pinecone api key>
export NEO4J_URL=<your neo4j url>
export NEO4J_USERNAME=<your neo4j username>
export NEO4J_PASSWORD=<your neo4j password>
Examples
Navigate to the examples/
.
How to
Initialize SDK
Import the SDK and initialize the client using your WhyHow API key.
from whyhow import WhyHow
client = WhyHow(api_key=<your whyhow api key>)
Add documents to namespace
Your namespace is a logical grouping of the raw data you upload, the seed concepts you define, and the graphs you create. Namespaces are meant to be tightly scoped to your use case. You can create as many namespaces as you want.
namespace = "harry-potter"
documents = ["files/harry_potter_and_the_philosophers_stone.pdf","files/harry_potter_and_the_chamber_of_secrets.pdf"]
add_docs_response = client.graph.add_documents(namespace, documents)
print(add_docs_response)
# Adding your documents
Create a graph
Tell the WhyHow SDK what you care about by providing a list of concepts in the form of natural language questions. Using these questions, we create a small ontology to guide extraction of entities and relationships that are most relevant to your use case. We then construct triples and generate a graph.
questions = ["What does Harry wear?","Who is Harry friends with?"]
create_graph_response = client.graph.create_graph(namespace, questions)
print(create_graph_response)
# Creating your graph
Query a graph
Query your graph using natural language. Using your natural language query, we automatically construct a Cypher query to run against the graph stored in your Neo4j instance.
query = "What does Harry wear?"
query_response = client.graph.query_graph(namespace, query)
print(query_response)
# {answer: "Harry wears a cloak, glasses, robe, and Dudley's old clothes.", cypher_query: "MATCH (:Entity {name: "Harry"})-[:WEARS]->(clothing:Entity)\nRETURN clothing;"}
Contributing
We welcome contributions to improve the Rule-based Retrieval package! If you have any ideas, bug reports, or feature requests, please open an issue on the GitHub repository.
If you'd like to contribute code, please follow these steps:
- Fork the repository
- Create a new branch for your feature or bug fix
- Make your changes and commit them with descriptive messages
- Push your changes to your forked repository
- Open a pull request to the main repository
License
This project is licensed under the MIT License.
Support
WhyHow.AI is building tools to help developers bring more determinism and control to their RAG pipelines using graph structures. If you're thinking about, in the process of, or have already incorporated knowledge graphs in RAG, we’d love to chat at team@whyhow.ai, or follow our newsletter at WhyHow.AI. Join our discussions about rules, determinism and knowledge graphs in RAG on our Discord.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file whyhow-0.0.1.tar.gz
.
File metadata
- Download URL: whyhow-0.0.1.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e45f53d75e8b0426022d21552bdd5a4bb5b26179817299f6e76f7a525a0ee7ef |
|
MD5 | 63bf0dc7a0ebeb28dda700bbab58edf5 |
|
BLAKE2b-256 | 862647a2949e29e7ec7d0ff0a2efbf1f9a20140e8561ecae80342874decffcdd |
File details
Details for the file whyhow-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: whyhow-0.0.1-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5eacb1162cb35f1c62da63981442d28f8899bbd2c89d949eeca8dd7ef9f321e |
|
MD5 | 41222899c5fed383ec3669fe385937de |
|
BLAKE2b-256 | 2160f962c6d3947cf59552d389737dc3e6614b5fc2b94afde59baa847934ea28 |