Metadata-Version: 2.4
Name: data-ai-sdk
Version: 0.2.0
Summary: Python SDK for AI Agents - Semantic Intelligence for AI builders
Project-URL: Homepage, https://open-metadata.org
Project-URL: Documentation, https://docs.open-metadata.org/sdk
Project-URL: Repository, https://github.com/open-metadata/ai-sdk
Author-email: Collate <dev@getcollate.io>
License:                        Collate Community License Agreement
                                        Version 1.0
        
        This Collate Community License Agreement Version 1.0 (the “Agreement”) sets
        forth the terms on which Collate, Inc. (“Collate”) makes available certain
        software made available by Collate under this Agreement (the “Software”).  BY
        INSTALLING, DOWNLOADING, ACCESSING, USING OR DISTRIBUTING ANY OF THE SOFTWARE,
        YOU AGREE TO THE TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE TO
        SUCH TERMS AND CONDITIONS, YOU MUST NOT USE THE SOFTWARE.  IF YOU ARE RECEIVING
        THE SOFTWARE ON BEHALF OF A LEGAL ENTITY, YOU REPRESENT AND WARRANT THAT YOU
        HAVE THE ACTUAL AUTHORITY TO AGREE TO THE TERMS AND CONDITIONS OF THIS
        AGREEMENT ON BEHALF OF SUCH ENTITY.  “Licensee” means you, an individual, or
        the entity on whose behalf you are receiving the Software.
        
           1. LICENSE GRANT AND CONDITIONS.
        
              1.1 License.  Subject to the terms and conditions of this Agreement,
              Collate hereby grants to Licensee a non-exclusive, royalty-free,
              worldwide, non-transferable, non-sublicenseable license during the term
              of this Agreement to: (a) use the Software; (b) prepare modifications and
              derivative works of the Software; (c) distribute the Software (including
              without limitation in source code or object code form); and (d) reproduce
              copies of the Software (the “License”).  Licensee is not granted the
              right to, and Licensee shall not, exercise the License for an Excluded
              Purpose.  For purposes of this Agreement, “Excluded Purpose” means making
              available any software-as-a-service, platform-as-a-service,
              infrastructure-as-a-service or other similar online service that competes
              with Collate products or services that provide the Software.
        
              1.2 Conditions.  In consideration of the License, Licensee’s distribution
              of the Software is subject to the following conditions:
        
                 (a) Licensee must cause any Software modified by Licensee to carry
                 prominent notices stating that Licensee modified the Software.
        
                 (b) On each Software copy, Licensee shall reproduce and not remove or
                 alter all Collate or third party copyright or other proprietary
                 notices contained in the Software, and Licensee must provide the
                 notice below with each copy.
        
                    “This software is made available by Collate, Inc., under the
                    terms of the Collate Community License Agreement, Version 1.0
                    located at http://www.getcollate.io/collate-community-license.  BY
                    INSTALLING, DOWNLOADING, ACCESSING, USING OR DISTRIBUTING ANY OF
                    THE SOFTWARE, YOU AGREE TO THE TERMS OF SUCH LICENSE AGREEMENT.”
        
              1.3 Licensee Modifications.  Licensee may add its own copyright notices
              to modifications made by Licensee and may provide additional or different
              license terms and conditions for use, reproduction, or distribution of
              Licensee’s modifications.  While redistributing the Software or
              modifications thereof, Licensee may choose to offer, for a fee or free of
              charge, support, warranty, indemnity, or other obligations. Licensee, and
              not Collate, will be responsible for any such obligations.
        
              1.4 No Sublicensing.  The License does not include the right to
              sublicense the Software, however, each recipient to which Licensee
              provides the Software may exercise the Licenses so long as such recipient
              agrees to the terms and conditions of this Agreement.
        
           2. TERM AND TERMINATION.  This Agreement will continue unless and until
           earlier terminated as set forth herein.  If Licensee breaches any of its
           conditions or obligations under this Agreement, this Agreement will
           terminate automatically and the License will terminate automatically and
           permanently.
        
           3. INTELLECTUAL PROPERTY.  As between the parties, Collate will retain all
           right, title, and interest in the Software, and all intellectual property
           rights therein.  Collate hereby reserves all rights not expressly granted
           to Licensee in this Agreement.  Collate hereby reserves all rights in its
           trademarks and service marks, and no licenses therein are granted in this
           Agreement.
        
           4. DISCLAIMER.  COLLATE HEREBY DISCLAIMS ANY AND ALL WARRANTIES AND
           CONDITIONS, EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, AND SPECIFICALLY
           DISCLAIMS ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
           PURPOSE, WITH RESPECT TO THE SOFTWARE.
        
           5. LIMITATION OF LIABILITY.  COLLATE WILL NOT BE LIABLE FOR ANY DAMAGES OF
           ANY KIND, INCLUDING BUT NOT LIMITED TO, LOST PROFITS OR ANY CONSEQUENTIAL,
           SPECIAL, INCIDENTAL, INDIRECT, OR DIRECT DAMAGES, HOWEVER CAUSED AND ON ANY
           THEORY OF LIABILITY, ARISING OUT OF THIS AGREEMENT.  THE FOREGOING SHALL
           APPLY TO THE EXTENT PERMITTED BY APPLICABLE LAW.
        
           6.GENERAL.
        
              6.1 Governing Law. This Agreement will be governed by and interpreted in
              accordance with the laws of the state of California, without reference to
              its conflict of laws principles.  If Licensee is located within the
              United States, all disputes arising out of this Agreement are subject to
              the exclusive jurisdiction of courts located in Santa Clara County,
              California. USA.  If Licensee is located outside of the United States,
              any dispute, controversy or claim arising out of or relating to this
              Agreement will be referred to and finally determined by arbitration in
              accordance with the JAMS International Arbitration Rules.  The tribunal
              will consist of one arbitrator.  The place of arbitration will be Palo
              Alto, California. The language to be used in the arbitral proceedings
              will be English.  Judgment upon the award rendered by the arbitrator may
              be entered in any court having jurisdiction thereof.
        
              6.2 Assignment.  Licensee is not authorized to assign its rights under
              this Agreement to any third party. Collate may freely assign its rights
              under this Agreement to any third party.
        
              6.3 Other.  This Agreement is the entire agreement between the parties
              regarding the subject matter hereof.  No amendment or modification of
              this Agreement will be valid or binding upon the parties unless made in
              writing and signed by the duly authorized representatives of both
              parties.  In the event that any provision, including without limitation
              any condition, of this Agreement is held to be unenforceable, this
              Agreement and all licenses and rights granted hereunder will immediately
              terminate.  Waiver by Collate of a breach of any provision of this
              Agreement or the failure by Collate to exercise any right hereunder
              will not be construed as a waiver of any subsequent breach of that right
              or as a waiver of any other right.
