Every frontier LLM. One unified interface.
Project description
Mirascope Python
This directory contains the Python implementation of Mirascope: The LLM Anti-Framework. It's intended as a "Goldilocks API" that affords the fine-grained control you'd get from using raw provider APIs, as well as the type safety and easy ergonomics that are offered by higher-level agent frameworks. Think of Mirascope as the "React" of LLM development, where provider native APIs are HTML/CSS, and the agent frameworks are Angular.
Documentation
Installation
# using uv, with all provider deps
uv add "mirascope[all]"
# using uv, with just Anthropic
uv add "mirascope[anthropic]"
# using pip, with all deps
pip install "mirascope[all]"
# using pip, just OpenAI
pip install "mirascope[openai]"
Usage
Here's an example of creating a simple agent, with tool-calling and streaming, using Mirascope. For many more examples, read the docs.
from mirascope import llm
@llm.tool
def exp(a: float, b: float) -> float:
"""Compute an exponent"""
return a ** b
@llm.tool
def add(a: float, b: float) -> float:
"""Add two numbers"""
return a + b
model = llm.Model("anthropic/claude-haiku-4-5")
response = model.stream("What is 42 ** 4 + 37 ** 3?", tools=[exp, add])
while True:
for stream in response.streams():
if stream.content_type == "text":
for delta in stream:
print(delta, end="", flush=True)
elif stream.content_type == "tool_call":
stream.collect() # consume the stream
print(f"\n> Calling {stream.tool_name}({stream.partial_args})")
print()
if response.tool_calls:
response = response.resume(response.execute_tools())
else:
break
Development Setup
-
Environment Variables: Copy
.env.exampleto.envand fill in your API keys:cp .env.example .env # Edit .env with your API keys # Necessary for updating e2e snapshot tests
-
Install Dependencies:
cd python uv sync --all-extras --dev
Helpful Commands:
Here are helpful development commands. All must be run from within the python directory.
uv run pyright .
Run typechecking.
uv run ruff check --fix .
Check ruff linter (fixing issues where possible).
uv run ruff format .
Run ruff formatter.
uv run pytest
Run all Python unit tests.
uv run pytest --cov --cov-config=.coverargc --cov-report=term-missing
Run all Python unit tests, and report code coverage. (We require 100% coverage in CI.)
uv run pytest --fix
Run all Python unit tests, and update any changed snapshots.
uvx codespell --config ../.codespellrc
Run codespell, identifying many common spelling mistakes.
Typechecking
We prize type safety, both on the API surface and internally. You can run typechecking via uv run pyright . within this python/ directory. (We're looking into supporting ty so as to speed up our typechecking.)
Testing
This project makes extensive use of e2e tests, which replay real interactions with various LLM providers to ensure that Mirascope truly works on the providers' APIs. We use VCR.py and inline-snapshot to maintain these e2e tests. For more details, read tests/e2e/README.md.
If you make changes to Mirascope that require new snapshots, you should manually delete the outdated cassette files, and then run uv run pytest python/tests/e2e --fix. Note that doing so requires real API keys in your .env file.
We require 100% code coverage in CI. You can get a code coverage report via:
uv run pytest --cov --cov-config=.coverargc --cov-report=term-missing
Read More
For more info on contributing, read the contributing page in our docs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mirascope-2.2.2.tar.gz.
File metadata
- Download URL: mirascope-2.2.2.tar.gz
- Upload date:
- Size: 3.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4cb3fa9a2243a963a32cbc5de04b70f50c263e239b1a6fb7c28a5a215a3f796
|
|
| MD5 |
82c41826e143453a1b6cd819d6acdaee
|
|
| BLAKE2b-256 |
34026dfb810e69144110daeaf3751121670be28c93a3ba2df982f334e47e4ae0
|
File details
Details for the file mirascope-2.2.2-py3-none-any.whl.
File metadata
- Download URL: mirascope-2.2.2-py3-none-any.whl
- Upload date:
- Size: 520.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea40dfed29bedc66a2673ebf39d99519b9cb60c56789ff4ffbec898ce57097a7
|
|
| MD5 |
7738272a7ac1e3ab69b8f9b8b9e42e12
|
|
| BLAKE2b-256 |
efc592e9401abc74a6229b99cfa65315de669bf212b905245ffe02c263113e00
|