Metadata-Version: 2.4
Name: projectdavid
Version: 1.89.0
Summary: Python SDK for interacting with the Entities Assistant API.
Author-email: Francis Neequaye Armah <francis.neequaye@projectdavid.co.uk>
License: PolyForm Noncommercial License 1.0.0
Keywords: AI,SDK,Entities,LLM,Assistant
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx<0.29,>=0.25.2
Requires-Dist: pydantic<3.0,>=2.0
Requires-Dist: python-dotenv<2.0,>=1.0.1
Requires-Dist: aiofiles<25.0,>=23.2.1
Requires-Dist: projectdavid_common==0.59.0
Requires-Dist: qdrant-client<2.0.0,>=1.0.0
Requires-Dist: pdfplumber<0.12.0,>=0.11.0
Requires-Dist: validators<0.35.0,>=0.29.0
Requires-Dist: sseclient-py
Requires-Dist: requests
Requires-Dist: python-docx
Requires-Dist: python-pptx
Requires-Dist: nest-asyncio>=1.6.0
Provides-Extra: dev
Requires-Dist: black>=23.3; extra == "dev"
Requires-Dist: isort>=5.12; extra == "dev"
Requires-Dist: pytest>=7.2; extra == "dev"
Requires-Dist: mypy>=1.0; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Provides-Extra: text-embeddings
Requires-Dist: sentence-transformers<5.0,>=3.4.0; extra == "text-embeddings"
Requires-Dist: torch>=2.0.0; extra == "text-embeddings"
Provides-Extra: vision-embeddings
Requires-Dist: sentence-transformers<5.0,>=3.4.0; extra == "vision-embeddings"
Requires-Dist: torch>=2.0.0; extra == "vision-embeddings"
Requires-Dist: torchvision>=0.15.0; extra == "vision-embeddings"
Provides-Extra: embeddings
Requires-Dist: projectdavid[text-embeddings]; extra == "embeddings"
Requires-Dist: projectdavid[vision-embeddings]; extra == "embeddings"
Dynamic: license-file

# projectdavid — Python SDK

