A new package is designed to facilitate structured evaluation of a system's performance comparison between optimistic and pessimistic approaches. It takes a textual description or data snippet as inpu
Project description
Optimistic‑Pessimistic Evaluator
A lightweight Python package that lets you compare optimistic and pessimistic validation strategies for any textual description or data snippet.
It builds structured prompts, queries a language model, matches the response against a strict regex pattern, and returns a clear, machine‑readable report indicating which approach performs better based on your criteria.
Installation
pip install optimistic_pessimistic_evaluator
Quick Start
from optimistic_pessimistic_evaluator import optimistic_pessimistic_evaluator
user_input = """
A user uploads a file. The system checks the file size and type.
We want to know whether an optimistic (early‑exit) or a pessimistic (full‑check) approach is more efficient.
"""
# Use the default LLM7 instance (you need an API key in LLM7_API_KEY env var)
report = optimistic_pessimistic_evaluator(user_input)
print(report)
Parameters
| Parameter | Type | Description |
|---|---|---|
user_input |
str |
The text to be evaluated. |
llm (optional) |
BaseChatModel |
Any LangChain‑compatible chat model. If omitted, the package creates a ChatLLM7 instance automatically. |
api_key (optional) |
str |
API key for LLM7. If not supplied, the function reads LLM7_API_KEY from the environment. |
Using a Custom LLM
You can pass any LangChain chat model (OpenAI, Anthropic, Google, …). Example with OpenAI:
from langchain_openai import ChatOpenAI
from optimistic_pessimistic_evaluator import optimistic_pessimistic_evaluator
my_llm = ChatOpenAI(model="gpt-4o-mini")
report = optimistic_pessimistic_evaluator(user_input, llm=my_llm)
Anthropic:
from langchain_anthropic import ChatAnthropic
from optimistic_pessimistic_evaluator import optimistic_pessimistic_evaluator
my_llm = ChatAnthropic()
report = optimistic_pessimistic_evaluator(user_input, llm=my_llm)
Google Gemini:
from langchain_google_genai import ChatGoogleGenerativeAI
from optimistic_pessimistic_evaluator import optimistic_pessimistic_evaluator
my_llm = ChatGoogleGenerativeAI(model="gemini-1.5-flash")
report = optimistic_pessimistic_evaluator(user_input, llm=my_llm)
Default LLM (LLM7)
If you do not provide a custom model, the function uses ChatLLM7 from the langchain_llm7 package:
from langchain_llm7 import ChatLLM7
The free tier of LLM7 offers generous rate limits for typical evaluation workloads.
To use a custom key:
report = optimistic_pessimistic_evaluator(user_input, api_key="YOUR_LLM7_API_KEY")
You can obtain a free API key by signing up at https://token.llm7.io/.
Output
The function returns a List[str] containing the extracted data that matches the predefined regex pattern, e.g.:
[
"Optimistic approach is faster for low‑traffic scenarios.",
"Pessimistic approach provides higher reliability under load."
]
If the LLM call fails or the output does not match the pattern, a RuntimeError is raised with the underlying error message.
Contributing
Contributions are welcome! Feel free to open a pull request or submit an issue.
Issues & Support
Report bugs or request features here: https://github.com/chigwell/optimistic-pessimistic-evaluator/issues
Author
Eugene Evstafev – hi@eugene.plus
GitHub: chigwell
License
This project is licensed under the MIT License.
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 optimistic_pessimistic_evaluator-2025.12.21151045.tar.gz.
File metadata
- Download URL: optimistic_pessimistic_evaluator-2025.12.21151045.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a3caef034da9cd50a37911adc13c894cbec2c23230b0b8a9fc6d8b998f49950
|
|
| MD5 |
8e1fa2690fba2cb7c5eb8a5c0bb774aa
|
|
| BLAKE2b-256 |
e0d2f41500bdea14c79783c6fca0568ae2cfb5bee4dbdc7eb3e39068adc5ece9
|
File details
Details for the file optimistic_pessimistic_evaluator-2025.12.21151045-py3-none-any.whl.
File metadata
- Download URL: optimistic_pessimistic_evaluator-2025.12.21151045-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d5945c9d92821344936b885384621f8322d7711e58523998256b4ff47cebbd5
|
|
| MD5 |
7bb23b5c5806b0e56616a07622d94f8f
|
|
| BLAKE2b-256 |
f816b5ea32cd0b4482f2812de62d95ed8fe3e2583ef74afdd9e4842fc0cfea06
|