Bedrock Syntaxer
A utility to force AWS Bedrock to apply the given syntax to its response.
Installation
To install the required dependencies, run:
pip install -r requirements.txt
Usage
Function: bedrock_syntaxer
A utility to force Bedrock to apply the given syntax to its response.
Parameters:
model_id(str): The model ID of the Bedrock model.messages(list): The messages to send to Bedrock.syntax(str): The syntax to apply to the response.inference_config(dict, optional): The inference configuration to use.region_name(str, optional): The region name of the Bedrock model.
Returns:
str: The response from Bedrock with the syntax applied.
Example
from bedrock_syntaxer import bedrock_syntaxer
import json
ACCOUNT_ID = "961341532715"
REGION = "us-east-1"
MODEL_NAME = "claude-3-5-sonnet-20241022-v2:0"
MODEL_ID = f"arn:aws:bedrock:{REGION}:{ACCOUNT_ID}:inference-profile/us.anthropic.{MODEL_NAME}"
prompt = (
"Write the definition of 3 Filipino word in JSON format. "
"The words are 'kamusta', 'salamat', and 'paalam'."
"Use the keys 'word' and 'definition'."
)
messages = [{"role": "user", "content": [{"text": prompt}]}]
response = bedrock_syntaxer(
model_id=MODEL_ID,
messages=messages,
syntax="json",
region_name=REGION,
)
print(response)
# The response is a JSON string.
response_json = json.loads(response)
Testing
To run the tests, use:
pytest
Metadata
Release files for bedrock-syntaxer 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bedrock_syntaxer-0.2.0.tar.gz | 2.9 kB | Without provenance | Details for bedrock_syntaxer-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bedrock_syntaxer-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for bedrock_syntaxer-0.2.0-py3-none-any.whl |
Total release size: 6.6 kB
Release files / bedrock_syntaxer-0.2.0.tar.gz
| Download URL | bedrock_syntaxer-0.2.0.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ae4f37162fa0b69b67158451b9e16f1fbd8898badc9dae5cfcb1002056d7158a
|
|
BLAKE2b-256 checksum How to use checksums |
3d262160133d9365e9870928217760fed2b9ef8f41dbfbb9146037d09c5f5b5f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.13.0 Darwin/24.3.0
|
Release files / bedrock_syntaxer-0.2.0-py3-none-any.whl
| Download URL | bedrock_syntaxer-0.2.0-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
77793f0f45ec2065e8ae1319e926a2fe510e78eb732fb9ecd2085d5a03ecaeaa
|
|
BLAKE2b-256 checksum How to use checksums |
c35cf5aacd75429b5f507e55ae2c235ecf5a18ef1dfe8db1b2929962774e1283
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.13.0 Darwin/24.3.0
|
Security for bedrock-syntaxer 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.