Metadata-Version: 2.5
Name: doconda
Version: 0.7.0
Summary: Python SDK for Doconda: convert, generate and edit Word, PowerPoint, Excel and PDF documents from AI agents (Amazon Bedrock, Vertex AI, OpenAI, Claude, LangChain).
Project-URL: Homepage, https://doconda.com
Project-URL: Documentation, https://docs.doconda.com/sdk/python
Project-URL: Examples, https://github.com/B-C-Software/doconda-examples
Project-URL: Issues, https://github.com/B-C-Software/doconda-examples/issues
License-Expression: MIT
License-File: LICENSE
Keywords: ai-agents,anthropic,azure-openai,bedrock,chatbot,crewai,document-generation,docx,docx-generator,excel,excel-generator,gemini,langchain,llm,mcp,openai,pdf,powerpoint,pptx,pptx-generator,report-generator,tools,vertex-ai,word,xlsx
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Office/Business
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: httpx>=0.27
Description-Content-Type: text/markdown

# doconda

Convert, generate and edit **Word (DOCX), PowerPoint (PPTX), Excel (XLSX) and PDF** documents from your AI agent or chatbot, with one call. Editable files with real Word styles, reviewed before they are delivered.

Use it when your agent has to hand the user a document and you don't want to maintain python-docx, python-pptx, openpyxl or templates. Works with Amazon Bedrock, Vertex AI, Azure OpenAI, OpenAI, Claude, Gemini, LangChain, LangGraph, CrewAI, Strands and any model with tool calling.

```bash
pip install doconda
```

```python
from doconda import Doconda

doconda = Doconda()  # reads DOCONDA_API_KEY
doc = doconda.documents.create(format="docx", prompt="Report on the housing law")
print(doc["outputs"])  # links to the Word file and the PDF

open("report.docx", "wb").write(doconda.documents.download(doc["id"], "docx"))
```

Error messages and report texts come in English. For Spanish, pass `Doconda(language="es")` (sent as `Accept-Language`).
Codes (`e.code`) never change with the language.

## As tools for your agent

`doconda.tools()` returns ready-made tools (name, description, JSON Schema, `run`) to convert, create and edit documents. If the API answers with an error, `run` doesn't raise: it returns `{"error": "<code>", "message": …, "fields": …}` so the model can act on it. With Amazon Bedrock (Converse API):

```python
import json
import os

import boto3
from doconda import Doconda

bedrock = boto3.client("bedrock-runtime")
model_id = os.environ["BEDROCK_MODEL_ID"]  # any model enabled in your Bedrock account
tools = Doconda().tools()
tool_config = {
    "tools": [
        {"toolSpec": {"name": t.name, "description": t.description, "inputSchema": {"json": t.input_schema}}}
        for t in tools
    ]
}
messages = [{"role": "user", "content": [{"text": "Make an Excel with the event budget"}]}]

while True:
    res = bedrock.converse(modelId=model_id, messages=messages, toolConfig=tool_config)
    message = res["output"]["message"]
    messages.append(message)
    if res["stopReason"] != "tool_use":
        break
    results = []
    for block in message["content"]:
        if "toolUse" in block:
            use = block["toolUse"]
            out = next(t for t in tools if t.name == use["name"]).run(use["input"])
            results.append(
                {"toolResult": {"toolUseId": use["toolUseId"], "content": [{"text": json.dumps(out)}]}}
            )
    messages.append({"role": "user", "content": results})

print(message["content"][0]["text"])
```

The same tools plug into Vertex AI / Gemini, OpenAI, Claude, LangChain or CrewAI: see the guides.

## What else

- `documents.create(operation="edit", file=…, prompt=…)`: change an existing Word, PowerPoint, Excel or PDF as asked.
- `convert(file, to)`: any file into another format with no AI, e.g. a PDF to Markdown for your model or Markdown to Word (free up to 1,000 a month, then €0.01 each).
- `files.upload(path)` (or `files.upload(data, filename)` for bytes), `webhooks.create(url)` and `verify_webhook(body, headers, secret)`.

## Why Doconda

- **Editable files**: real Word styles, slide layouts and Excel formulas, not images or HTML exports.
- **Checked before delivery**: the agent checks every file and fixes what it finds before handing it over.
- **Always a PDF and a preview** of each page, ready to show in your chat UI.
- **Works with any model** that calls tools, and runs in the EU.

## Examples

- [Excel from an Amazon Bedrock agent](https://docs.doconda.com/tutorials/bedrock-excel)
- [A Vercel AI SDK chatbot that returns a Word file](https://docs.doconda.com/tutorials/ai-sdk-chatbot-word)
- [PowerPoint from Gemini on Vertex AI](https://docs.doconda.com/tutorials/vertex-powerpoint)
- [Convert files](https://docs.doconda.com/guides/convert)
- More, one per stack (Bedrock, Vertex AI, Azure OpenAI, OpenAI, Claude, LangGraph, Strands, Mastra): [B-C-Software/doconda-examples](https://github.com/B-C-Software/doconda-examples)

Also in TypeScript: [`@doconda/sdk`](https://www.npmjs.com/package/@doconda/sdk) · Docs: https://docs.doconda.com/sdk/python · Guides per stack: https://docs.doconda.com/agents/introduction · Get an API key: https://doconda.com
