Skip to content

query_assistant

query_assistant(
    assistant_id: UuidOrArn,
    *,
    config_overrides: Optional[QConnectClientConfig] = None,
    query_text: Optional[QueryText] = None,
    next_token: Optional[NextToken] = None,
    max_results: Optional[MaxResults] = None,
    session_id: Optional[UuidOrArn] = None,
    query_condition: Optional[QueryConditionExpression] = None,
    query_input_data: Optional[QueryInputData] = None,
    override_knowledge_base_search_type: Optional[KnowledgeBaseSearchType] = None,
) -> QueryAssistantResponse

This API will be discontinued starting June 1, 2024. To receive generative responses after March 1, 2024, you will need to create a new Assistant in the Connect Customer console and integrate the Amazon Q in Connect JavaScript library (amazon-q-connectjs) into your applications.

Performs a manual search against the specified assistant. To retrieve recommendations for an assistant, use GetRecommendations.

Parameters:

  • assistant_id (UuidOrArn) –

    The identifier of the Amazon Q in Connect assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.

  • query_text (Optional[QueryText], default: None ) –

    The text to search for.

  • next_token (Optional[NextToken], default: None ) –

    The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.

  • max_results (Optional[MaxResults], default: None ) –

    The maximum number of results to return per page.

  • session_id (Optional[UuidOrArn], default: None ) –

    The identifier of the Amazon Q in Connect session. Can be either the ID or the ARN. URLs cannot contain the ARN.

  • query_condition (Optional[QueryConditionExpression], default: None ) –

    Information about how to query content.

  • query_input_data (Optional[QueryInputData], default: None ) –

    Information about the query.

  • override_knowledge_base_search_type (Optional[KnowledgeBaseSearchType], default: None ) –

    The search type to be used against the Knowledge Base for this request. The values can be SEMANTIC which uses vector embeddings or HYBRID which use vector embeddings and raw text.

Raises:

  • AccessDeniedException –

    You do not have sufficient access to perform this action.

  • RequestTimeoutException –

    The request reached the service more than 15 minutes after the date stamp on the request or more than 15 minutes after the request expiration date (such as for pre-signed URLs), or the date stamp on the request is more than 15 minutes in the future.

  • ResourceNotFoundException –

    The specified resource does not exist.

  • ValidationException –

    The input fails to satisfy the constraints specified by a service.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_qconnect/_services/q_connect.py
def query_assistant(
    self,
    assistant_id: "capo_qconnect.types.uuid_or_arn.UuidOrArn",
    *,
    config_overrides: Optional[QConnectClientConfig] = None,
    query_text: Optional["capo_qconnect.types.query_text.QueryText"] = None,
    next_token: Optional["capo_qconnect.types.next_token.NextToken"] = None,
    max_results: Optional["capo_qconnect.types.max_results.MaxResults"] = None,
    session_id: Optional["capo_qconnect.types.uuid_or_arn.UuidOrArn"] = None,
    query_condition: Optional[
        "capo_qconnect.types.query_condition_expression.QueryConditionExpression"
    ] = None,
    query_input_data: Optional[
        "capo_qconnect.types.query_input_data.QueryInputData"
    ] = None,
    override_knowledge_base_search_type: Optional[
        "capo_qconnect.types.knowledge_base_search_type.KnowledgeBaseSearchType"
    ] = None,
) -> "capo_qconnect.types.query_assistant_response.QueryAssistantResponse":
    """<important> <p>This API will be discontinued starting June 1, 2024. To receive generative responses after March 1, 2024, you will need to create a new Assistant in the Connect Customer console and integrate the Amazon Q in Connect JavaScript library (amazon-q-connectjs) into your applications.</p> </important> <p>Performs a manual search against the specified assistant. To retrieve recommendations for an assistant, use <a href="https://docs.aws.amazon.com/amazon-q-connect/latest/APIReference/API_GetRecommendations.html">GetRecommendations</a>. </p>

    Args:
        assistant_id: <p>The identifier of the Amazon Q in Connect assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.</p>
        query_text: <p>The text to search for.</p>
        next_token: <p>The token for the next set of results. Use the value returned in the previous response in the next request to retrieve the next set of results.</p>
        max_results: <p>The maximum number of results to return per page.</p>
        session_id: <p>The identifier of the Amazon Q in Connect session. Can be either the ID or the ARN. URLs cannot contain the ARN.</p>
        query_condition: <p>Information about how to query content.</p>
        query_input_data: <p>Information about the query.</p>
        override_knowledge_base_search_type: <p>The search type to be used against the Knowledge Base for this request. The values can be <code>SEMANTIC</code> which uses vector embeddings or <code>HYBRID</code> which use vector embeddings and raw text.</p>

    Raises:
        capo_qconnect.errors.access_denied_exception.AccessDeniedException: <p>You do not have sufficient access to perform this action.</p>
        capo_qconnect.errors.request_timeout_exception.RequestTimeoutException: <p>The request reached the service more than 15 minutes after the date stamp on the request or more than 15 minutes after the request expiration date (such as for pre-signed URLs), or the date stamp on the request is more than 15 minutes in the future.</p>
        capo_qconnect.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource does not exist.</p>
        capo_qconnect.errors.validation_exception.ValidationException: <p>The input fails to satisfy the constraints specified by a service.</p>
        capo_qconnect.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_qconnect.types.query_assistant_request.QueryAssistantRequest]",
    ) -> OperationResponse[
        "capo_qconnect.types.query_assistant_response.QueryAssistantResponse"
    ]:
        import capo_qconnect._operations.wisdom_service.query_assistant

        output, http_response = (
            capo_qconnect._operations.wisdom_service.query_assistant.query_assistant(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_qconnect.types.query_assistant_request.QueryAssistantRequest",
    ) -> dict[str, Any]:
        import capo_qconnect.types.query_assistant_request

        return capo_qconnect.types.query_assistant_request.redact_sensitive(input_)

    def _redact_output(
        output: "capo_qconnect.types.query_assistant_response.QueryAssistantResponse",
    ) -> dict[str, Any]:
        import capo_qconnect.types.query_assistant_response

        return capo_qconnect.types.query_assistant_response.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "QueryAssistant",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_qconnect.types.query_assistant_request.QueryAssistantRequest = {
        "assistant_id": assistant_id
    }
    if query_text is not None:
        input_["query_text"] = query_text
    if next_token is not None:
        input_["next_token"] = next_token
    if max_results is not None:
        input_["max_results"] = max_results
    if session_id is not None:
        input_["session_id"] = session_id
    if query_condition is not None:
        input_["query_condition"] = query_condition
    if query_input_data is not None:
        input_["query_input_data"] = query_input_data
    if override_knowledge_base_search_type is not None:
        input_["override_knowledge_base_search_type"] = (
            override_knowledge_base_search_type
        )

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output