bedrock-inference


Namebedrock-inference JSON
Version 0.0.13 PyPI version JSON
download
home_pageNone
SummaryLogin into your AWS and call Bedrock models in Python
upload_time2024-09-30 10:16:12
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2024 Tommaso Buonocore 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 aws bedrock llm inference generative_ai
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # bedrock-inference

[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]


[![Status][status-shield]][status-url] [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10715476.svg)](https://doi.org/10.5281/zenodo.10715476)


<sub> **Keywords**: *generative AI, Amazon AWS, Bedrock, API, wrapper, LLM, inference, NLP*. </sub>

------------------------------

Bedrock Inference is a simple python package to handle 2FA and on-demand calls to AWS Bedrock foundation models.

<!-- REQUIREMENTS -->
## Requirements

- An **AWS IAM account**
- An **Access key ID** (es: AKIAIOSFODNN7EXAMPLE) and its correspondent **secret access key** (es: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY) for API requests
    - These credentials can be created through Home --> Security credentials --> Access Keys --> Create access key
    - If you have AWS CLI installed and set up on your machine, chances are your credentials are already stored at ~/.aws/credentials and/or in the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. In this case, the package will retrieve them automatically.
        - *Note: AWS CLI is <ins>not required</ins>  to use bedrock-inference.*
- A **Multi-factor authentication device ARN** (es: arn:aws:iam::012345678910:mfa/example_username)
    - The ARN of your MFA device can be located at Home --> Security credentials --> Multi-factor authentication
- The 6 digits **temp token** generated by the MDA device (es: 366 712)



<!-- INSTALLATION -->
## Installation

1. Make sure you have the latest version of pip installed
   ```sh
   pip install --upgrade pip
    ```
2. Install araucanaxai through pip
    ```sh
    pip install bedrock_inference
    ```

<!-- USAGE EXAMPLES -->
## Usage

```python
import from bedrock_inference import bedrock

# Authenticates through MFA and establish a session
session = bedrock.aws_login_mfa(arn="MFA_device_arn", token="MFA_token", aws_access_key_id="your_ID", aws_secret_access_key="your_key")
#session =  bedrock.aws_login_mfa(arn="MFA_device_arn", token="MFA_token") #use this if you already have AWS credentials set up for API requests on your machine

# Instantiate youre Bedrock caller
caller = bedrock.Bedrock(session=session, region="your_aws_region")

#Check available models in your region
print(caller.list_models())

#Invoke the target AWS model and retrieve the generated answer
answer = caller.invoke_model(prompt="What's the conceptual opposite of 'Hello World'?", model_id="target_aws_model_id")
print(answer)
```

<!-- CONTACTS AND USEFUL LINKS -->
## Contacts and Useful Links

*   **Repository maintainer**: Tommaso M. Buonocore  [![Gmail][gmail-shield]][gmail-url] [![LinkedIn][linkedin-shield]][linkedin-url]  

*   **Project Link**: [https://github.com/detsutut/bedrock-inference](https://github.com/detsutut/bedrock-inference)

*   **Package Link**: [https://pypi.org/project/bedrock-inference/](https://pypi.org/project/bedrock-inference/)

<!-- LICENSE -->
## License

Distributed under MIT License. See `LICENSE` for more information.


<!-- MARKDOWN LINKS -->
[contributors-shield]: https://img.shields.io/github/contributors/detsutut/bedrock-inference.svg?style=for-the-badge
[contributors-url]: https://github.com/detsutut/bedrock-inference/graphs/contributors
[status-shield]: https://img.shields.io/badge/Status-pre--release-blue
[status-url]: https://github.com/detsutut/bedrock-inference/releases
[forks-shield]: https://img.shields.io/github/forks/detsutut/bedrock-inference.svg?style=for-the-badge
[forks-url]: https://github.com/detsutut/AraucanaXAI/network/members
[stars-shield]: https://img.shields.io/github/stars/detsutut/bedrock-inference.svg?style=for-the-badge
[stars-url]: https://github.com/detsutut/AraucanaXAI/stargazers
[issues-shield]: https://img.shields.io/github/issues/detsutut/bedrock-inference.svg?style=for-the-badge
[issues-url]: https://github.com/detsutut/bedrock-inference/issues
[license-shield]: https://img.shields.io/github/license/detsutut/bedrock-inference.svg?style=for-the-badge
[license-url]: https://github.com/detsutut/AraucanaXAI/blob/master/araucanaxai/LICENSE
[linkedin-shield]: 	https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white
[linkedin-url]: https://linkedin.com/in/tbuonocore
[gmail-shield]: https://img.shields.io/badge/Gmail-D14836?style=for-the-badge&logo=gmail&logoColor=white
[gmail-url]: mailto:buonocore.tms@gmail.com

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "bedrock-inference",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "aws, bedrock, llm, inference, generative_ai",
    "author": null,
    "author_email": "Tommaso Mario Buonocore <tommaso.buonocore@unipv.it>",
    "download_url": "https://files.pythonhosted.org/packages/71/69/dd62848860b19ce7a5be1dff12c8caad2296319674a0e2d65831fe672fa3/bedrock_inference-0.0.13.tar.gz",
    "platform": null,
    "description": "# bedrock-inference\n\n[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]\n\n\n[![Status][status-shield]][status-url] [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10715476.svg)](https://doi.org/10.5281/zenodo.10715476)\n\n\n<sub> **Keywords**: *generative AI, Amazon AWS, Bedrock, API, wrapper, LLM, inference, NLP*. </sub>\n\n------------------------------\n\nBedrock Inference is a simple python package to handle 2FA and on-demand calls to AWS Bedrock foundation models.\n\n<!-- REQUIREMENTS -->\n## Requirements\n\n- An **AWS IAM account**\n- An **Access key ID** (es: AKIAIOSFODNN7EXAMPLE) and its correspondent **secret access key** (es: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY) for API requests\n    - These credentials can be created through Home --> Security credentials --> Access Keys --> Create access key\n    - If you have AWS CLI installed and set up on your machine, chances are your credentials are already stored at ~/.aws/credentials and/or in the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. In this case, the package will retrieve them automatically.\n        - *Note: AWS CLI is <ins>not required</ins>  to use bedrock-inference.*\n- A **Multi-factor authentication device ARN** (es: arn:aws:iam::012345678910:mfa/example_username)\n    - The ARN of your MFA device can be located at Home --> Security credentials --> Multi-factor authentication\n- The 6 digits **temp token** generated by the MDA device (es: 366 712)\n\n\n\n<!-- INSTALLATION -->\n## Installation\n\n1. Make sure you have the latest version of pip installed\n   ```sh\n   pip install --upgrade pip\n    ```\n2. Install araucanaxai through pip\n    ```sh\n    pip install bedrock_inference\n    ```\n\n<!-- USAGE EXAMPLES -->\n## Usage\n\n```python\nimport from bedrock_inference import bedrock\n\n# Authenticates through MFA and establish a session\nsession = bedrock.aws_login_mfa(arn=\"MFA_device_arn\", token=\"MFA_token\", aws_access_key_id=\"your_ID\", aws_secret_access_key=\"your_key\")\n#session =  bedrock.aws_login_mfa(arn=\"MFA_device_arn\", token=\"MFA_token\") #use this if you already have AWS credentials set up for API requests on your machine\n\n# Instantiate youre Bedrock caller\ncaller = bedrock.Bedrock(session=session, region=\"your_aws_region\")\n\n#Check available models in your region\nprint(caller.list_models())\n\n#Invoke the target AWS model and retrieve the generated answer\nanswer = caller.invoke_model(prompt=\"What's the conceptual opposite of 'Hello World'?\", model_id=\"target_aws_model_id\")\nprint(answer)\n```\n\n<!-- CONTACTS AND USEFUL LINKS -->\n## Contacts and Useful Links\n\n*   **Repository maintainer**: Tommaso M. Buonocore  [![Gmail][gmail-shield]][gmail-url] [![LinkedIn][linkedin-shield]][linkedin-url]  \n\n*   **Project Link**: [https://github.com/detsutut/bedrock-inference](https://github.com/detsutut/bedrock-inference)\n\n*   **Package Link**: [https://pypi.org/project/bedrock-inference/](https://pypi.org/project/bedrock-inference/)\n\n<!-- LICENSE -->\n## License\n\nDistributed under MIT License. See `LICENSE` for more information.\n\n\n<!-- MARKDOWN LINKS -->\n[contributors-shield]: https://img.shields.io/github/contributors/detsutut/bedrock-inference.svg?style=for-the-badge\n[contributors-url]: https://github.com/detsutut/bedrock-inference/graphs/contributors\n[status-shield]: https://img.shields.io/badge/Status-pre--release-blue\n[status-url]: https://github.com/detsutut/bedrock-inference/releases\n[forks-shield]: https://img.shields.io/github/forks/detsutut/bedrock-inference.svg?style=for-the-badge\n[forks-url]: https://github.com/detsutut/AraucanaXAI/network/members\n[stars-shield]: https://img.shields.io/github/stars/detsutut/bedrock-inference.svg?style=for-the-badge\n[stars-url]: https://github.com/detsutut/AraucanaXAI/stargazers\n[issues-shield]: https://img.shields.io/github/issues/detsutut/bedrock-inference.svg?style=for-the-badge\n[issues-url]: https://github.com/detsutut/bedrock-inference/issues\n[license-shield]: https://img.shields.io/github/license/detsutut/bedrock-inference.svg?style=for-the-badge\n[license-url]: https://github.com/detsutut/AraucanaXAI/blob/master/araucanaxai/LICENSE\n[linkedin-shield]: \thttps://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white\n[linkedin-url]: https://linkedin.com/in/tbuonocore\n[gmail-shield]: https://img.shields.io/badge/Gmail-D14836?style=for-the-badge&logo=gmail&logoColor=white\n[gmail-url]: mailto:buonocore.tms@gmail.com\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Tommaso Buonocore  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. ",
    "summary": "Login into your AWS and call Bedrock models in Python",
    "version": "0.0.13",
    "project_urls": {
        "Homepage": "https://github.com/detsutut/bedrock_inference",
        "Issues": "https://github.com/detsutut/bedrock_inference/issues"
    },
    "split_keywords": [
        "aws",
        " bedrock",
        " llm",
        " inference",
        " generative_ai"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3e11d65b476b3b20eceb0df013d15bb6232e480a4d680e4f9ae1afcb165eec12",
                "md5": "80c05c7d26779eebb0f4cf4fb5f67b2d",
                "sha256": "2b4a7dd09174f2e2b733dea799743e68d50523a1cf1b88abe05744c95df96bb2"
            },
            "downloads": -1,
            "filename": "bedrock_inference-0.0.13-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "80c05c7d26779eebb0f4cf4fb5f67b2d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 7622,
            "upload_time": "2024-09-30T10:16:10",
            "upload_time_iso_8601": "2024-09-30T10:16:10.878589Z",
            "url": "https://files.pythonhosted.org/packages/3e/11/d65b476b3b20eceb0df013d15bb6232e480a4d680e4f9ae1afcb165eec12/bedrock_inference-0.0.13-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7169dd62848860b19ce7a5be1dff12c8caad2296319674a0e2d65831fe672fa3",
                "md5": "804a0fccfe42122a583f2264dbc01f73",
                "sha256": "c85ac16b731d8a1eb723ace3962e6d8587b3bdc5a8aa8d9c35e24b9687eedd99"
            },
            "downloads": -1,
            "filename": "bedrock_inference-0.0.13.tar.gz",
            "has_sig": false,
            "md5_digest": "804a0fccfe42122a583f2264dbc01f73",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 7467,
            "upload_time": "2024-09-30T10:16:12",
            "upload_time_iso_8601": "2024-09-30T10:16:12.594395Z",
            "url": "https://files.pythonhosted.org/packages/71/69/dd62848860b19ce7a5be1dff12c8caad2296319674a0e2d65831fe672fa3/bedrock_inference-0.0.13.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-30 10:16:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "detsutut",
    "github_project": "bedrock_inference",
    "github_not_found": true,
    "lcname": "bedrock-inference"
}
        
Elapsed time: 0.66072s