License-File: LICENSE
Keywords: agents,ai,langchain,llm,metadata,openmetadata,semantic
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Requires-Dist: httpx>=0.25.0
Requires-Dist: pydantic>=2.0.0
Provides-Extra: all
Requires-Dist: datamodel-code-generator>=0.25.0; extra == 'all'
Requires-Dist: langchain-core>=0.1.0; extra == 'all'
Requires-Dist: langchain-openai>=0.1.0; extra == 'all'
Requires-Dist: langchain>=0.1.0; extra == 'all'
Requires-Dist: pytest-asyncio>=0.21; extra == 'all'
Requires-Dist: pytest-httpx>=0.30; extra == 'all'
Requires-Dist: pytest>=7.0; extra == 'all'
Requires-Dist: ruff>=0.8.0; extra == 'all'
Requires-Dist: ty>=0.0.1a7; extra == 'all'
Provides-Extra: dev
Requires-Dist: datamodel-code-generator>=0.25.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
Requires-Dist: pytest-httpx>=0.30; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.8.0; extra == 'dev'
Requires-Dist: ty>=0.0.1a7; extra == 'dev'
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.1.0; extra == 'langchain'
Requires-Dist: langchain-openai>=0.1.0; extra == 'langchain'
Requires-Dist: langchain>=0.1.0; extra == 'langchain'
Description-Content-Type: text/markdown

# AI SDK for Python

