Skip to content

Absurd take on "no" as a service using a markov chain

jeremytregunna/no-as-a-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

No as a Service

A delightfully absurd API that generates creative ways to say "no" using Markov chains.

What is this?

This is a breakfast project that turns the art of rejection into a service. It was inspired by this post on X I saw while eating breakfast. It uses a Markov chain trained on various creative ways to say "no" (generated by Claude) to generate new, amusing rejections on demand.

Why?

Sometimes you need to say no with style. Sometimes you need to say no with variety. Sometimes you just need an API that does something wonderfully unnecessary.

If you want to run this silly thing

  1. Install dependencies:

    uv sync
  2. Run the server:

    uv run python main.py
  3. The API will be available at http://localhost:8100

API Endpoints

GET /

Returns information about the service and available endpoints.

GET /no

Returns a single creative way to say no.

Example Response:

{
  "response": "I'm afraid that won't be possible.",
}

GET /nos?count=5

Returns multiple absurd ways to say no. The count parameter is optional (default: 5, max: 20).

Example Response:

{
  "responses": [
    "Not a chance.",
    "I think not.",
    "That's off the table."
  ],
  "count": 3,
}

GET /health

Health check endpoint that shows service status and training information.

Example Response:

{
  "status": "healthy",
  "markov_trained": true,
  "training_phrases_count": 177
}

How It Works

  1. Training Data: The service is trained on 178 absurd ways to say no, ranging from polite to humorous
  2. Markov Chain: Uses a Markov chain (order=2) to generate new phrases based on word patterns
  3. API: REST API returns the responses

Testing

Yes, there are tests, because why not, while eating some french toast?

uv run python -m pytest test_no.py -v

The tests cover:

  • Markov chain functionality
  • API endpoints
  • Integration testing
  • Response validation

Example Usage

# Get a single "no"
curl http://localhost:8100/no

# Get multiple "nos"
curl "http://localhost:8100/nos?count=3"

# Check health
curl http://localhost:8100/health

License

Copyright (c) 2025 Jeremy Tregunna

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Absurd take on "no" as a service using a markov chain

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages