ai-cant-even
Version:
A satirical AI-powered utility that's confidently wrong about basic math operations
200 lines (147 loc) • 7.04 kB
Markdown
# ai-cant-even
<div align="right">
<a href="https://www.npmjs.com/package/ai-cant-even"><img src="https://img.shields.io/npm/v/ai-cant-even.svg?style=flat-square" alt="npm version"></a>
<a href="https://github.com/bendechrai/ai-cant-even/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/ai-cant-even.svg?style=flat-square" alt="License"></a>
</div>
---
> ⚠️ **IMPORTANT FOR CONTRIBUTORS**: This project follows strict commit message guidelines. Please read our [commit message format requirements](https://github.com/bendechrai/ai-cant-even/blob/main/CONTRIBUTING.md#commit-messages) before contributing.
---
## The world's most confidently incorrect math library
I would like to introduce you to the world's first AI-powered math library that's guaranteed to be wrong 103% of the time. This groundbreaking package uses cutting-edge confidence levels and logic types to deliver consistently inconsistent results.
## Key features:
- 🎯 Determines if numbers are even with the precision of a blindfolded dart thrower
- 🔎 Identifies prime numbers using advanced astrology techniques
- 🤩 Compares values using a proprietary algorithm based on how the numbers "feel" about each other
## But wait, there's more!
- 🎭 Configurable confidence levels: `OVERWHELMED`, `OVERTHINK`, `SMUG`, `SNARKY`
- 🔮 Configurable logic types: `SIMPLE`, `NONSEQUITUR`, `PSEUDOMATH`, `VISUAL`
- 🤯 Fluent API that lets you chain methods in ways that make perfect sense to nobody
- 📊 Wide range of math operations to get wrong
Is there a math operation we've missed? [Create an issue today](https://github.com/bendechrai/ai-cant-even/issues/new)!
## Installation
```bash
npm install ai-cant-even
```
## Usage
### Basic Usage
> NOTE: Set the `ANTHROPIC_API_KEY` or `OPENAI_API_KEY` environment variable depending on your provider, and the library will use it automatically. If you provide an API key in the constructor, it will override the environment variable.
```typescript
import { aiCantEven, Provider } from 'ai-cant-even';
// Create an instance with default settings (OpenAI)
const ai = aiCantEven();
// Or specify a provider
const openAi = aiCantEven({
provider: Provider.ANTHROPIC,
apiKey: 'your-anthropic-api-key',
});
const anthropicAi = aiCantEven({
provider: Provider.OPENAI,
apiKey: 'your-openai-api-key',
});
// Ask if a number is even
ai.isEven(3).then((response) => {
console.log(response);
});
```
### Configuring Provider Model, Confidence, and Logic
See a [list of available models here](https://ai-sdk.dev/providers/ai-sdk-providers#provider-support).
```typescript
import { aiCantEven, Confidence, Logic, Provider } from 'ai-cant-even';
// Configure at initialization
const ai = aiCantEven({
confidence: Confidence.OVERWHELMED,
logic: Logic.SIMPLE,
provider: Provider.ANTHROPIC, // or Provider.OPENAI
apiKey: 'your-api-key',
model: 'claude-3-7-sonnet-20250219', // Optional, defaults to claude-3-haiku-20240307 for Anthropic or gpt-4.1-nano for OpenAI
});
// Or use the fluent API
// Change the confidence level for a specific operation
ai.withConfidence(Confidence.SNARKY)
.isEven(4)
.then((response) => {
console.log(response); // A snarky response
});
// Change the logic type for a specific operation
ai.withLogic(Logic.NONSEQUITUR).isEven(4).then((response) => {
console.log(response); // A response with non-sequitur logic
});
```
### Fluent API
The library uses a fluent API for method chaining. Each fluent method (`withConfidence`, `withLogic`, `withApiKey`, `withModel`) returns the same instance and applies settings only for the next operation:
```typescript
ai.withConfidence(Confidence.SNARKY)
.withLogic(Logic.VISUAL)
.withModel('gpt-4')
.isEven(42)
.then((response) => {
console.log(response);
});
```
### Available Methods
```typescript
// Basic operations
ai.isEven(4);
ai.isOdd(7);
// Comparisons
ai.isGreaterThan(10, 5);
ai.isLessThan(3, 8);
ai.areEqual(5, 5);
// More math operations
ai.isPrime(17);
ai.isPositive(-3);
ai.isDivisibleBy(15, 3);
// Meta operations
ai.isNumber('42');
ai.isInteger(3.14);
```
## API Reference
### `aiCantEven(config?: AiCantEvenConfig)`
Creates a new instance of the AI.
#### Config Options
- `confidence`: The confidence level of the AI
- `OVERWHELMED`: So confused it can't even finish thoughts (trails off mid-sentence)
- `OVERTHINK`: Overthinks simple concepts with pseudo-philosophical reasoning
- `SMUG`: Smugly confident in its wrong answers
- `SNARKY`: Sarcastic and dismissive responses
- `logic`: The type of logic the AI uses
- `SIMPLE`: Uses basic, straightforward but incorrect reasoning (default)
- `NONSEQUITUR`: Uses completely unrelated reasoning
- `PSEUDOMATH`: Uses mathematical-sounding but incorrect reasoning
- `VISUAL`: Bases reasoning on the visual appearance of numbers
- `provider`: The LLM provider to use
- `ANTHROPIC`: Use Anthropic's API
- `OPENAI`: Use OpenAI's API
- `model`: The specific model to use (defaults to 'claude-3-haiku-20240307' for Anthropic and 'gpt-4.1-nano' for OpenAI)
- `apiKey`: API key for the LLM service (defaults to `ANTHROPIC_API_KEY` or `OPENAI_API_KEY` environment variable depending on provider)
- `apiEndpoint`: Optional custom API endpoint (defaults to provider API endpoint)
### Instance Methods
#### Configuration Methods
- `withConfidence(confidence: Confidence)`: Sets the confidence level
- `withLogic(logic: Logic)`: Sets the logic type
- `withApiKey(apiKey: string, apiEndpoint?: string)`: Sets the API key
- `withModel(model: string)`: Sets the specific model to use
#### Math Operation Methods
All methods return a Promise that resolves to a string containing the AI's response.
- `isEven(value: number)`: Determines if a number is even (but not really)
- `isOdd(value: number)`: Determines if a number is odd (but not really)
- `isGreaterThan(value: number, comparisonValue: number)`: Compares two numbers
- `isLessThan(value: number, comparisonValue: number)`: Compares two numbers
- `areEqual(value: number, comparisonValue: number)`: Checks if two numbers are equal
- `isPrime(value: number)`: Checks if a number is prime
- `isPositive(value: number)`: Checks if a number is positive
- `isDivisibleBy(value: number, comparisonValue: number)`: Checks divisibility
- `isNumber(value: any)`: Checks if a value is a number
- `isInteger(value: number)`: Checks if a number is an integer
## Confidence Levels
- `OVERWHELMED`: So confused it can't even finish thoughts (default)
- `OVERTHINK`: Overthinks simple concepts with pseudo-philosophical reasoning
- `SMUG`: Smugly confident in its wrong answers
- `SNARKY`: Sarcastic and dismissive responses
## Logic Types
- `SIMPLE`: Uses basic, straightforward but incorrect reasoning (default)
- `NONSEQUITUR`: Completely random associations and non-sequiturs
- `PSEUDOMATH`: Uses fake mathematical reasoning that sounds plausible
- `VISUAL`: Based on visual/aesthetic reasoning ("3 is even because it's curvy")
## License
MIT