Metadata-Version: 2.4
Name: makeyouragent
Version: 0.1.0
Summary: Official Python SDK for Make Your Agent (MYA) — build AI agents with knowledge bases, tool execution, streaming chat, and per-session token usage
Project-URL: Homepage, https://makeyouragent.ai
Project-URL: Documentation, https://github.com/Make-Your-Agent/core/tree/main/sdk-python
Project-URL: Repository, https://github.com/Make-Your-Agent/core
Author: FireInBelly
License: MIT
License-File: LICENSE
Keywords: agents,ai,chatbot,llm,makeyouragent,mya,sdk
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.8
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: Typing :: Typed
Requires-Python: >=3.8
Requires-Dist: httpx>=0.24
Provides-Extra: dev
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Description-Content-Type: text/markdown

# makeyouragent (Python SDK)

Official Python SDK for [Make Your Agent (MYA)](https://makeyouragent.ai) — build AI agents with
knowledge bases, tool execution, file/image attachments, streaming chat, and per-session token usage.

This is the server-side SDK, feature-equivalent to the Node SDK's server module
([`@makeyouragent/sdk`](https://www.npmjs.com/package/@makeyouragent/sdk)).

## Install

```bash
pip install makeyouragent
```

## Quick Start

```python
from makeyouragent import MakeYourAgent

mya = MakeYourAgent(api_key="mya_live_...")

# Create an agent
agent = mya.agents.create({
    "name": "Support Bot",
    "systemPrompt": "You are a helpful support agent.",
})

# Chat (blocking)
res = mya.chat.send(agent["id"], {"message": "What can you help me with?"})
print(res["message"]["content"])
print(res["usage"])         # tokens for THIS call
print(res["sessionUsage"])  # cumulative {totals, byModel} for the whole conversation

# Chat (streaming)
stream = mya.chat.stream(agent["id"], {"message": "Tell me a story"})
for chunk in stream:
    if chunk.type == "content":
        print(chunk.delta, end="", flush=True)
final = stream.final_response()

# Knowledge bases
kb = mya.knowledge_bases.create(agent["id"], {"name": "Docs", "sourceType": "MARKDOWN"})
mya.knowledge_bases.import_(agent["id"], kb["id"], {
    "content": "# Getting Started\n\nWelcome...",
    "title": "Getting Started",
})

# File / image uploads
with open("manual.pdf", "rb") as f:
    mya.files.upload(agent["id"], f.read(), filename="manual.pdf")

# Token usage (billing) — reconcile invoices. from_/to are Unix seconds.
usage = mya.usage.get(from_=1748736000, to=1751327999)
print(usage["totals"]["totalTokens"], usage["byModel"])
```

## Resources

| Namespace | Methods |
|---|---|
| `mya.agents` | `create`, `list`, `get`, `update`, `delete` |
| `mya.chat` | `send`, `stream` |
| `mya.knowledge_bases` | `create`, `list`, `get`, `delete`, `import_`, `search` |
| `mya.files` | `upload` |
| `mya.images` | `upload` |
| `mya.usage` | `get` |

Use `mya.request(path, method=..., body=...)` for endpoints not covered by a resource
(returns the raw `httpx.Response`).

## Errors

All API and transport failures raise `MakeYourAgentError` with `.status`, `.code`, and `.data`.

```python
from makeyouragent import MakeYourAgentError

try:
    mya.agents.get("does-not-exist")
except MakeYourAgentError as e:
    print(e.status, e.code, e.message)
```

## Configuration

```python
MakeYourAgent(
    api_key="mya_live_...",
    base_url="https://api.makeyouragent.ai",  # default
    timeout=30.0,                              # seconds
    max_retries=3,                             # retries on 5xx with backoff
)
```

## License

MIT