[![Lint, Test, Tag, Publish Status](https://github.com/frankie336/projectdavid/actions/workflows/test_tag_release.yml/badge.svg)](https://github.com/frankie336/projectdavid/actions/workflows/test_tag_release.yml)
[![License: PolyForm Noncommercial](https://img.shields.io/badge/license-PolyForm%20Noncommercial%201.0.0-blue.svg)](https://polyformproject.org/licenses/noncommercial/1.0.0/)
[![PyPI](https://img.shields.io/pypi/v/projectdavid)](https://pypi.org/project/projectdavid/)
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/)

**The Python SDK for Project David — the open source, GDPR compliant successor to the OpenAI Assistants API.**

Same primitives. Every model. Your infrastructure.

---

## What is Project David?

Project David is a full-scale, containerized LLM orchestration platform built around the same primitives as the OpenAI Assistants API — **Assistants, Threads, Messages, Runs, and Tools** — but without the lock-in.

- **Provider agnostic** — Hyperbolic, TogetherAI, Ollama, or any OpenAI-compatible endpoint. Point at any inference provider and the platform normalizes the stream.
- **Every model** — hosted APIs today, raw local weights tomorrow. Bring your own model.
- **Your infrastructure** — fully self-hostable, open source, GDPR compliant, security audited.
- **Production grade** — sandboxed code execution (FireJail), multi-agent delegation, file serving with signed URLs, real-time streaming frontend.

> **Project Uni5** — the next milestone. `transformers`, GGUF, and vLLM adapters that mean a model straight off a training run has a full orchestration platform in minutes. From the lab to enterprise grade orchestration — instantly.

---

## Installation

```bash
pip install projectdavid
```

**Requirements:** Python 3.10+ · A running Project David platform instance

---

## Quick Start

```python
import os
from dotenv import load_dotenv
from projectdavid import Entity

load_dotenv()

client = Entity(
    base_url=os.getenv("BASE_URL"),        # default: http://localhost:80
    api_key=os.getenv("ENTITIES_API_KEY"),
)

# Create an assistant
assistant = client.assistants.create_assistant(
    name="my_assistant",
    instructions="You are a helpful AI assistant.",
)

# Create a thread and send a message
thread = client.threads.create_thread()

message = client.messages.create_message(
    thread_id=thread.id,
    role="user",
    content="Tell me about the latest trends in AI.",
    assistant_id=assistant.id,
)

# Create a run
run = client.runs.create_run(
    assistant_id=assistant.id,
    thread_id=thread.id,
)

# Stream the response
stream = client.synchronous_inference_stream
stream.setup(
    user_id=os.getenv("ENTITIES_USER_ID"),
    thread_id=thread.id,
    assistant_id=assistant.id,
    message_id=message.id,
    run_id=run.id,
    api_key=os.getenv("PROVIDER_API_KEY"),
)

for chunk in stream.stream_chunks(
    model="hyperbolic/deepseek-ai/DeepSeek-V3-0324",
    timeout_per_chunk=15.0,
):
    content = chunk.get("content", "")
    if content:
        print(content, end="", flush=True)
```

See the [Quick Start guide](https://github.com/project-david-ai/projectdavid_docs/blob/master/src/pages/sdk/sdk-quick-start.md) for the event-driven interface, tool calling, and advanced usage.

---

## Why Project David?

| | OpenAI Assistants API | LangChain | Project David |
|---|---|---|---|
| Assistants / Threads / Runs primitives | ✅ | ❌ | ✅ |
| Provider agnostic | ❌ | Partial | ✅ |
| Local model support | ❌ | Partial | ✅ |
| Raw weights → orchestration | ❌ | ❌ | ✅ *(Uni5)* |
| Sandboxed code execution | ✅ Black box | ❌ | ✅ FireJail PTY |
| Multi-agent delegation | Limited | ❌ | ✅ |
| Self-hostable | ❌ | ✅ | ✅ |
| GDPR compliant | ❌ | N/A | ✅ |
| Security audited | N/A | N/A | ✅ |
| Open source | ❌ | ✅ | ✅ |

---

## Supported Inference Providers

[Full list of supported providers and endpoints →](https://github.com/project-david-ai/projectdavid_docs/blob/master/src/pages/providers/providers.md)

Works with any OpenAI-compatible endpoint out of the box — including Ollama for fully local inference.

---

## Environment Variables

| Variable | Description                                        |
|---|----------------------------------------------------|
| `ENTITIES_API_KEY` | Your Entities API key                              |
| `ENTITIES_USER_ID` | Your user ID                                       |
| `BASE_URL` | Platform base URL (default: `http://localhost:80`) |
| `PROVIDER_API_KEY` | Your inference provider API key                    |

---

## Documentation

| Topic | Link |
|---|---|
| Quick Start | [sdk-quick-start.md](https://github.com/project-david-ai/projectdavid_docs/blob/master/src/pages/sdk/sdk-quick-start.md) |
| Assistants | [sdk-assistants.md](https://github.com/project-david-ai/projectdavid_docs/blob/master/src/pages/sdk/sdk-assistants.md) |
| Threads | [sdk-threads.md](https://github.com/project-david-ai/docs/blob/main/src/pages/sdk/sdk-threads.md) |
| Messages | [sdk-messages.md](https://github.com/project-david-ai/projectdavid_docs/blob/master/src/pages/sdk/sdk-messages.md) |
| Runs | [sdk-runs.md](https://github.com/project-david-ai/projectdavid_docs/blob/master/src/pages/sdk/sdk-runs.md) |
| Inference | [sdk-inference.md](https://github.com/project-david-ai/projectdavid_docs/blob/master/src/pages/sdk/sdk-inference.md) |
| Tools | [sdk-tools.md](https://github.com/project-david-ai/projectdavid_docs/blob/master/src/pages/sdk/sdk-tools.md) |
| Function Calls | [function-calling-and-tool-execution.md](https://github.com/project-david-ai/projectdavid_docs/blob/master/src/pages/sdk/sdk-function-calls.md) |
| Code Interpreter | [sdk-code-interpreter.md](https://github.com/project-david-ai/projectdavid_docs/blob/master/src/pages/sdk/platform-tools/sdk-code-interpreter.md) |
| Files | [sdk-files.md](https://github.com/project-david-ai/projectdavid_docs/blob/master/src/pages/sdk/sdk-files.md) |
| Vector Store | [sdk-vector-store.md](https://github.com/project-david-ai/projectdavid_docs/blob/master/src/pages/sdk/sdk-vector-store.md) |

[Full SDK documentation →](https://github.com/project-david-ai/projectdavid_docs/tree/master/src/pages/sdk)

> Full hosted docs coming at `docs.projectdavid.co.uk`

---

## Related Repositories

| Repo | Description |
|---|---|
| [platform](https://github.com/project-david-ai/platform) | Core orchestration engine |
| [entities-common](https://github.com/project-david-ai/entities-common) | Shared utilities and validation |
| [david-core](https://github.com/project-david-ai/david-core) | Docker orchestration layer |
| [reference-frontend](https://github.com/project-david-ai/reference-frontend) | Reference streaming frontend |
| [entities_cook_book](https://github.com/project-david-ai/entities_cook_book) | Minimal tested examples — streaming, tools, search, stateful logic |

---

## Project Uni5 — Roadmap

The next major milestone extends Project David to every model deployment scenario:

```
Got freshly trained weights?     →  transformers adapter     (Phase 1)
Got a quantized GGUF model?      →  GGUF / llama.cpp adapter (Phase 2)
Got a GPU cluster?               →  vLLM adapter             (Phase 3)
Want a hosted provider?          →  already works
Running Ollama locally?          →  already works
```

Five scenarios. One platform. **From the lab to enterprise grade orchestration — instantly.**

---

## License

[PolyForm Noncommercial 1.0.0](https://polyformproject.org/licenses/noncommercial/1.0.0/)
