Skip to main content

pydantic-ai-cosmosdb-persistence

Azure CosmosDB backend for pydantic-ai-persistence — a PydanticAI StepStore (durable events / snapshots / tool-effect ledger) and message-history store, on CosmosDB.

Install

pip install pydantic-ai-cosmosdb-persistence
# or:  pip install "pydantic-ai-persistence[cosmosdb]"

Usage

from pydantic_ai import Agent
from pydantic_ai_harness.step_persistence import StepPersistence
from pydantic_ai_cosmosdb_persistence import CosmosDBStepStore

store = CosmosDBStepStore(
    endpoint="https://<acct>.documents.azure.com:443/",
    key="<key>",
    database_name="pai",
    container_name="steps",
    max_snapshots_per_run=20,
)
agent = Agent("openai:gpt-4o", capabilities=[StepPersistence(store=store)])

CosmosDBHistoryStore(endpoint=…, key=…, database_name=…, container_name=…) provides save/load message history.

Data model

A container partitioned by /PK; each item is {id, PK, SK, data} (the id is a URL-encoded SK since Cosmos ids can't contain # / \ ?; the raw SK is a field for range queries). Database and container are auto-created (key-based auth).

Note: PydanticAI's StepStore is a beta/experimental harness feature.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_ai_cosmosdb_persistence-0.1.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file pydantic_ai_cosmosdb_persistence-0.1.0.tar.gz.

File metadata

File hashes

Hashes for pydantic_ai_cosmosdb_persistence-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5cdcc2866da9b88da42f8cd21e7d4e5e4438a24a9ed31b339699c76358e824d5
MD5 17afed4c87ad850f0771c2826c679a35
BLAKE2b-256 2f3f90b61fc316d980bb29afd7a652b20cb635e3cffa401845941053c79072d3

See more details on using hashes here.

File details

Details for the file pydantic_ai_cosmosdb_persistence-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_ai_cosmosdb_persistence-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9cecfbb74bfab335caa12d3eeb1f909f41e69044b81eb663a53728950568c505
MD5 49f38521e2305043d00a987150e5eaeb
BLAKE2b-256 ac98a11a941f2f698d14f510d1aaba6103df02e4600896e74f5a690275cbee44

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page