Metadata-Version: 2.4
Name: artasupport
Version: 0.1.0
Summary: Python SDK for ArtaSupport TSE copilot and batch APIs.
Author: ArtaSupport
License: MIT License
        
        Copyright (c) 2026 ArtaSupport
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://artasupport.com
Project-URL: Documentation, https://artasupport.com
Project-URL: Issues, https://artasupport.com
Keywords: sdk,api,copilot,batch,ingest,artasupport
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
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: Operating System :: OS Independent
Classifier: License :: OSI Approved :: MIT License
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: <4,>=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx<1.0.0,>=0.28.0
Dynamic: license-file

# artasupport Python SDK

`artasupport` is a Python SDK for ArtaSupport TSE APIs (`copilot` and `batch`).

## Requirements

- Python `3.10+`
- An API key (`arta_live_...`)
- Backend base URL (`http://localhost:8000` or your deployed URL)

## Install

```bash
pip install artasupport
```

Local development install:

```bash
pip install -e .
```

## Environment setup

```bash
export ARTASUPPORT_API_KEY="arta_live_...<secret>"
export ARTASUPPORT_BASE_URL="http://localhost:8000"
```

You can also pass `api_key=` and `base_url=` directly in code.

## How it works

Each SDK call:
1. Builds auth headers (`x-api-key` + Bearer)
2. Sends request to backend (`/api/tse`, `/v1/models`, `/v1/sessions`, `/api/ingest`)
3. Parses typed response (`text`, `session_id`, `usage`, `next_steps`, etc.)
4. Raises typed exceptions for API/network/config errors

## Usage mode 1: Quick one-shot calls

Use top-level helper functions for simple scripts.

```python
from artasupport import tse_copilot, tse_batch

resp = tse_copilot(user_input="internet is slow")
print(resp.text)

resp2 = tse_batch(text="summarize tunnel issue")
print(resp2.text)
```

## Usage mode 2: Sync conversation with context

Use `ArtaSupportMessage` when you want multi-turn chat.
Conversation context is tied to `session_id`.

```python
from artasupport import ArtaSupportMessage

with ArtaSupportMessage() as client:
    sid = client.create_session().session_id

    r1 = client.tse_copilot(user_input="internet is slow", session_id=sid)
    r2 = client.tse_copilot(user_input="only one location affected", session_id=sid)

    print(r1.text)
    print(r2.text)

    # optional cleanup
    client.delete_session(sid)
```

## Usage mode 3: Async conversation

Use `AsyncArtaSupportMessage` in async apps.

```python
import asyncio
from artasupport import AsyncArtaSupportMessage

async def main():
    async with AsyncArtaSupportMessage() as client:
        sid = (await client.create_session()).session_id
        r = await client.tse_batch(user_input="summarize issue", session_id=sid)
        print(r.text)

asyncio.run(main())
```

`AsyncArtaSupportMessage` is non-blocking async I/O, not token streaming.

## Usage mode 4: File ingestion

Upload PDF or Excel files for runbook extraction and cases ingestion.

```python
from artasupport import tse_ingest

# Quick one-shot upload
response = tse_ingest("runbook.pdf")
print(response.status)  # "completed" or "processing"

# With explicit client
from artasupport import ArtaSupportMessage

with ArtaSupportMessage() as client:
    response = client.tse_ingest("cases.xlsx")
    print(f"Ingestion {response.status}")
```

Async version:

```python
import asyncio
from artasupport import AsyncArtaSupportMessage

async def upload_file():
    async with AsyncArtaSupportMessage() as client:
        response = await client.tse_ingest("runbook.pdf")
        print(f"Status: {response.status}")

asyncio.run(upload_file())
```

Supported file types: `.pdf`, `.xlsx`, `.xls`
Folders are not supported; `tse_ingest(...)` expects a single file path.

## Input styles

For `tse_copilot(...)` and `tse_batch(...)`, provide exactly one of:
- `user_input="..."`
- `text="..."`
- `message="..."`
- `messages=[{"role": "user", "content": "..."}]`

## Error handling

```python
from artasupport import (
    ArtaSupportMessage,
    APIError,
    AuthenticationError,
    RateLimitError,
)

try:
    with ArtaSupportMessage() as client:
        resp = client.tse_copilot(user_input="help", session_id="sess_...")
except AuthenticationError as exc:
    print("Invalid/revoked API key:", exc)
except RateLimitError as exc:
    print("Rate limited:", exc)
except APIError as exc:
    print("API failure:", exc.status_code, exc.request_id, exc.message)
```

## API surface

- Top-level helpers:
  - `tse_copilot(...)`
  - `tse_batch(...)`
  - `tse_ingest(file_path)`
- Sync client:
  - `ArtaSupportMessage`
  - `list_models()`, `create_session()`, `delete_session()`
  - `tse_copilot(...)`, `tse_batch(...)`, `tse_ingest(file_path)`
- Async client:
  - `AsyncArtaSupportMessage`
  - `await list_models()`, `await create_session()`, `await delete_session()`
  - `await tse_copilot(...)`, `await tse_batch(...)`, `await tse_ingest(file_path)`
