Skip to main content

Mark lets you seamlessly use markdown, images and links to interact with LLMs

Project description

Build Status License

Mark

Mark lets you seamlessly use markdown, images and links to interact with LLMs

"Markdown is still the best format for feeding into language models"
- Simon Willison (co-creator of Django)

Why Markdown + LLMs? For a full rundown of the benefits and use cases, check out Introducing 'Mark', a Markdown CLI tool for LLMs

Key Features

  • Interact with LLMs using Markdown
  • Visual recognition of markdown image references via multi-modal LLMs
  • Local and remote links are scraped for context
  • LLM responses appended directly into Markdown files
  • stdin and stdout support for piping
  • Support for Image Generation

Example

Describe ![this image](https://www.animal.photos/mamm1/cat-tig1_files/bengal12.jpg) to me in one short sentence.

# GPT Response (model: gpt-4o-2024-05-13, system: default)
A Bengal tiger is walking on a sandy path with greenery in the background.

# User Response
List each section of content on [this page](https://en.wikipedia.org/wiki/Bengal_tiger)

# GPT Response (model: gpt-4o-2024-05-13, system: default)
## Sections of Content on the Bengal Tiger Wikipedia Page

1. **Taxonomy**
   - Genetic ancestry

2. **Characteristics**
   - Body weight and size

3. **Distribution and habitat**
   - India
   - Bangladesh
    ...

This allows you to carry on a conversation directly in the markdown file - or simply integrate the response back into the document you're working on. This is a powerful, flexible and natural way to interact with LLMs that unlocks countless use cases. mark's focus on explicitly using Markdown as both a prompt and response medium for LLMs presents a unique approach. By blending interactive, version-controlled Markdown documents with LLM responses in a CLI tool offers an innovative workflow for those looking to integrate LLM interactions into their development and documentation processes.

Install the Mark CLI

pip install mark

Browser Setup (Required for Web Scraping)

Mark uses Playwright browsers to scrape web links. After installing mark, you need to install the browser binaries:

mark-setup-browsers

Or manually:

playwright install chromium

Note: This only needs to be done once after installation. The browser binaries are downloaded to ~/.cache/ms-playwright/ (~100MB).

Usage

By default, mark will read a markdown file, extract any context references, and send them to the LLM. The responses are then appended to the markdown file.

mark path/to/markdown.md

Requires an OpenAI API key in the OPENAI_API_KEY environment variable

Also supports stdin with stdout for piping LLM responses into other tools

cat path/to/markdown.md | mark 
# LLM response....

Use a specific LLM model

You can specify a different LLM model to use with the --model (or -m) flag

mark path/to/markdown.md --model gpt-4o-2024-05-13

Custom system prompts

The system prompts folder is located at ~/.mark/system_prompts and it includes a default.md prompt. You can add any additional system prompts you'd like to use in this folder and use them with the --system (or -s) flag.

# ~/.mark/system_prompts/custom.md
mark path/to/markdown.md --system custom

Override the OpenAI API endpoint

If you want to use a different LLM API endpoint that is fully compatible with the OpenAI API, set the OPENAI_API_BASE_URL environment variable to that endpoint value. This should enable you to use OpenAI proxy services like credal.ai, or other LLMs that are compatible with the OpenAI SDK.

Image Generation

To generate an image based on the input just add the --generate-image (or -i) flag to the command

mark path/to/markdown.md --generate-image

This will generate an image using the 'dall-e-3' model and append it to the markdown file.

Development

Local Setup

poetry install

Requires poetry

After installation, install Playwright browsers:

poetry run mark-setup-browsers
# Or: poetry run playwright install chromium

Run the CLI Tool locally

poetry run mark path/to/markdown.md

Run the tests

poetry run python -m pytest

Auto-fix lint errors

poetry run autopep8 --in-place --aggressive --aggressive --recursive .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mark-0.11.0.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mark-0.11.0-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file mark-0.11.0.tar.gz.

File metadata

  • Download URL: mark-0.11.0.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.9 Linux/6.17.1-arch1-1-surface

File hashes

Hashes for mark-0.11.0.tar.gz
Algorithm Hash digest
SHA256 3291089ec02735f2e552b76d30fc814d359dfeac63033fc4efbe60f604cb0aab
MD5 8d6e5bf11f0bf9c9e7faab327fe1be05
BLAKE2b-256 cbf29c2be91f94bcf09ace783c1aadc940d9b25e80124e403b9c7f5523f64b2c

See more details on using hashes here.

File details

Details for the file mark-0.11.0-py3-none-any.whl.

File metadata

  • Download URL: mark-0.11.0-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.9 Linux/6.17.1-arch1-1-surface

File hashes

Hashes for mark-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5005b18f52ae6c994bd4e2b092c0e62a3514968cefb8737f1e00aa233abc4107
MD5 7580b128c51326cdcf68db7ee17f1962
BLAKE2b-256 1e8b08ec5d41f75e0c60d3f0a3f2bcad1ed161e288bdbef9f70b47de6410dd3b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page