Python SDK for the Babcock University Knowledge Graph API
Project description
gdg_bu_kg: Babcock Knowledge Graph Python SDK
A lightweight, production-ready Python SDK for interacting with the Babcock University Knowledge Graph platform.
Features
- Dual-Mode Querying:
client.query(): LLM-as-a-Service with built-in Babcock knowledge.client.graph_query(): Extract raw contextual graph data (nodes & edges).
- LLM Control: Full control over
system_prompt,temperature,max_tokens, andtop_p. - Developer-Friendly:
- Sync and Async clients (
httpx-based). - Strongly typed Pydantic v2 models.
- Rich HTML display in Jupyter Notebooks.
- Automatic retries with exponential backoff on transient errors.
- Sync and Async clients (
- Minimal Dependencies: Only
httpx,pydantic, andtenacity.
Installation
pip install gdg-bu-kg
Quick Start (Sync)
from gdg_bu_kg import KnowledgeGraphClient, AuthenticationError
# 1. Initialize with your API key
client = KnowledgeGraphClient(api_key="your_platform_api_key_here")
try:
# 2. AI Query: LLM + Knowledge Graph
response = client.query(
"Who is the current Vice Chancellor of Babcock University?",
system_prompt="You are a helpful university administrator.",
temperature=0.7
)
# Access the AI text response
print("AI Answer:", response.data.text_response)
# Access supporting graph data
for node in response.data.graph.nodes:
print(f"Verified Entity: {node.label}")
# 3. Raw Graph Data Query
graph_resp = client.graph_query("List all departments in the School of Computing")
print("Context:", graph_resp.data.context)
except AuthenticationError:
print("Invalid API Key. Please regenerate it in the SaaS Dashboard.")
finally:
client.close()
Async Usage
import asyncio
from kg_client import AsyncKnowledgeGraphClient
async def main():
async with AsyncKnowledgeGraphClient(api_key="your_key") as client:
response = await client.query("Tell me about the history of Babcock.")
print(response.data.text_response)
if __name__ == "__main__":
asyncio.run(main())
Jupyter Notebook Support
The SDK models render beautifully in Jupyter:
# In a Jupyter cell:
response = client.query("What is the School of Computing?")
response # Automatically renders as a formatted HTML view
Error Handling
The SDK provides a rich exception hierarchy:
AuthenticationError(401)ForbiddenError(403)InvalidQueryError(400)RateLimitExceededError(429)BackendServiceError(5xx)ConnectionError(Network issues)
All inherit from KnowledgeGraphError.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gdg_bu_kg-0.1.2.tar.gz
(19.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
gdg_bu_kg-0.1.2-py3-none-any.whl
(10.1 kB
view details)
File details
Details for the file gdg_bu_kg-0.1.2.tar.gz.
File metadata
- Download URL: gdg_bu_kg-0.1.2.tar.gz
- Upload date:
- Size: 19.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e0dfb4e3c235c937f6b03f4154fa2eda5d00c58586f29d6df5e7dae6626a272
|
|
| MD5 |
93ef1b89f4c59578b0a2254d3c6338d3
|
|
| BLAKE2b-256 |
b999156e8358ab96b8f1e3610cd78a23d730903ec5f1159095b342a1d5d45916
|
File details
Details for the file gdg_bu_kg-0.1.2-py3-none-any.whl.
File metadata
- Download URL: gdg_bu_kg-0.1.2-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce9bf76f8241dbc01eb6ea1a929383592a5e483b72b42eba8fc74a195441b93a
|
|
| MD5 |
fac7c4662dd47defc547a7e0e711bb58
|
|
| BLAKE2b-256 |
b2eee2a8a62eb641c444d8fc1c18fa133f43c5670f42976fe9354c6552ee4e50
|