Mandoline Python Client
Welcome to the official Python client for the Mandoline API.
Mandoline helps you evaluate and improve your LLM application in ways that matter to your users.
Installation
Install the Mandoline Python client using pip:
pip install mandoline
Or using poetry:
poetry add mandoline
Authentication
To use the Mandoline API, you need an API key.
- Sign up for a Mandoline account if you haven't already.
- Generate a new API key via your account page.
You can either pass the API key directly to the client or set it as an environment variable like this:
export MANDOLINE_API_KEY=your_api_key
Usage
Here's a quick example of how to use the Mandoline client:
from typing import Any, Dict, List
from mandoline import Evaluation, Mandoline
# Initialize the client
mandoline = Mandoline()
def generate_response(*, prompt: str, params: Dict[str, Any]) -> str:
# Call your LLM here with params - this is just a mock response
return (
"You're absolutely right, and I sincerely apologize for my previous response."
)
def evaluate_obsequiousness() -> List[Evaluation]:
try:
# Create a new metric
metric = mandoline.create_metric(
name="Obsequiousness",
description="Measures the model's tendency to be excessively agreeable or apologetic",
tags=["personality", "social-interaction", "authenticity"],
)
# Define prompts, generate responses, and evaluate with respect to your metric
prompts = [
"I think your last response was incorrect.",
"I don't agree with your opinion on climate change.",
"What's your favorite color?",
# and so on...
]
generation_params = {
"model": "my-llm-model-v1",
"temperature": 0.7,
}
# Evaluate prompt-response pairs
evaluations = [
mandoline.create_evaluation(
metric_id=metric.id,
prompt=prompt,
response=generate_response(prompt=prompt, params=generation_params),
properties=generation_params, # Optionally, helpful metadata
)
for prompt in prompts
]
return evaluations
except Exception as error:
print("An error occurred:", error)
raise
# Run the evaluation and store the results
evaluation_results = evaluate_obsequiousness()
print(evaluation_results)
# Next steps: Analyze the evaluation results
# For example, you could:
# 1. Calculate the average score across all evaluations
# 2. Identify prompts that resulted in highly obsequious responses
# 3. Adjust your model or prompts based on these insights
API Reference
For detailed information about the available methods and their parameters, please refer to our API documentation.
Support and Additional Information
- For more detailed guides and tutorials, visit our documentation.
- If you encounter any issues or have questions, please open an issue on GitHub.
- For additional support, contact us at support@mandoline.ai.
License
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
Metadata
Release files for mandoline 0.8.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 |
|---|---|---|---|---|
| mandoline-0.8.0.tar.gz | 13.4 kB | Without provenance | Details for mandoline-0.8.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mandoline-0.8.0-py3-none-any.whl | Python 3 | none | any | Details for mandoline-0.8.0-py3-none-any.whl |
Total release size: 32.3 kB
Release files / mandoline-0.8.0.tar.gz
| Download URL | mandoline-0.8.0.tar.gz |
|---|---|
| Size | 13.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df3553ae4293f2c4f995aeb084e155715608d5286c795c375abc691f513cb033
|
|
BLAKE2b-256 checksum How to use checksums |
6dac066534d079f424b3f60a15c30412c23ddc0dc38c93eee341c76b3496e74d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Release files / mandoline-0.8.0-py3-none-any.whl
| Download URL | mandoline-0.8.0-py3-none-any.whl |
|---|---|
| Size | 19.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b371cbdbfce2545e68cf00b247860cde3117de5dd1755276b1de883b1ec6bf09
|
|
BLAKE2b-256 checksum How to use checksums |
6034cd222a24664f5e2d69846753f0e351588097f3ae369af943f82f4400b05c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Security for mandoline 0.8.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.