Docs /Templates/ sinapsis-aws-bedrock

BedrockTextGeneration

sinapsis-aws-bedrockBedrockawsbedrockchatbotscontext

Python template · sinapsis_aws_bedrock.templates.bedrock_text_generation

Overview

Template for AWS Bedrock text generation using the Converse API.

Credentials and region are resolved with boto3's default credential chain (environment variables, `~/.aws/credentials`/`~/.aws/config`, `AWS_PROFILE`, SSO, or an IAM instance/role profile).

At initialization, a bare `llm_model_name` that requires a cross-region inference profile is automatically rewritten with the region prefix (`us.`/`eu.`/`apac.`) when a matching profile exists; on-demand model ids are left unchanged.

Capabilities

Capabilities: not set

Installation

Install the published package using pip or uv.

Terminalbash
pip install sinapsis-aws-bedrock==1.0.0
uv pip install sinapsis-aws-bedrock==1.0.0
uv add sinapsis-aws-bedrock==1.0.0

Configuration

Effective fields from the inspector schema, including nested Pydantic model fields.

metadata
sinapsis_core.template_base.base_models.TemplateMetadata | None
Optional
Default: null
init_argsRequired

Bedrock model configuration. `llm_model_name` must be a Bedrock model id or inference-profile id (for example `us.anthropic.claude-3-5-sonnet-20241022-v2:0`).

LLMInitArgs
Required
Default: null
llm_model_nameRequired

The name or path of the LLM model to use (e.g., 'claude-3-7-sonnet-latest', 'TheBloke/Llama-2-7B-GGUF').

str
Required
Default: null
completion_args

Bedrock Converse generation arguments.

BedrockCompletionArgs
Optional
Default: null
top_k

Top-k sampling. Not part of `inferenceConfig`; forwarded via `additional_model_request_fields` when supported by the model.

int | None
Optional
Default: null
top_p

Nucleus sampling parameter (`inferenceConfig.topP`).

float | None
Optional
Default: null
max_tokens

Maximum number of tokens to generate (`inferenceConfig.maxTokens`).

int
Optional
Default: 4096
temperature

Sampling temperature (`inferenceConfig.temperature`).

float | None
Optional
Default: null
stop_sequences

Custom stop sequences (`inferenceConfig.stopSequences`).

list[str] | None
Optional
Default: null
response_format

Provider-neutral structured output config.

LLMResponseFormat
Optional
Default: null
type_

Output mode. Aliased to `type`.

typing.Literal['text', 'json_object']
Optional
Default: "text"
schema_

Optional schema used for structured JSON output. Aliased to `schema`.

SchemaDefinition
Optional
Default: null
required

Required root property names.

list[str]
Optional
Default: null
properties

Root schema properties.

dict[str, str | sinapsis_chatbots_base.helpers.schemas.PropertyDefinition]
Optional
Default: null
additional_properties

Whether extra root-level fields are allowed.

bool | None
Optional
Default: null
additional_model_request_fields

Extra model-specific request fields forwarded verbatim as Converse `additionalModelRequestFields`.

dict[str, typing.Any]
Optional
Default: null
cleanup_response
bool
Optional
Default: true
reasoning_end_tag
str | None
Optional
Default: "</think>"
reasoning_start_tag
str | None
Optional
Default: "<think>"

Configuration example

Example from the Python docstring:

yaml
agent:
  name: my_test_agent
templates:
- template_name: InputTemplate
  class_name: InputTemplate
  attributes: {}
- template_name: BedrockTextGeneration
  class_name: BedrockTextGeneration
  template_input: LLMConversationInput
  attributes:
    init_args:
      llm_model_name: us.anthropic.claude-3-5-sonnet-20241022-v2:0
    completion_args:
      max_tokens: 1024
      temperature: 0.7
Show schema-based configuration skeleton
yaml
templates:
  - template_name: "BedrockTextGeneration"
    class_name: "BedrockTextGeneration"
    attributes:
      init_args:
        llm_model_name: "<required>"
      completion_args:
        top_k: null
        top_p: null
        max_tokens: 4096
        temperature: null
        stop_sequences: null
        response_format:
          type_: "text"
          schema_:
            required: null
            properties: null
            additional_properties: null
        additional_model_request_fields: null
      cleanup_response: true
      reasoning_end_tag: "</think>"
      reasoning_start_tag: "<think>"

Inheritance

Immediate parent: sinapsis_chatbots_base.templates.llm_template_base.LLMTemplateBase

Environment variables

Environment definitions belong to their canonical Python modules.

No directly related environment variables listed.