anthropic-cli


Nameanthropic-cli JSON
Version 0.2.3 PyPI version JSON
download
home_page
SummaryA command-line tool for interacting with the Anthropic API
upload_time2024-03-07 08:00:47
maintainer
docs_urlNone
author
requires_python>=3.7
licenseCopyright 2024 David Mohl 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.
keywords anthropic api cli command-line
VCS
bugtrack_url
requirements anthropic pdf2image
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Anthropic API Command Line Tool

This is a command line tool that allows you to interact with the Anthropic API using the Anthropic Python SDK. You can send messages, including text and images, to the API and receive responses.

**NOTE**: This CLI has been programmed by Claude 3

![screenshot](./screenshot.png)

## Features

- Send text messages to the Anthropic API
- Include images (PNG, JPEG, or PDF) in the messages
- Specify various parameters such as model, system message, temperature, top-k, top-p, and max tokens
- Parse PDF files and convert into a JPEG image for processing (requires Poppler)

### Installing Poppler

Poppler is a separate library that is required by the `pdf2image` library for converting PDF files to images. The installation process for Poppler varies depending on your operating system.

Please check https://pdf2image.readthedocs.io/en/latest/installation.html for installation instructions.

You do not need to install Poppler if you don't plan on passing PDFs into the vision API.

## Setup

```
pip install anthropic-sdk
```

Set your Anthropic API key as an environment variable named `ANTHROPIC_API_KEY`. You can do this by running the following command in your terminal or adding it to your shell configuration file (e.g., `.bashrc`, `.zshrc`):

```bash
export ANTHROPIC_API_KEY="your_api_key_here"
```

Replace `"your_api_key_here"` with your actual Anthropic API key.

## Usage

To use the command line tool, run the following command:

```bash
python anthropic_cli.py [options]
```

### Options

- `-g`, `--message`: Add a message with the specified role and content. You can use this option multiple times to add multiple messages. The format is `-g <role> "<content>"`.
  - `<role>`: The role of the message sender, e.g., "user" or "assistant".
  - `<content>`: The content of the message, enclosed in double quotes.

- `-i`, `--image`: Path to an image file to include in the message. The image should be in PNG format.

- `-m`, `--model`: Anthropic model to use (default: "claude-3-opus-20240229").

- `-s`, `--system`: System message to provide context or instructions to the model.

- `-t`, `--temperature`: Temperature value for the model, controlling the randomness of the generated response.

- `-k`, `--top_k`: Top-k sampling parameter, restricting the model to consider only the top k most likely tokens.

- `-p`, `--top_p`: Top-p sampling parameter, restricting the model to consider only the most likely tokens whose cumulative probability exceeds p.

- `-x`, `--max_tokens`: Maximum number of tokens in the generated response (default: 1024).

### Examples

1. Send a simple message:

   ```bash
   python anthropic_cli.py -g user "Hello, Claude!"
   ```

2. Send multiple messages:

   ```bash
   python anthropic_cli.py -g user "Hello, Claude!" -g assistant "Hello! How can I assist you today?"
   ```

3. Include an image in the message:

   ```bash
   python anthropic_cli.py -g user "What does this image show?" -i path/to/image.png
   ```

4. Specify the model and other parameters:

   ```bash
   python anthropic_cli.py -g user "Hello, Claude!" -m claude-3-opus-20240229 -s "You are a helpful assistant." -t 0.8 -x 500
   ```

   This command uses the "claude-3-opus-20240229" model, sets a system message, adjusts the temperature to 0.8, and limits the maximum number of tokens in the response to 500.

## Output

The command line tool will send the messages and image (if provided) to the Anthropic API and print the text content of the response to the console.

## LICENSE

