ask-bedrock


Nameask-bedrock JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/awslabs/ask-bedrock
SummaryConverse with your favorite Amazon Bedrock LLM from the command line.
upload_time2024-03-21 16:19:28
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords ask-bedrock genai bedrock aws
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Ask Amazon Bedrock

Converse with your favorite [Amazon Bedrock](https://aws.amazon.com/bedrock/) large language model from the command line.

<p>
  <img width="1000" src="https://raw.githubusercontent.com/awslabs/ask-bedrock/main/README.svg">
</p>

This tool is a wrapper around the low-level Amazon Bedrock APIs and [Langchain](https://python.langchain.com/docs/integrations/llms/bedrock). Its main added value is that it locally persists AWS account and model configuration to enable quick and easy interaction.

## Installation

⚠️ Requires Python >= 3.9

⚠️ Requires a working AWS CLI setup configured with a profile that allows Amazon Bedrock access. See [CLI documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) for details.


```shell
pip install ask-bedrock
```

You can also build/run this project locally, see [Building and Running Locally](#building-and-running-locally).

## Usage

### Activating models

Before you can use this command line tool, you need to [request model access through the AWS Console](https://console.aws.amazon.com/bedrock/home#/modelaccess) in a region where Bedrock is available: Switch to the region where you want to run Bedrock, go to ”Model access“, click “Edit”, activate the models you wish to use, and then click “Save changes”.

### Invocation

To start a conversation, simply enter the following command:

```shell
ask-bedrock converse
```

Upon the first run, you will be led through a configuration flow. To learn more about configuration options, see the [Configuration](#configuration) section below.

If you’re fully configured, the tool will show you a `>>>` prompt and you can start interacting with the configured model.

Multi-line prompts can be wrapped into `<<< >>>` blocks.

To end your interaction, hit `Ctrl + D`. Note that the conversation will be lost.

### Pricing

Note that using Ask Amazon Bedrock incurs AWS fees. For more information, see [Amazon Bedrock pricing](https://aws.amazon.com/bedrock/pricing/). Consider using a dedicated AWS account and [AWS Budgets](https://docs.aws.amazon.com/cost-management/latest/userguide/budgets-managing-costs.html) to control costs.

## Configuration

*Ask Amazon Bedrock* stores your user configuration in `$HOME/.config/ask-bedrock/config.yaml`. This file may contain several sets of configuration (contexts). For instance, you can use contexts to switch between different models. Use the `--context` parameter to select the context you'd like to use. The default context is `default`.

If no configuration is found for a selected context, a new one is created. If you want to change an existing config, use

```shell
ask-bedrock configure --context mycontext
```

You can also create or edit the configuration file yourself in `$HOME/.config/ask-bedrock/config.yaml`:

```yaml
contexts:
  default:
    region: ""                  # an AWS region where you have activated Bedrock
    aws_profile: ""             # a profile from your ~/.aws/config file
    model_id: ""                # a Bedrock model, e.g. "ai21.j2-ultra-v1"
    model_params: "{}"          # a JSON object with parameters for the selected model
```

### Model parameters

This JSON is passed to Langchain during client setup (as `model_kwargs`). The schema depends on the model that is used. Have a look at the [examples](model_params_examples.md).

If you want to configure multiple lines, model parameters can be wrapped in `<<< >>>`.

## Building and Running Locally

```
pip install build
python -m build
python ask_bedrock/main.py converse
```

## Feedback

As this tool is still early stage, we are very interested in hearing about your experience. Please take one minute to take a little survey: **https://pulse.aws/survey/GTRWNHT1**


## Troubleshooting

**Q:** I’m getting the following error during invocation: “ValueError: Error raised by bedrock service: An error occurred (AccessDeniedException) when calling the InvokeModel operation: Your account is not authorized to invoke this API operation.”

**A:** You may have selected a model that is currently not yet activated for public usage. It may have been listed it in the selection of available models, but unfortunately some models (such as Amazon Titan) aren’t yet available via API.

---

**Q:** The model responses are cut off mid-sentence.

**A:** Configure the model to allow for longer response. Use model parameters (see above) for this. Claude for example would take the following model parameters: `{"max_tokens_to_sample": 3000}`

---

**Q**: I'm getting an error that is not listed here.

**A**: Use the `--debug` option to find out more about the error. If you cannot solve it, create an issue.

## Security

See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.

## License

This project is licensed under the Apache-2.0 License.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/awslabs/ask-bedrock",
    "name": "ask-bedrock",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "ask-bedrock, GenAI, Bedrock, AWS",
    "author": null,
    "author_email": "Ulrich Hinze <uhinze@amazon.de>, Alexander G\u00fcnsche <lxg@amazon.de>",
    "download_url": "https://files.pythonhosted.org/packages/8a/82/1ba5a0b0794ae03d44ced79eb2253cbf97a0ec21fc2d0b5c330e7ef76eff/ask-bedrock-0.1.0.tar.gz",
    "platform": null,
    "description": "# Ask Amazon Bedrock\n\nConverse with your favorite [Amazon Bedrock](https://aws.amazon.com/bedrock/) large language model from the command line.\n\n<p>\n  <img width=\"1000\" src=\"https://raw.githubusercontent.com/awslabs/ask-bedrock/main/README.svg\">\n</p>\n\nThis tool is a wrapper around the low-level Amazon Bedrock APIs and [Langchain](https://python.langchain.com/docs/integrations/llms/bedrock). Its main added value is that it locally persists AWS account and model configuration to enable quick and easy interaction.\n\n## Installation\n\n\u26a0\ufe0f Requires Python >= 3.9\n\n\u26a0\ufe0f Requires a working AWS CLI setup configured with a profile that allows Amazon Bedrock access. See [CLI documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) for details.\n\n\n```shell\npip install ask-bedrock\n```\n\nYou can also build/run this project locally, see [Building and Running Locally](#building-and-running-locally).\n\n## Usage\n\n### Activating models\n\nBefore you can use this command line tool, you need to [request model access through the AWS Console](https://console.aws.amazon.com/bedrock/home#/modelaccess) in a region where Bedrock is available: Switch to the region where you want to run Bedrock, go to \u201dModel access\u201c, click \u201cEdit\u201d, activate the models you wish to use, and then click \u201cSave changes\u201d.\n\n### Invocation\n\nTo start a conversation, simply enter the following command:\n\n```shell\nask-bedrock converse\n```\n\nUpon the first run, you will be led through a configuration flow. To learn more about configuration options, see the [Configuration](#configuration) section below.\n\nIf you\u2019re fully configured, the tool will show you a `>>>` prompt and you can start interacting with the configured model.\n\nMulti-line prompts can be wrapped into `<<< >>>` blocks.\n\nTo end your interaction, hit `Ctrl + D`. Note that the conversation will be lost.\n\n### Pricing\n\nNote that using Ask Amazon Bedrock incurs AWS fees. For more information, see [Amazon Bedrock pricing](https://aws.amazon.com/bedrock/pricing/). Consider using a dedicated AWS account and [AWS Budgets](https://docs.aws.amazon.com/cost-management/latest/userguide/budgets-managing-costs.html) to control costs.\n\n## Configuration\n\n*Ask Amazon Bedrock* stores your user configuration in `$HOME/.config/ask-bedrock/config.yaml`. This file may contain several sets of configuration (contexts). For instance, you can use contexts to switch between different models. Use the `--context` parameter to select the context you'd like to use. The default context is `default`.\n\nIf no configuration is found for a selected context, a new one is created. If you want to change an existing config, use\n\n```shell\nask-bedrock configure --context mycontext\n```\n\nYou can also create or edit the configuration file yourself in `$HOME/.config/ask-bedrock/config.yaml`:\n\n```yaml\ncontexts:\n  default:\n    region: \"\"                  # an AWS region where you have activated Bedrock\n    aws_profile: \"\"             # a profile from your ~/.aws/config file\n    model_id: \"\"                # a Bedrock model, e.g. \"ai21.j2-ultra-v1\"\n    model_params: \"{}\"          # a JSON object with parameters for the selected model\n```\n\n### Model parameters\n\nThis JSON is passed to Langchain during client setup (as `model_kwargs`). The schema depends on the model that is used. Have a look at the [examples](model_params_examples.md).\n\nIf you want to configure multiple lines, model parameters can be wrapped in `<<< >>>`.\n\n## Building and Running Locally\n\n```\npip install build\npython -m build\npython ask_bedrock/main.py converse\n```\n\n## Feedback\n\nAs this tool is still early stage, we are very interested in hearing about your experience. Please take one minute to take a little survey: **https://pulse.aws/survey/GTRWNHT1**\n\n\n## Troubleshooting\n\n**Q:** I\u2019m getting the following error during invocation: \u201cValueError: Error raised by bedrock service: An error occurred (AccessDeniedException) when calling the InvokeModel operation: Your account is not authorized to invoke this API operation.\u201d\n\n**A:** You may have selected a model that is currently not yet activated for public usage. It may have been listed it in the selection of available models, but unfortunately some models (such as Amazon Titan) aren\u2019t yet available via API.\n\n---\n\n**Q:** The model responses are cut off mid-sentence.\n\n**A:** Configure the model to allow for longer response. Use model parameters (see above) for this. Claude for example would take the following model parameters: `{\"max_tokens_to_sample\": 3000}`\n\n---\n\n**Q**: I'm getting an error that is not listed here.\n\n**A**: Use the `--debug` option to find out more about the error. If you cannot solve it, create an issue.\n\n## Security\n\nSee [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information.\n\n## License\n\nThis project is licensed under the Apache-2.0 License.\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Converse with your favorite Amazon Bedrock LLM from the command line.",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/awslabs/ask-bedrock"
    },
    "split_keywords": [
        "ask-bedrock",
        " genai",
        " bedrock",
        " aws"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "664a952b9fecf08fa577398d206fe07e2210194c3fea6738cd08b3e3c8d49bd0",
                "md5": "24587cafcbcd5c366ebe59911b686398",
                "sha256": "a326f67bf540c94409be90d583b1107bc0226a6331f2a292c2f3d45b346ad263"
            },
            "downloads": -1,
            "filename": "ask_bedrock-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "24587cafcbcd5c366ebe59911b686398",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 10843,
            "upload_time": "2024-03-21T16:19:27",
            "upload_time_iso_8601": "2024-03-21T16:19:27.485081Z",
            "url": "https://files.pythonhosted.org/packages/66/4a/952b9fecf08fa577398d206fe07e2210194c3fea6738cd08b3e3c8d49bd0/ask_bedrock-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8a821ba5a0b0794ae03d44ced79eb2253cbf97a0ec21fc2d0b5c330e7ef76eff",
                "md5": "7304e1c3735fb70c871c41ecae70ce3d",
                "sha256": "fd4154953cafb9b77c216d5739a7ef8228811889fdd3d9c77683945ece951939"
            },
            "downloads": -1,
            "filename": "ask-bedrock-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "7304e1c3735fb70c871c41ecae70ce3d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 10032,
            "upload_time": "2024-03-21T16:19:28",
            "upload_time_iso_8601": "2024-03-21T16:19:28.572816Z",
            "url": "https://files.pythonhosted.org/packages/8a/82/1ba5a0b0794ae03d44ced79eb2253cbf97a0ec21fc2d0b5c330e7ef76eff/ask-bedrock-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-21 16:19:28",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "awslabs",
    "github_project": "ask-bedrock",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ask-bedrock"
}
        
Elapsed time: 0.20600s