associateAgentKnowledgeBase method

Future<AssociateAgentKnowledgeBaseResponse> associateAgentKnowledgeBase({
  1. required String agentId,
  2. required String agentVersion,
  3. required String description,
  4. required String knowledgeBaseId,
  5. KnowledgeBaseState? knowledgeBaseState,
})

Associates a knowledge base with an agent. If a knowledge base is associated and its indexState is set to Enabled, the agent queries the knowledge base for information to augment its response to the user.

May throw AccessDeniedException. May throw ConflictException. May throw InternalServerException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ThrottlingException. May throw ValidationException.

Parameter agentId : The unique identifier of the agent with which you want to associate the knowledge base.

Parameter agentVersion : The version of the agent with which you want to associate the knowledge base.

Parameter description : A description of what the agent should use the knowledge base for.

Parameter knowledgeBaseId : The unique identifier of the knowledge base to associate with the agent.

Parameter knowledgeBaseState : Specifies whether to use the knowledge base or not when sending an InvokeAgent request.

Implementation

Future<AssociateAgentKnowledgeBaseResponse> associateAgentKnowledgeBase({
  required String agentId,
  required String agentVersion,
  required String description,
  required String knowledgeBaseId,
  KnowledgeBaseState? knowledgeBaseState,
}) async {
  final $payload = <String, dynamic>{
    'description': description,
    'knowledgeBaseId': knowledgeBaseId,
    if (knowledgeBaseState != null)
      'knowledgeBaseState': knowledgeBaseState.value,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'PUT',
    requestUri:
        '/agents/${Uri.encodeComponent(agentId)}/agentversions/${Uri.encodeComponent(agentVersion)}/knowledgebases/',
    exceptionFnMap: _exceptionFns,
  );
  return AssociateAgentKnowledgeBaseResponse.fromJson(response);
}