Catalog PyPI
PACKAGE EXPLORERView in registry

agent-office

PyPI

Python SDK for Agent Office API - AI-powered document editing

agent-officeaiapiautomationdocument-editingsdk
Versions collected1
Direct dependencies5From release 0.0.4
Last observed20 Oct, 22:48 UTC

README

Version 0.0.4 documentation

Agent Office Python SDK

Python SDK for the Agent Office API - AI-powered document editing for agentic workflows.

Installation

pip install agent-office

Quick Start

from agent_office import AgentOffice
from uuid import uuid4

# Initialize the client
client = AgentOffice(api_key="sk_ao_your_api_key")  # Get your key from https://agentoffice.dev

# Upload a document
doc = client.documents.create(
    file="document.docx",
    return_markdown=True
)
print(f"Uploaded: {doc.doc_id}")

# Edit the document
edit = client.edit(
    doc_id=doc.doc_id,
    edit_uid=str(uuid4()),
    edit_instructions="Change the title to 'My New Title'",
    tracked_changes=False
)
print(f"Edit applied: {edit.edit_applied}")

# Download the edited document
result = client.documents.download(doc_id=doc.doc_id)
print(f"Download URL: {result.download_url}")

# You can then download the file using requests
import requests
response = requests.get(result.download_url)
with open(f"edited_{doc.name}", "wb") as f:
    f.write(response.content)

Features

  • 📝 Upload and convert documents (DOCX, PDF, etc.)
  • ✏️ AI-powered document editing
  • 📖 Read document content as Markdown
  • 💾 Download edited documents
  • 🔄 Track changes support

API Reference

Client Initialization

client = AgentOffice(
    api_key="sk_ao_your_api_key",  # Required: Your API key
    base_url="https://api.agentoffice.dev",  # Optional: API base URL
    timeout=60  # Optional: Request timeout in seconds
)

Documents

Create Document

doc = client.documents.create(
    file="path/to/document.docx",  # File path or file-like object
    return_markdown=True,  # Return markdown content
    ttl_seconds=3600  # Time to live in seconds (300-21600)
)

Create Document from URL

doc = client.documents.create_from_url(
    file_url="https://example.com/document.docx",
    ttl_seconds=3600
)

List Documents

docs = client.documents.list()
for doc in docs.documents:
    print(f"{doc.name}: {doc.doc_id}")

Download Document

result = client.documents.download(
    doc_id="doc-id",
    expires_in=3600  # Presigned URL expiration in seconds
)
print(result.download_url)

Check Document Exists

result = client.documents.exists(doc_id="doc-id")
if result.exists:
    print(f"Document exists: {result.document.name}")

Edit Document

edit = client.edit(
    doc_id="doc-id",
    edit_uid=str(uuid4()),  # Unique identifier for the edit
    edit_instructions="Change the title to 'My New Title'",  # Natural language instructions
    lookup_text="Section 1",  # Optional: Text to locate edit position
    tracked_changes=False,  # Enable track changes
    use_large_model=False  # Use larger AI model
)

Read Document

result = client.read(doc_id="doc-id")
print(result.markdown)

Error Handling

The SDK provides specific exception types for different error conditions:

from agent_office import (
    AgentOffice,
    AgentOfficeError,
    AuthenticationError,
    NotFoundError,
    ValidationError,
    RateLimitError,
    ServerError,
)

client = AgentOffice(api_key="sk_ao_your_api_key")

try:
    doc = client.documents.create("document.docx")
except AuthenticationError:
    print("Invalid API key")
except NotFoundError:
    print("Document not found")
except ValidationError as e:
    print(f"Validation error: {e.message}")
except RateLimitError:
    print("Rate limit exceeded")
except ServerError:
    print("Server error")
except AgentOfficeError as e:
    print(f"General error: {e.message}")

Development

Install from source

git clone https://github.com/agentoffice/python-sdk.git
cd python-sdk
pip install -e .

Install development dependencies

pip install -e ".[dev]"

License

MIT

Support

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.0.420 Oct 20255

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
agentoffice/python-sdk

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 22:48 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:603bf0b96ebb1fd63c7a53a5e05a83fd5c412f409408bea2de2ba8fa71b43f11