Metadata-Version: 2.4
Name: miadi
Version: 0.2.0
Summary: Miadi Platform Wrapper
Project-URL: Homepage, https://github.com/jgwill/Miadi
Project-URL: Issues, https://github.com/jgwill/Miadi/issues
Author-email: Guillaume Isabelle <jgi@jgwill.com>
License-Expression: MIT
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8
Requires-Dist: ironsilk
Requires-Dist: miadi-webweave
Provides-Extra: langchain
Requires-Dist: anthropic>=2; extra == 'langchain'
Requires-Dist: langchain-anthropic>=1.7; extra == 'langchain'
Provides-Extra: llm
Requires-Dist: anthropic>=2; extra == 'llm'
Provides-Extra: test
Requires-Dist: pytest>=7; extra == 'test'
Description-Content-Type: text/markdown

# Miadi

Miadi is a narrative computing hub for distributed systems. This package serves as the primary wrapper for the Miadi platform.

## Status

This package is currently a placeholder and wrapper for the broader Miadi platform components.

## Installation

```bash
pip install miadi
```

## Usage

```bash
miadi --help
```

## `miadi.llm`: Claude through the Langfuse AI Gateway

The gateway holds the Anthropic key and records every call as a Langfuse trace. A caller needs a
gateway key and host:

```bash
pip install 'miadi[llm]'          # 'miadi[langchain]' adds ChatAnthropic
export LANGFUSE_GATEWAY_HOST=https://gateway.cloud.langfuse.com
export LANGFUSE_GATEWAY_KEY=...   # a gateway key
python -m miadi.llm models        # model ids the key can call
python -m miadi.llm ping          # one short call to claude-haiku-5-5, prints the trace id
```

```python
from miadi.llm import TraceContext, create_message, chat_model

answer = create_message(
    trace=TraceContext(trace_name="chapter-draft", session_id="story-42", tags="storytelling,draft"),
    model="claude-haiku-5-5",
    max_tokens=2048,
    messages=[{"role": "user", "content": "Open a story about a weaver."}],
)
print(answer.message.content[0].text, answer.trace_address)  # miadi-tracing:eng/trace/<id>

llm = chat_model("claude-haiku-5-5", trace=TraceContext(trace_name="storytelling"))  # LangChain
```

Trace labels (`trace_name`, `session_id`, `tags`, `metadata`, `environment`, `user_id`) become the
gateway's `langfuse-*` request headers. A bare model id is sent as `anthropic:<id>`. Specification:
`packages/miadi/rispecs/llm-gateway/` in [jgwill/Miadi](https://github.com/jgwill/Miadi).