Python SDK for invoking [Metadata](https://open-metadata.org) Dynamic Agents from your AI applications.

## Installation

```bash
pip install data-ai-sdk
```

With LangChain integration:

```bash
pip install data-ai-sdk[langchain]
```

## Quick Start

```python
from ai_sdk import AISdk

client = AISdk(
    host="https://your-metadata-instance.com",
    token="your-bot-jwt-token"
)

# default AskCollate agent
response = client.agent().call("What data quality tests should I add for the customers table?")
print(response.response)

# Named dynamic agent
response = client.agent("DataQualityPlannerAgent").call(
    "What data quality tests should I add for the customers table?"
)
print(response.response)
```

## Streaming

```python
for event in client.agent("DataQualityPlannerAgent").stream("Analyze the customers table"):
    if event.event_type == "message":
        print(event.content, end="", flush=True)
```

## Async Support

```python
import asyncio
from ai_sdk import AISdk

async def main():
    client = AISdk(
        host="https://your-metadata-instance.com",
        token="your-bot-jwt-token",
        enable_async=True,
    )
    response = await client.agent("DataQualityPlannerAgent").acall(
        "Analyze the customers table"
    )
    print(response.response)

asyncio.run(main())
```

## Context Memories

The `client.memories` namespace manages reusable Context Center knowledge — preferences, use cases, runbooks, and FAQs that any AI agent can read.

```python
from ai_sdk import (
    AISdk,
    CreateContextMemoryRequest,
    EntityReference,
    MemoryType,
    MemoryVisibility,
)

# Create
created = client.memories.create(CreateContextMemoryRequest(
    name="orders-grain",
    title="Orders grain",
    question="What is the grain of the orders table?",
    answer="One row per order_id.",
    memory_type=MemoryType.NOTE,             # Preference | UseCase | Note | Runbook | Faq
    visibility=MemoryVisibility.SHARED,      # Private | Entity | Shared
    primary_entity=EntityReference(id="<table-uuid>", type="table"),
    tags=["Domain.Analytics"],
))

# Get / list (filter by entity FQN, optional limit)
client.memories.get(created.id)
client.memories.list(primary_entity_fqn="prod.warehouse.orders", limit=50)

# Hybrid NLQ search — combines vector + keyword ranking over the contextMemory index.
# Optional filters scope the search by indexed fields.
results = client.memories.search(
    "how do we measure order volume",
    filters={"visibility": ["Entity", "Shared"]},
    size=10,
    from_=0,
)
for hit in results.hits:
    print(f"[{hit.score:.2f}] {hit.memory.title}: {hit.memory.answer}")

# Soft delete by default; pass hard_delete=True to remove permanently
client.memories.delete(created.id)
client.memories.delete(created.id, hard_delete=True)
```

### Async

Every method has an `aXxx` counterpart when the client is constructed with `enable_async=True`:

```python
client = AISdk(host=..., token=..., enable_async=True)

await client.memories.acreate(req)
await client.memories.alist(primary_entity_fqn="prod.warehouse.orders")
await client.memories.aget(memory_id)
await client.memories.asearch("explain customer churn")
await client.memories.adelete(memory_id)
```

### What's stored

| Field | Notes |
|-------|-------|
| `name` | Stable system name (required) |
| `question` / `answer` | Canonical Q/A pair (required) — what an agent retrieves |
| `title`, `description`, `summary` | Human-facing text, optional |
| `memory_type` | `Preference`, `UseCase`, `Note`, `Runbook`, or `Faq` |
| `memory_scope` | `EntityScoped` (default) or `UserGlobal` |
| `visibility` | `Private`, `Entity`, or `Shared` (controls who can read it) |
| `primary_entity` | Attaches the memory to a specific asset for entity-scoped recall |
| `tags` | List of tag FQN strings (e.g. `"PII.Sensitive"`) |

## MCP Tools

Access [Model Context Protocol](https://modelcontextprotocol.io/) tools from your Metadata instance:

```python
tools = client.mcp.list_tools()

result = client.mcp.call_tool(
    tool=MCPTool.SEARCH_ENTITIES,
    arguments={"query": "customers", "limit": 5},
)
```

## Documentation

- [Full SDK docs](https://docs.open-metadata.org/sdk)
- [Source & all SDKs](https://github.com/open-metadata/ai-sdk)

## License

Collate Community License 1.0