MIT

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "anthropic-cli",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "anthropic,api,cli,command-line",
    "author": "",
    "author_email": "David Mohl <git@d.sh>",
    "download_url": "https://files.pythonhosted.org/packages/a8/77/ed4ad5b23bbae8f71af6db754170c6bffbca327b80cd625a100c2b3ed092/anthropic-cli-0.2.3.tar.gz",
    "platform": null,
    "description": "# Anthropic API Command Line Tool\n\nThis is a command line tool that allows you to interact with the Anthropic API using the Anthropic Python SDK. You can send messages, including text and images, to the API and receive responses.\n\n**NOTE**: This CLI has been programmed by Claude 3\n\n![screenshot](./screenshot.png)\n\n## Features\n\n- Send text messages to the Anthropic API\n- Include images (PNG, JPEG, or PDF) in the messages\n- Specify various parameters such as model, system message, temperature, top-k, top-p, and max tokens\n- Parse PDF files and convert into a JPEG image for processing (requires Poppler)\n\n### Installing Poppler\n\nPoppler is a separate library that is required by the `pdf2image` library for converting PDF files to images. The installation process for Poppler varies depending on your operating system.\n\nPlease check https://pdf2image.readthedocs.io/en/latest/installation.html for installation instructions.\n\nYou do not need to install Poppler if you don't plan on passing PDFs into the vision API.\n\n## Setup\n\n```\npip install anthropic-sdk\n```\n\nSet your Anthropic API key as an environment variable named `ANTHROPIC_API_KEY`. You can do this by running the following command in your terminal or adding it to your shell configuration file (e.g., `.bashrc`, `.zshrc`):\n\n```bash\nexport ANTHROPIC_API_KEY=\"your_api_key_here\"\n```\n\nReplace `\"your_api_key_here\"` with your actual Anthropic API key.\n\n## Usage\n\nTo use the command line tool, run the following command:\n\n```bash\npython anthropic_cli.py [options]\n```\n\n### Options\n\n- `-g`, `--message`: Add a message with the specified role and content. You can use this option multiple times to add multiple messages. The format is `-g <role> \"<content>\"`.\n  - `<role>`: The role of the message sender, e.g., \"user\" or \"assistant\".\n  - `<content>`: The content of the message, enclosed in double quotes.\n\n- `-i`, `--image`: Path to an image file to include in the message. The image should be in PNG format.\n\n- `-m`, `--model`: Anthropic model to use (default: \"claude-3-opus-20240229\").\n\n- `-s`, `--system`: System message to provide context or instructions to the model.\n\n- `-t`, `--temperature`: Temperature value for the model, controlling the randomness of the generated response.\n\n- `-k`, `--top_k`: Top-k sampling parameter, restricting the model to consider only the top k most likely tokens.\n\n- `-p`, `--top_p`: Top-p sampling parameter, restricting the model to consider only the most likely tokens whose cumulative probability exceeds p.\n\n- `-x`, `--max_tokens`: Maximum number of tokens in the generated response (default: 1024).\n\n### Examples\n\n1. Send a simple message:\n\n   ```bash\n   python anthropic_cli.py -g user \"Hello, Claude!\"\n   ```\n\n2. Send multiple messages:\n\n   ```bash\n   python anthropic_cli.py -g user \"Hello, Claude!\" -g assistant \"Hello! How can I assist you today?\"\n   ```\n\n3. Include an image in the message:\n\n   ```bash\n   python anthropic_cli.py -g user \"What does this image show?\" -i path/to/image.png\n   ```\n\n4. Specify the model and other parameters:\n\n   ```bash\n   python anthropic_cli.py -g user \"Hello, Claude!\" -m claude-3-opus-20240229 -s \"You are a helpful assistant.\" -t 0.8 -x 500\n   ```\n\n   This command uses the \"claude-3-opus-20240229\" model, sets a system message, adjusts the temperature to 0.8, and limits the maximum number of tokens in the response to 500.\n\n## Output\n\nThe command line tool will send the messages and image (if provided) to the Anthropic API and print the text content of the response to the console.\n\n## LICENSE\n\nMIT\n",
    "bugtrack_url": null,
    "license": "Copyright 2024 David Mohl  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u201cSoftware\u201d), 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 \u201cAS IS\u201d, 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. ",
    "summary": "A command-line tool for interacting with the Anthropic API",
    "version": "0.2.3",
    "project_urls": {
        "Bug Tracker": "https://github.com/dvcrn/anthropic-cli/issues",
        "Homepage": "https://github.com/dvcrn/anthropic-cli"
    },
    "split_keywords": [
        "anthropic",
        "api",
        "cli",
        "command-line"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bdb765f886b04254db8f9a63c68556219b8bce0fa27b72fb2dcc97d75632f455",
                "md5": "2094bffcb66f0fad527f70f579368da6",
                "sha256": "510f4366fa9e0ab24580940c87bf8783c145895d091e82d6e47e3ada8cd629fa"
            },
            "downloads": -1,
            "filename": "anthropic_cli-0.2.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2094bffcb66f0fad527f70f579368da6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 6048,
            "upload_time": "2024-03-07T08:00:45",
            "upload_time_iso_8601": "2024-03-07T08:00:45.735554Z",
            "url": "https://files.pythonhosted.org/packages/bd/b7/65f886b04254db8f9a63c68556219b8bce0fa27b72fb2dcc97d75632f455/anthropic_cli-0.2.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a877ed4ad5b23bbae8f71af6db754170c6bffbca327b80cd625a100c2b3ed092",
                "md5": "00237c7cccb4384a773a459360996d85",
                "sha256": "c0a255caf8a83d71e9047b7ab250c7ee996a0cb23766475025a56b2aa5e0a515"
            },
            "downloads": -1,
            "filename": "anthropic-cli-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "00237c7cccb4384a773a459360996d85",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 5017,
            "upload_time": "2024-03-07T08:00:47",
            "upload_time_iso_8601": "2024-03-07T08:00:47.383445Z",
            "url": "https://files.pythonhosted.org/packages/a8/77/ed4ad5b23bbae8f71af6db754170c6bffbca327b80cd625a100c2b3ed092/anthropic-cli-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-07 08:00:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dvcrn",
    "github_project": "anthropic-cli",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "anthropic",
            "specs": [
                [
                    "==",
                    "0.19.1"
                ]
            ]
        },
        {
            "name": "pdf2image",
            "specs": [
                [
                    "==",
                    "1.17.0"
                ]
            ]
        }
    ],
    "lcname": "anthropic-cli"
}
        
Elapsed time: 0.22048s