pip install strands-agent-tools
.PrintingCallbackHandler
that streams responses to stdout as they’re generated. When you call agent("What is 2+2")
, you’ll see the response appear in real-time as it’s being generated. The print(response)
above also shows the final collected result after the response is complete. See Callback Handlers in the Strands documentation for more details.client_args
:
WriterModel
accepts configuration parameters as keyword arguments to the model constructor:
Parameter | Type | Description | Default | Options |
---|---|---|---|---|
model_id | str | Model name to use (e.g. palmyra-x5, palmyra-x4, etc.) | Required | reference |
max_tokens | Optional[int] | Maximum number of tokens to generate | See the Context Window for each available model | reference |
stop | Optional[Union[str, List[str]]] | A token or sequence of tokens that, when generated, will cause the model to stop producing further content. This can be a single token or an array of tokens, acting as a signal to end the output. | None | reference |
stream_options | Dict[str, Any] | Additional options for streaming. Specify include_usage to include usage information in the response, in the accumulated_usage field. If you do not specify this, accumulated_usage will show 0 for each value. | None | reference |
temperature | Optional[float] | What sampling temperature to use (0.0 to 2.0). A higher temperature will produce more random output. | 1 | reference |
top_p | Optional[float] | Threshold for “nucleus sampling” | None | reference |
Model | Model ID | Context Window | Description |
---|---|---|---|
Palmyra X5 | palmyra-x5 | 1M tokens | Latest model with 1 million token context for complex workflows, supports vision and multi-content |
Palmyra X4 | palmyra-x4 | 128k tokens | Advanced model for workflow automation and tool calling |
Palmyra Fin | palmyra-fin | 128k tokens | Finance-specialized model (first to pass CFA exam) |
Palmyra Med | palmyra-med | 32k tokens | Healthcare-specialized model for medical analysis |
Palmyra Creative | palmyra-creative | 128k tokens | Creative writing and brainstorming model |
client_args["api_key"]
parameter:
web_search
and email_sender
tools in this example are custom tools that you would need to define. See Python Tools for guidance on creating custom tools, or use existing tools from the strands_tools package.