Maniac Python Client
A minimal python client for Maniac's API. Supports chat completions and dataset uploads.
Installation
pip install maniac
Example Usage
from __future__ import annotations
import asyncio
from maniac import Maniac
async def main() -> None:
client = Maniac() # or Maniac({"apiKey": os.environ["MANIAC_API_KEY"]})
try:
# Run inference without a container
# Using kwargs
standard_response = await client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "Tell me a story about france"}],
)
print(standard_response["choices"][0]["message"]["content"]) # type: ignore[index]
# Create a container to collect telemetry
container = await client.containers.create(
label="local-test",
initial_model="openai/gpt-4o-mini",
initial_system_prompt="You are a helpful assistant that answers questions and discusses travel topics.",
)
container_response = await client.chat.completions.create(
container=container,
messages=[{"role": "user", "content": "Tell me a story about france"}],
)
print(container_response["choices"][0]["message"]["content"]) # type: ignore[index]
# Stream responses as async iterable
gen = await client.chat.completions.stream(
container=container,
messages=[{"role": "user", "content": "Tell me a story about france"}],
)
async for chunk in gen: # type: ignore[union-attr]
piece = (
(chunk.get("choices") or [{}])[0].get("delta", {}).get("content", "")
)
if piece:
print(piece, end="", flush=True)
print()
# Stream responses with callback
async def on_chunk(chunk) -> None:
piece = (
(chunk.get("choices") or [{}])[0].get("delta", {}).get("content", "")
)
if piece:
print(piece, end="", flush=True)
await client.chat.completions.stream(
{"container": container, "messages": [{"role": "user", "content": "Tell me a story about france"}]},
on_chunk,
)
# Get a container by label and run a completion
travel_agent = await client.containers.get("local-test")
email_resp = await client.chat.completions.create(
container=travel_agent,
messages=[{"role": "user", "content": "Tell me a story about france"}],
)
print(email_resp["choices"][0]["message"]["content"]) # type: ignore[index]
# Models list / retrieve
models = await client.models.list()
print([m["id"] for m in models.get("data", [])])
model = await client.models.retrieve("openai/gpt-4o-mini")
print(model)
finally:
await client.aclose()
if __name__ == "__main__":
asyncio.run(main())
Metadata
Release files for maniac 0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| maniac-0.tar.gz | 22.0 kB | Without provenance | Details for maniac-0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| maniac-0-py3-none-any.whl | Python 3 | none | any | Details for maniac-0-py3-none-any.whl |
Total release size: 44.6 kB
Release files / maniac-0.tar.gz
| Download URL | maniac-0.tar.gz |
|---|---|
| Size | 22.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
812cf21b24865a3b5b5ff18a7e1019802174de8d4b8d79462ebd348b904d071f
|
|
BLAKE2b-256 checksum How to use checksums |
285faf5e22e351e6d1de19f9daaf0f2341043f5ee8f0bd1e5592afe41b6e2d58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / maniac-0-py3-none-any.whl
| Download URL | maniac-0-py3-none-any.whl |
|---|---|
| Size | 22.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cb3f475d1fd8a64ac07364fa9ab9198d25d8fe2793e016e918f93de043963726
|
|
BLAKE2b-256 checksum How to use checksums |
0465d30814aa95efb80fcbdea46717743bf7fe4a33aa3f7ad46504bf7248af32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for maniac 0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.