invokeInlineAgent method
- required String foundationModel,
- required String instruction,
- required String sessionId,
- List<
AgentActionGroup> ? actionGroups, - AgentCollaboration? agentCollaboration,
- String? agentName,
- InlineBedrockModelConfigurations? bedrockModelConfigurations,
- List<
CollaboratorConfiguration> ? collaboratorConfigurations, - List<
Collaborator> ? collaborators, - CustomOrchestration? customOrchestration,
- String? customerEncryptionKeyArn,
- bool? enableTrace,
- bool? endSession,
- GuardrailConfigurationWithArn? guardrailConfiguration,
- int? idleSessionTTLInSeconds,
- InlineSessionState? inlineSessionState,
- String? inputText,
- List<
KnowledgeBase> ? knowledgeBases, - OrchestrationType? orchestrationType,
- PromptCreationConfigurations? promptCreationConfigurations,
- PromptOverrideConfiguration? promptOverrideConfiguration,
- StreamingConfigurations? streamingConfigurations,
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.
-
(Optional)
-
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.
May throw AccessDeniedException.
May throw BadGatewayException.
May throw ConflictException.
May throw DependencyFailedException.
May throw InternalServerException.
May throw ResourceNotFoundException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter foundationModel :
The model
identifier (ID) of the model to use for orchestration by the inline
agent. For example, meta.llama3-1-70b-instruct-v1:0.
Parameter instruction :
The instructions that tell the inline agent what it should do and how it
should interact with users.
Parameter sessionId :
The unique identifier of the session. Use the same value across requests
to continue the same conversation.
Parameter actionGroups :
A list of action groups with each action group defining the action the
inline agent needs to carry out.
Parameter agentCollaboration :
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.
Parameter agentName :
The name for the agent.
Parameter bedrockModelConfigurations :
Model settings for the request.
Parameter collaboratorConfigurations :
Settings for an inline agent collaborator called with InvokeInlineAgent.
Parameter collaborators :
List of collaborator inline agents.
Parameter customOrchestration :
Contains details of the custom orchestration configured for the agent.
Parameter customerEncryptionKeyArn :
The Amazon Resource Name (ARN) of the Amazon Web Services KMS key to use
to encrypt your inline agent.
Parameter enableTrace :
Specifies whether to turn on the trace or not to track the agent's
reasoning process. For more information, see Using
trace.
Parameter endSession :
Specifies whether to end the session with the inline agent or not.
Parameter guardrailConfiguration :
The guardrails
to assign to the inline agent.
Parameter idleSessionTTLInSeconds :
The number of seconds for which the inline agent should maintain session
information. After this time expires, the subsequent
InvokeInlineAgent request 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.
Parameter inlineSessionState :
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.
Parameter inputText :
The prompt text to send to the agent.
Parameter knowledgeBases :
Contains information of the knowledge bases to associate with.
Parameter orchestrationType :
Specifies the type of orchestration strategy for the agent. This is set to
DEFAULT orchestration type, by default.
Parameter promptCreationConfigurations :
Specifies parameters that control how the service populates the agent
prompt for an InvokeInlineAgent request. 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.
Parameter promptOverrideConfiguration :
Configurations for advanced prompts used to override the default prompts
to enhance the accuracy of the inline agent.
Parameter streamingConfigurations :
Specifies the configurations for streaming.
Implementation
Future<InvokeInlineAgentResponse> invokeInlineAgent({
required String foundationModel,
required String instruction,
required String sessionId,
List<AgentActionGroup>? actionGroups,
AgentCollaboration? agentCollaboration,
String? agentName,
InlineBedrockModelConfigurations? bedrockModelConfigurations,
List<CollaboratorConfiguration>? collaboratorConfigurations,
List<Collaborator>? collaborators,
CustomOrchestration? customOrchestration,
String? customerEncryptionKeyArn,
bool? enableTrace,
bool? endSession,
GuardrailConfigurationWithArn? guardrailConfiguration,
int? idleSessionTTLInSeconds,
InlineSessionState? inlineSessionState,
String? inputText,
List<KnowledgeBase>? knowledgeBases,
OrchestrationType? orchestrationType,
PromptCreationConfigurations? promptCreationConfigurations,
PromptOverrideConfiguration? promptOverrideConfiguration,
StreamingConfigurations? streamingConfigurations,
}) async {
_s.validateNumRange(
'idleSessionTTLInSeconds',
idleSessionTTLInSeconds,
60,
3600,
);
final $payload = <String, dynamic>{
'foundationModel': foundationModel,
'instruction': instruction,
if (actionGroups != null) 'actionGroups': actionGroups,
if (agentCollaboration != null)
'agentCollaboration': agentCollaboration.value,
if (agentName != null) 'agentName': agentName,
if (bedrockModelConfigurations != null)
'bedrockModelConfigurations': bedrockModelConfigurations,
if (collaboratorConfigurations != null)
'collaboratorConfigurations': collaboratorConfigurations,
if (collaborators != null) 'collaborators': collaborators,
if (customOrchestration != null)
'customOrchestration': customOrchestration,
if (customerEncryptionKeyArn != null)
'customerEncryptionKeyArn': customerEncryptionKeyArn,
if (enableTrace != null) 'enableTrace': enableTrace,
if (endSession != null) 'endSession': endSession,
if (guardrailConfiguration != null)
'guardrailConfiguration': guardrailConfiguration,
if (idleSessionTTLInSeconds != null)
'idleSessionTTLInSeconds': idleSessionTTLInSeconds,
if (inlineSessionState != null) 'inlineSessionState': inlineSessionState,
if (inputText != null) 'inputText': inputText,
if (knowledgeBases != null) 'knowledgeBases': knowledgeBases,
if (orchestrationType != null)
'orchestrationType': orchestrationType.value,
if (promptCreationConfigurations != null)
'promptCreationConfigurations': promptCreationConfigurations,
if (promptOverrideConfiguration != null)
'promptOverrideConfiguration': promptOverrideConfiguration,
if (streamingConfigurations != null)
'streamingConfigurations': streamingConfigurations,
};
final response = await _protocol.sendRaw(
payload: $payload,
method: 'POST',
requestUri: '/agents/${Uri.encodeComponent(sessionId)}',
exceptionFnMap: _exceptionFns,
);
final $json = await _s.jsonFromResponse(response);
return InvokeInlineAgentResponse(
completion: InlineAgentResponseStream.fromJson($json),
contentType: _s.extractHeaderStringValue(
response.headers, 'x-amzn-bedrock-agent-content-type')!,
sessionId: _s.extractHeaderStringValue(
response.headers, 'x-amz-bedrock-agent-session-id')!,
);
}