Skip to content

Lex GeneralQA Intent includes <answer>\n<intent>FAQ_QUERY</intent>\n<text>

0

Hi, I have a Lex BOT that uses GeneralQA Intent with the "Knowledge base for Amazon bedrock" Sometimes the beginning of the responses includes: "<answer>\n<intent>FAQ_QUERY</intent>\n<text>"

Is this a bug?

Response snippet:

{
 "messages": [
  {
   "content": "<answer>\n<intent>FAQ_QUERY</intent>\n<text>Yes, there are several financial aid options available to students at .... (rest of the response text)    ",
   "contentType": "PlainText"
  }

Enter image description here

asked a year ago145 views
2 Answers
0
Accepted Answer

I understand that you are having a Lex BOT that uses GeneralQA Intent with the "Knowledge base for Amazon bedrock" Sometimes the beginning of the responses includes: "<answer>\n<intent>FAQ_QUERY</intent>\n<text>" This appears to be XML/markup formatting being included in the response that should typically be stripped out. While not technically a bug, it's metadata that shouldn't be visible to end users. To handle this, -Use a Lambda function as a fulfillment hook to clean/parse the response before sending it to the user. Resource: https://docs.aws.amazon.com/lexv2/latest/dg/built-in-intent-qna.html

For further queries , Contact AWS Support , they would be able to help you with better context and resource.

AWS
SUPPORT ENGINEER
answered a year ago
  • Thanks! This seems to happen when the response is long and truncated.

0
This is not a bug but rather part of the expected output format for the AMAZON.QnAIntent in Amazon Lex. 

When using the AMAZON.QnAIntent with a knowledge base (like Amazon Bedrock knowledge base), the response includes structured metadata that helps categorize the type of response being provided. The format you're seeing (`<answer>`, `<intent>FAQ_QUERY</intent>`, `<text>`) is part of the output instruction format that the model uses to structure its responses.

This format indicates:
- `<intent>FAQ_QUERY</intent>` - Shows that the model classified this as a frequently asked question
- `<text>` - Introduces the actual response content

The complete format typically includes additional elements like passage_id and confidence level. This structured format is designed to provide both the answer and metadata about how the answer was derived.

If you don't want this metadata to appear in your user-facing responses, you'll need to process the response in a Lambda function or in your client application to extract just the text portion before displaying it to your users.
  

Sources
AMAZON.QnAIntent - Amazon Lex

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.