QConnect / Client / query_assistant
query_assistant¶
- QConnect.Client.query_assistant(**kwargs)¶
Warning
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 Amazon Connect 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.
Danger
This operation is deprecated and may not function as expected. This operation should not be used going forward and is only kept for the purpose of backwards compatiblity.
See also: AWS API Documentation
Request Syntax
response = client.query_assistant( assistantId='string', queryText='string', nextToken='string', maxResults=123, sessionId='string', queryCondition=[ { 'single': { 'field': 'RESULT_TYPE', 'comparator': 'EQUALS', 'value': 'string' } }, ], queryInputData={ 'queryTextInputData': { 'text': 'string' }, 'intentInputData': { 'intentId': 'string' } }, overrideKnowledgeBaseSearchType='HYBRID'|'SEMANTIC' )
- Parameters:
assistantId (string) –
[REQUIRED]
The identifier of the Amazon Q in Connect assistant. Can be either the ID or the ARN. URLs cannot contain the ARN.
queryText (string) – The text to search for.
nextToken (string) – 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.
maxResults (integer) – The maximum number of results to return per page.
sessionId (string) – The identifier of the Amazon Q in Connect session. Can be either the ID or the ARN. URLs cannot contain the ARN.
queryCondition (list) –
Information about how to query content.
(dict) –
Information about how to query content.
Note
This is a Tagged Union structure. Only one of the following top level keys can be set:
single
.single (dict) –
The condition for the query.
field (string) – [REQUIRED]
The name of the field for query condition to query on.
comparator (string) – [REQUIRED]
The comparison operator for query condition to query on.
value (string) – [REQUIRED]
The value for the query condition to query on.
queryInputData (dict) –
Information about the query.
Note
This is a Tagged Union structure. Only one of the following top level keys can be set:
queryTextInputData
,intentInputData
.queryTextInputData (dict) –
Input information for the query.
text (string) – [REQUIRED]
The text to search for.
intentInputData (dict) –
Input information for the intent.
intentId (string) – [REQUIRED]
The identifier of the Amazon Q intent.
overrideKnowledgeBaseSearchType (string) – The search type to be used against the Knowledge Base for this request. The values can be
SEMANTIC
which uses vector embeddings orHYBRID
which use vector embeddings and raw text.
- Return type:
dict
- Returns:
Response Syntax
{ 'results': [ { 'resultId': 'string', 'document': { 'contentReference': { 'knowledgeBaseArn': 'string', 'knowledgeBaseId': 'string', 'contentArn': 'string', 'contentId': 'string', 'sourceURL': 'string', 'referenceType': 'WEB_CRAWLER'|'KNOWLEDGE_BASE' }, 'title': { 'text': 'string', 'highlights': [ { 'beginOffsetInclusive': 123, 'endOffsetExclusive': 123 }, ] }, 'excerpt': { 'text': 'string', 'highlights': [ { 'beginOffsetInclusive': 123, 'endOffsetExclusive': 123 }, ] } }, 'relevanceScore': 123.0, 'data': { 'reference': { 'contentReference': { 'knowledgeBaseArn': 'string', 'knowledgeBaseId': 'string', 'contentArn': 'string', 'contentId': 'string', 'sourceURL': 'string', 'referenceType': 'WEB_CRAWLER'|'KNOWLEDGE_BASE' }, 'generativeReference': { 'modelId': 'string', 'generationId': 'string' } }, 'details': { 'contentData': { 'textData': { 'title': { 'text': 'string', 'highlights': [ { 'beginOffsetInclusive': 123, 'endOffsetExclusive': 123 }, ] }, 'excerpt': { 'text': 'string', 'highlights': [ { 'beginOffsetInclusive': 123, 'endOffsetExclusive': 123 }, ] } }, 'rankingData': { 'relevanceScore': 123.0, 'relevanceLevel': 'HIGH'|'MEDIUM'|'LOW' } }, 'generativeData': { 'completion': 'string', 'references': [ {'... recursive ...'}, ], 'rankingData': { 'relevanceScore': 123.0, 'relevanceLevel': 'HIGH'|'MEDIUM'|'LOW' } }, 'intentDetectedData': { 'intent': 'string', 'intentId': 'string' }, 'sourceContentData': { 'id': 'string', 'type': 'KNOWLEDGE_CONTENT', 'textData': { 'title': { 'text': 'string', 'highlights': [ { 'beginOffsetInclusive': 123, 'endOffsetExclusive': 123 }, ] }, 'excerpt': { 'text': 'string', 'highlights': [ { 'beginOffsetInclusive': 123, 'endOffsetExclusive': 123 }, ] } }, 'rankingData': { 'relevanceScore': 123.0, 'relevanceLevel': 'HIGH'|'MEDIUM'|'LOW' }, 'citationSpan': { 'beginOffsetInclusive': 123, 'endOffsetExclusive': 123 } }, 'generativeChunkData': { 'completion': 'string', 'references': [ {'... recursive ...'}, ], 'nextChunkToken': 'string' } } }, 'type': 'KNOWLEDGE_CONTENT'|'INTENT_ANSWER'|'GENERATIVE_ANSWER'|'GENERATIVE_ANSWER_CHUNK'|'BLOCKED_GENERATIVE_ANSWER_CHUNK'|'INTENT_ANSWER_CHUNK'|'BLOCKED_INTENT_ANSWER_CHUNK' }, ], 'nextToken': 'string' }
Response Structure
(dict) –
results (list) –
The results of the query.
(dict) –
Information about the result.
resultId (string) –
The identifier of the result data.
document (dict) –
The document.
contentReference (dict) –
A reference to the content resource.
knowledgeBaseArn (string) –
The Amazon Resource Name (ARN) of the knowledge base.
knowledgeBaseId (string) –
The identifier of the knowledge base. This should not be a QUICK_RESPONSES type knowledge base.
contentArn (string) –
The Amazon Resource Name (ARN) of the content.
contentId (string) –
The identifier of the content.
sourceURL (string) –
The web URL of the source content.
referenceType (string) –
The type of reference content.
title (dict) –
The title of the document.
text (string) –
Text in the document.
highlights (list) –
Highlights in the document text.
(dict) –
Offset specification to describe highlighting of document excerpts for rendering search results and recommendations.
beginOffsetInclusive (integer) –
The offset for the start of the highlight.
endOffsetExclusive (integer) –
The offset for the end of the highlight.
excerpt (dict) –
The excerpt from the document.
text (string) –
Text in the document.
highlights (list) –
Highlights in the document text.
(dict) –
Offset specification to describe highlighting of document excerpts for rendering search results and recommendations.
beginOffsetInclusive (integer) –
The offset for the start of the highlight.
endOffsetExclusive (integer) –
The offset for the end of the highlight.
relevanceScore (float) –
The relevance score of the results.
data (dict) –
Summary of the recommended content.
reference (dict) –
Reference information about the content.
Note
This is a Tagged Union structure. Only one of the following top level keys will be set:
contentReference
,generativeReference
. If a client receives an unknown member it will setSDK_UNKNOWN_MEMBER
as the top level key, which maps to the name or tag of the unknown member. The structure ofSDK_UNKNOWN_MEMBER
is as follows:'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
contentReference (dict) –
Reference information about the content.
knowledgeBaseArn (string) –
The Amazon Resource Name (ARN) of the knowledge base.
knowledgeBaseId (string) –
The identifier of the knowledge base. This should not be a QUICK_RESPONSES type knowledge base.
contentArn (string) –
The Amazon Resource Name (ARN) of the content.
contentId (string) –
The identifier of the content.
sourceURL (string) –
The web URL of the source content.
referenceType (string) –
The type of reference content.
generativeReference (dict) –
Reference information about the generative content.
modelId (string) –
The identifier of the LLM model.
generationId (string) –
The identifier of the LLM model.
details (dict) –
Details about the data.
Note
This is a Tagged Union structure. Only one of the following top level keys will be set:
contentData
,generativeData
,intentDetectedData
,sourceContentData
,generativeChunkData
. If a client receives an unknown member it will setSDK_UNKNOWN_MEMBER
as the top level key, which maps to the name or tag of the unknown member. The structure ofSDK_UNKNOWN_MEMBER
is as follows:'SDK_UNKNOWN_MEMBER': {'name': 'UnknownMemberName'}
contentData (dict) –
Details about the content data.
textData (dict) –
Details about the content text data.
title (dict) –
The text of the document.
text (string) –
Text in the document.
highlights (list) –
Highlights in the document text.
(dict) –
Offset specification to describe highlighting of document excerpts for rendering search results and recommendations.
beginOffsetInclusive (integer) –
The offset for the start of the highlight.
endOffsetExclusive (integer) –
The offset for the end of the highlight.
excerpt (dict) –
The text of the document.
text (string) –
Text in the document.
highlights (list) –
Highlights in the document text.
(dict) –
Offset specification to describe highlighting of document excerpts for rendering search results and recommendations.
beginOffsetInclusive (integer) –
The offset for the start of the highlight.
endOffsetExclusive (integer) –
The offset for the end of the highlight.
rankingData (dict) –
Details about the content ranking data.
relevanceScore (float) –
The relevance level of the recommendation.
relevanceLevel (string) –
The relevance score of the content.
generativeData (dict) –
Details about the generative data.
completion (string) –
The LLM response.
references (list) –
The references used to generative the LLM response.
(dict) –
Summary of the data.
rankingData (dict) –
Details about the generative content ranking data.
relevanceScore (float) –
The relevance level of the recommendation.
relevanceLevel (string) –
The relevance score of the content.
intentDetectedData (dict) –
Details about the intent data.
intent (string) –
The detected intent.
intentId (string) –
The identifier of the detected intent.
sourceContentData (dict) –
Details about the content data.
id (string) –
The identifier of the source content.
type (string) –
The type of the source content.
textData (dict) –
Details about the source content text data.
title (dict) –
The text of the document.
text (string) –
Text in the document.
highlights (list) –
Highlights in the document text.
(dict) –
Offset specification to describe highlighting of document excerpts for rendering search results and recommendations.
beginOffsetInclusive (integer) –
The offset for the start of the highlight.
endOffsetExclusive (integer) –
The offset for the end of the highlight.
excerpt (dict) –
The text of the document.
text (string) –
Text in the document.
highlights (list) –
Highlights in the document text.
(dict) –
Offset specification to describe highlighting of document excerpts for rendering search results and recommendations.
beginOffsetInclusive (integer) –
The offset for the start of the highlight.
endOffsetExclusive (integer) –
The offset for the end of the highlight.
rankingData (dict) –
Details about the source content ranking data.
relevanceScore (float) –
The relevance level of the recommendation.
relevanceLevel (string) –
The relevance score of the content.
citationSpan (dict) –
Contains information about where the text with a citation begins and ends in the generated output.
beginOffsetInclusive (integer) –
Where the text with a citation starts in the generated output.
endOffsetExclusive (integer) –
Where the text with a citation ends in the generated output.
generativeChunkData (dict) –
Details about the generative chunk data.
completion (string) –
A chunk of the LLM response.
references (list) –
The references used to generate the LLM response.
(dict) –
Summary of the data.
nextChunkToken (string) –
The token for the next set of chunks. Use the value returned in the previous response in the next request to retrieve the next set of chunks.
type (string) –
The type of the query result.
nextToken (string) –
If there are additional results, this is the token for the next set of results.
Exceptions
QConnect.Client.exceptions.RequestTimeoutException
QConnect.Client.exceptions.ValidationException
QConnect.Client.exceptions.AccessDeniedException
QConnect.Client.exceptions.ResourceNotFoundException