Metadata-Version: 2.4
Name: gdg_bu_kg
Version: 0.1.2
Summary: Python SDK for the Babcock University Knowledge Graph API
Project-URL: Homepage, https://babcock-kg.com
Project-URL: Documentation, https://docs.babcock-kg.com
Project-URL: Repository, https://github.com/babcock-kg/kg-client-python
Project-URL: Issues, https://github.com/babcock-kg/kg-client-python/issues
Author: Babcock KG Team
License: MIT
Keywords: babcock,knowledge-graph,llm,neo4j,sdk
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: httpx>=0.24
Requires-Dist: pydantic>=2.0
Requires-Dist: tenacity>=8.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: respx>=0.20; extra == 'dev'
Description-Content-Type: text/markdown

# 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`, and `top_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.
- **Minimal Dependencies**: Only `httpx`, `pydantic`, and `tenacity`.

## Installation

```bash
pip install gdg-bu-kg
```

## Quick Start (Sync)

```python
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

```python
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:

```python
# 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
