Whyhow automated 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;"}
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.2.tar.gz
.
File metadata
- Download URL: whyhow-0.0.2.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff60729d6cde4165c6ffbed5f259a03619c7c9e3af5edad9d980e5b9185b18dd |
|
MD5 | 52130325d851b838ba64c17b9519bb6c |
|
BLAKE2b-256 | 71918c62d44a6d4d109413e4f75061dc37e32955099471163586d7423e6345cf |
File details
Details for the file whyhow-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: whyhow-0.0.2-py3-none-any.whl
- Upload date:
- Size: 9.4 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 | 736f342fcb12823efa8189fceb387093d693e1dd7bba192b2b37edf0eefa3b55 |
|
MD5 | 9b704fe7ca513b4a603f62a3824cb3f2 |
|
BLAKE2b-256 | 04f5be7e0aa2a8f4356c57baea39bca59c3af03661a901e27a5744f42556e3d2 |