invoke_inline_agent
async
¶
invoke_inline_agent(
foundation_model: ModelIdentifier,
instruction: Instruction,
session_id: SessionId,
*,
config_overrides: Optional[AsyncBedrockAgentRuntimeClientConfig] = None,
customer_encryption_key_arn: Optional[KmsKeyArn] = None,
idle_session_ttl_in_seconds: Optional[SessionTTL] = None,
action_groups: Optional[AgentActionGroups] = None,
knowledge_bases: Optional[KnowledgeBases] = None,
guardrail_configuration: Optional[GuardrailConfigurationWithArn] = None,
prompt_override_configuration: Optional[PromptOverrideConfiguration] = None,
agent_collaboration: Optional[AgentCollaboration] = None,
collaborator_configurations: Optional[CollaboratorConfigurations] = None,
agent_name: Optional[Name] = None,
end_session: Optional[bool] = None,
enable_trace: Optional[bool] = None,
input_text: Optional[InputText] = None,
streaming_configurations: Optional[StreamingConfigurations] = None,
prompt_creation_configurations: Optional[PromptCreationConfigurations] = None,
inline_session_state: Optional[InlineSessionState] = None,
collaborators: Optional[Collaborators] = None,
bedrock_model_configurations: Optional[InlineBedrockModelConfigurations] = None,
orchestration_type: Optional[OrchestrationType] = None,
custom_orchestration: Optional[CustomOrchestration] = None,
) -> AsyncGenerator[InvokeInlineAgentResponse]
Invokes an inline Amazon Bedrock agent using the configurations you provide with the request.
-
Specify the following fields for security purposes.
-
(Optional)
customerEncryptionKeyArn– The Amazon Resource Name (ARN) of a KMS key to encrypt the creation of the agent. -
(Optional)
idleSessionTTLinSeconds– Specify the number of seconds for which the agent should maintain session information. After this time expires, the subsequentInvokeInlineAgentrequest begins a new session.
-
-
To override the default prompt behavior for agent orchestration and to use advanced prompts, include a
promptOverrideConfigurationobject. For more information, see Advanced prompts. -
The agent instructions will not be honored if your agent has only one knowledge base, uses default prompts, has no action group, and user input is disabled.
Parameters:
-
customer_encryption_key_arn(Optional[KmsKeyArn], default:None) –The Amazon Resource Name (ARN) of the Amazon Web Services KMS key to use to encrypt your inline agent.
-
foundation_model(ModelIdentifier) –The model identifier (ID) of the model to use for orchestration by the inline agent. For example,
meta.llama3-1-70b-instruct-v1:0. -
instruction(Instruction) –The instructions that tell the inline agent what it should do and how it should interact with users.
-
idle_session_ttl_in_seconds(Optional[SessionTTL], default:None) –The number of seconds for which the inline agent should maintain session information. After this time expires, the subsequent
InvokeInlineAgentrequest begins a new session.A user interaction remains active for the amount of time specified. If no conversation occurs during this time, the session expires and the data provided before the timeout is deleted.
-
action_groups(Optional[AgentActionGroups], default:None) –A list of action groups with each action group defining the action the inline agent needs to carry out.
-
knowledge_bases(Optional[KnowledgeBases], default:None) –Contains information of the knowledge bases to associate with.
-
guardrail_configuration(Optional[GuardrailConfigurationWithArn], default:None) –The guardrails to assign to the inline agent.
-
prompt_override_configuration(Optional[PromptOverrideConfiguration], default:None) –Configurations for advanced prompts used to override the default prompts to enhance the accuracy of the inline agent.
-
agent_collaboration(Optional[AgentCollaboration], default:None) –Defines how the inline collaborator agent handles information across multiple collaborator agents to coordinate a final response. The inline collaborator agent can also be the supervisor.
-
collaborator_configurations(Optional[CollaboratorConfigurations], default:None) –Settings for an inline agent collaborator called with InvokeInlineAgent.
-
agent_name(Optional[Name], default:None) –The name for the agent.
-
session_id(SessionId) –The unique identifier of the session. Use the same value across requests to continue the same conversation.
-
end_session(Optional[bool], default:None) –Specifies whether to end the session with the inline agent or not.
-
enable_trace(Optional[bool], default:None) –Specifies whether to turn on the trace or not to track the agent's reasoning process. For more information, see Using trace.
-
input_text(Optional[InputText], default:None) –The prompt text to send to the agent.
If you include
returnControlInvocationResultsin thesessionStatefield, theinputTextfield will be ignored. -
streaming_configurations(Optional[StreamingConfigurations], default:None) –Specifies the configurations for streaming.
To use agent streaming, you need permissions to perform the
bedrock:InvokeModelWithResponseStreamaction. -
prompt_creation_configurations(Optional[PromptCreationConfigurations], default:None) –Specifies parameters that control how the service populates the agent prompt for an
InvokeInlineAgentrequest. You can control which aspects of previous invocations in the same agent session the service uses to populate the agent prompt. This gives you more granular control over the contextual history that is used to process the current request. -
inline_session_state(Optional[InlineSessionState], default:None) –Parameters that specify the various attributes of a sessions. You can include attributes for the session or prompt or, if you configured an action group to return control, results from invocation of the action group. For more information, see Control session context.
If you include
returnControlInvocationResultsin thesessionStatefield, theinputTextfield will be ignored. -
collaborators(Optional[Collaborators], default:None) –List of collaborator inline agents.
-
bedrock_model_configurations(Optional[InlineBedrockModelConfigurations], default:None) –Model settings for the request.
-
orchestration_type(Optional[OrchestrationType], default:None) –Specifies the type of orchestration strategy for the agent. This is set to DEFAULT orchestration type, by default.
-
custom_orchestration(Optional[CustomOrchestration], default:None) –Contains details of the custom orchestration configured for the agent.
Raises:
-
AccessDeniedException–The request is denied because of missing access permissions. Check your permissions and retry your request.
-
BadGatewayException–There was an issue with a dependency due to a server issue. Retry your request.
-
ConflictException–There was a conflict performing an operation. Resolve the conflict and retry your request.
-
DependencyFailedException–There was an issue with a dependency. Check the resource configurations and retry the request.
-
InternalServerException–An internal server error occurred. Retry your request.
-
ResourceNotFoundException–The specified resource Amazon Resource Name (ARN) was not found. Check the Amazon Resource Name (ARN) and try your request again.
-
ServiceQuotaExceededException–The number of requests exceeds the service quota. Resubmit your request later.
-
ThrottlingException–The number of requests exceeds the limit. Resubmit your request later.
-
ValidationException–Input validation failed. Check your request parameters and retry the request.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_bedrock_agent_runtime/_services/async_bedrock_agent_runtime.py
1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 | |