Official Python client for the Mandoline API
Project description
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.
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
File details
Details for the file mandoline-0.1.2.tar.gz
.
File metadata
- Download URL: mandoline-0.1.2.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c17b028135950dd86627247c11aef5c26b4149ddf7efeb607f3c297945e5fcb |
|
MD5 | 7c21cb5811d38f68ce141955474cce03 |
|
BLAKE2b-256 | 0558bfe62de3403eb2918ddcfc83698b1145efd08a6718c162be4df9235d905f |
File details
Details for the file mandoline-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: mandoline-0.1.2-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62f9ca0dbd23aa4f6f9f74b928b5e332d8a7f7dab5b779f0b9b2a211a15b1fd8 |
|
MD5 | bfa7f5dea0fd3bef9185aa8e00299cea |
|
BLAKE2b-256 | acc11a1445670fc9418789e5334af592b25bbd697fb29c6a6fe078f2d47fbd7a |