Skip to content

Commit

Permalink
Add support for the --version flag to display the current version o…
Browse files Browse the repository at this point in the history
…f mark

#6
  • Loading branch information
relston committed Jul 30, 2024
1 parent 80f02ed commit f353b58
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### [0.7.3] - 2024-07-24
#### Added
- Support for `--version` option in the CLI

### [0.7.2] - 2024-07-24
#### Added
- Aliases for cli options `--system` (`-s`) and `--generate-images` (`-i`)
Expand Down
23 changes: 18 additions & 5 deletions mark/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,32 @@
from mark.llm_request import LLMRequest
from mark.markdown_file import MarkdownFile
from mark.config import get_config
from importlib.metadata import version, PackageNotFoundError

try:
package_version = version("mark")
except PackageNotFoundError:
package_version = "unknown"


@click.command()
@click.argument('input', type=click.File())
@click.option('--system', '-s', type=click.STRING, default='default')
@click.argument('file', type=click.File())
@click.option('--system', '-s', type=click.STRING, default='default', help='The system prompt to use')
@click.option('--generate-image', '-i', is_flag=True, default=False,
help='EXPERIMENTAL: Generate an image using DALL-E.')
def command(input, system, generate_image):
@click.version_option(version=package_version)
def command(file, system, generate_image):
"""
Command line tool that processes an input file with a specified agent to generate and record a response.
Markdown powered LLM CLI - Multi-modal AI text generation tool
In-document Thread Example:
mark path/to/markdown.md
stdin Example:
echo "Hello, World!" | mark -
"""
system_prompt = get_config().system_prompts().get(system, 'default')
markdown_file = MarkdownFile(input)
markdown_file = MarkdownFile(file)
request = LLMRequest() \
.with_prompt(markdown_file.content) \
.with_system_message(system_prompt)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mark"
version = "0.7.2"
version = "0.7.3"
description = ""
authors = ["Ryan Elston <[email protected]>"]

Expand Down
3 changes: 2 additions & 1 deletion tests/test_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ def test_page_scrape(mock_web_page):
assert page.body == '\n\nBasic HTML Page\n\nWelcome to My Page\n' + \
'==================\n\n[Visit Example.com](https://www.example.com)\n\n'


def test_timeout_error_handling():
with patch('mark.scraper._render_page', side_effect=pyppeteer.errors.TimeoutError):
page = scraper.get('https://timeout-test.com')

assert page.body == 'Timeout while fetching page'
assert page.title is None, "Expected no title when a TimeoutError occurs"
assert page.url == 'https://timeout-test.com', "URL should be correct even when timeout occurs"
assert page.url == 'https://timeout-test.com', "URL should be correct even when timeout occurs"

0 comments on commit f353b58

Please sign in to comment.