Metadata-Version: 2.4
Name: r2p-school-sdk
Version: 0.1.1
Summary: One-liner Python SDK for R2P-Enterprise school integrations
Author-email: R2P Enterprise <kabilan3120@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/kabilan3120/R2P-School-SDK
Project-URL: Source, https://github.com/kabilan3120/R2P-School-SDK
Project-URL: Documentation, https://r2p-enterprise.vercel.app/documentation.html
Keywords: r2p,school,education,mcp,reports,rag,ai
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Education
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.31.0
Provides-Extra: rag
Requires-Dist: pinecone>=5.0.0; extra == "rag"
Provides-Extra: admin
Requires-Dist: fastapi>=0.100.0; extra == "admin"
Provides-Extra: invoicing
Requires-Dist: stripe>=8.0.0; extra == "invoicing"
Provides-Extra: all
Requires-Dist: pinecone>=5.0.0; extra == "all"
Requires-Dist: fastapi>=0.100.0; extra == "all"
Requires-Dist: stripe>=8.0.0; extra == "all"
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Dynamic: license-file

# r2p-school-sdk

One-liner Python SDK for plugging **R2P-Enterprise** into any school app or
website. Your school only needs an **API key** (created in the dashboard) —
nothing else.

```bash
pip install r2p-school-sdk
```

---

## Quickstart

```python
from r2p_school_sdk import R2PSchoolClient

client = R2PSchoolClient(
    api_url="https://r2p-enterprise.onrender.com",
    api_key="sk_...",          # created in the dashboard → API Keys
)

# 1) Analyze a student report card (PDF or image) → full pipeline
result = client.upload_report(
    file_path="report.pdf",
    student_name="Aarav Sharma",
    student_id="10-A",
    output_format="pptx",      # pptx | charts | both
    wait=True,                 # block until the pipeline finishes
)
print(result)
```

That single call runs the whole pipeline: **upload → Gemini extraction →
unified per-student JSON → charts → PPTX**. No MCP knowledge needed.

## Per-student RAG

Each student gets a **private Pinecone namespace** in the school's index, so
`query_textbook` always returns results from that student's own ingested
materials only:

```python
# Index the student's own study material into their private namespace
client.ingest_textbook(
    file_path="grade10-biology.pdf",
    textbook_name="grade10-biology",
    student_id="10-A",           # <- isolation!
)

# Ask a question — only the student's namespace is searched
answer = client.query_textbook(
    textbook_name="grade10-biology",
    question="What is photosynthesis?",
    student_id="10-A",
    top_k=5,
)
print(answer["answer"])
print(answer["sources"])         # citations with page numbers
```

If `student_id` is omitted, the shared (school-wide) namespace is used.

## Async / non-blocking analysis

`upload_report(..., wait=False)` returns immediately with `{"status": "started"}`.
Poll with:

```python
started = client.upload_report(..., wait=False)
state = client.wait_for_report(timeout=300)   # polls until completed
# or manually:
state = client.get_pipeline_state()
```

## Methods

| Method | Purpose |
|---|---|
| `upload_report(...)` | full analysis pipeline for a report PDF |
| `get_pipeline_state()` | current pipeline stage |
| `wait_for_report(timeout=)` | block until pipeline completes |
| `ingest_textbook(...)` | index a textbook (optionally per student) |
| `query_textbook(...)` | RAG question with citations |
| `list_textbooks()` | list ingested textbooks |
| `delete_textbook(name)` | remove a textbook |
| `rag_health()` | sanity-check the RAG stack |
| `list_tools()` | list all MCP tools exposed by the backend |

## Auth

- SDK calls use the school's **integration key**: `Authorization: Bearer sk_...`
- Keys are created + revoked in the dashboard
- A revoked key stops working immediately (401 on next call)

## Errors

- `PermissionError` — 401: key invalid/revoked/wrong school
- `RuntimeError` — tool-level failure (check `.error` message)
- `TimeoutError` — `wait_for_report` exceeded its timeout

## Optional extras

The core package only depends on `requests`. Optional integrations:

```bash
pip install "r2p-school-sdk[rag]"        # Pinecone per-student RAG manager
pip install "r2p-school-sdk[admin]"      # FastAPI admin dashboard sub-app
pip install "r2p-school-sdk[invoicing]"  # Stripe invoice helpers
pip install "r2p-school-sdk[all]"        # everything
```

## Example app

See [`example.py`](example.py) for a drop-in FastAPI route / Django view /
plain script using the same two lines.

## License

MIT
