Skip to content

Commit 9415823

Browse files
Adds functionality to enable/disable a new Q Business Hallucination Reduction feature. If enabled, Q Business will detect and attempt to remove Hallucinations from certain Chat requests.
1 parent afb2e14 commit 9415823

18 files changed

+499
-2
lines changed

generator/ServiceModels/qbusiness/qbusiness-2023-11-27.api.json

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,7 @@
13631363
"errors":[
13641364
{"shape":"ResourceNotFoundException"},
13651365
{"shape":"InternalServerException"},
1366+
{"shape":"ConflictException"},
13661367
{"shape":"ThrottlingException"},
13671368
{"shape":"ValidationException"},
13681369
{"shape":"AccessDeniedException"},
@@ -3506,7 +3507,8 @@
35063507
"blockedPhrases":{"shape":"BlockedPhrasesConfiguration"},
35073508
"topicConfigurations":{"shape":"TopicConfigurations"},
35083509
"creatorModeConfiguration":{"shape":"AppliedCreatorModeConfiguration"},
3509-
"nextToken":{"shape":"NextToken"}
3510+
"nextToken":{"shape":"NextToken"},
3511+
"hallucinationReductionConfiguration":{"shape":"HallucinationReductionConfiguration"}
35103512
}
35113513
},
35123514
"GetDataAccessorRequest":{
@@ -3911,6 +3913,19 @@
39113913
"type":"list",
39123914
"member":{"shape":"GroupSummary"}
39133915
},
3916+
"HallucinationReductionConfiguration":{
3917+
"type":"structure",
3918+
"members":{
3919+
"hallucinationReductionControl":{"shape":"HallucinationReductionControl"}
3920+
}
3921+
},
3922+
"HallucinationReductionControl":{
3923+
"type":"string",
3924+
"enum":[
3925+
"ENABLED",
3926+
"DISABLED"
3927+
]
3928+
},
39143929
"HookConfiguration":{
39153930
"type":"structure",
39163931
"members":{
@@ -5852,6 +5867,13 @@
58525867
"min":0,
58535868
"pattern":"\\P{C}*"
58545869
},
5870+
"SystemMessageType":{
5871+
"type":"string",
5872+
"enum":[
5873+
"RESPONSE",
5874+
"GROUNDED_RESPONSE"
5875+
]
5876+
},
58555877
"Tag":{
58565878
"type":"structure",
58575879
"required":[
@@ -5923,6 +5945,7 @@
59235945
"TextOutputEvent":{
59245946
"type":"structure",
59255947
"members":{
5948+
"systemMessageType":{"shape":"SystemMessageType"},
59265949
"conversationId":{"shape":"ConversationId"},
59275950
"userMessageId":{"shape":"MessageId"},
59285951
"systemMessageId":{"shape":"MessageId"},
@@ -6070,7 +6093,8 @@
60706093
"blockedPhrasesConfigurationUpdate":{"shape":"BlockedPhrasesConfigurationUpdate"},
60716094
"topicConfigurationsToCreateOrUpdate":{"shape":"TopicConfigurations"},
60726095
"topicConfigurationsToDelete":{"shape":"TopicConfigurations"},
6073-
"creatorModeConfiguration":{"shape":"CreatorModeConfiguration"}
6096+
"creatorModeConfiguration":{"shape":"CreatorModeConfiguration"},
6097+
"hallucinationReductionConfiguration":{"shape":"HallucinationReductionConfiguration"}
60746098
}
60756099
},
60766100
"UpdateChatControlsConfigurationResponse":{

generator/ServiceModels/qbusiness/qbusiness-2023-11-27.docs.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1773,6 +1773,19 @@
17731773
"ListGroupsResponse$items": "<p>Summary information for list of groups that are mapped to users.</p>"
17741774
}
17751775
},
1776+
"HallucinationReductionConfiguration": {
1777+
"base": "<p>Configuration information required to setup hallucination reduction. For more information, see <a href=\"amazonq/latest/qbusiness-ug/hallucination-reduction.html\">hallucination reduction</a>.</p> <note> <p>The hallucination reduction feature won't work if chat orchestration controls are enabled for your application.</p> </note>",
1778+
"refs": {
1779+
"GetChatControlsConfigurationResponse$hallucinationReductionConfiguration": "<p> The hallucination reduction settings for your application.</p>",
1780+
"UpdateChatControlsConfigurationRequest$hallucinationReductionConfiguration": "<p> The hallucination reduction settings for your application.</p>"
1781+
}
1782+
},
1783+
"HallucinationReductionControl": {
1784+
"base": null,
1785+
"refs": {
1786+
"HallucinationReductionConfiguration$hallucinationReductionControl": "<p>Controls whether hallucination reduction has been enabled or disabled for your application. The default status is <code>DISABLED</code>. </p>"
1787+
}
1788+
},
17761789
"HookConfiguration": {
17771790
"base": "<p>Provides the configuration information for invoking a Lambda function in Lambda to alter document metadata and content when ingesting documents into Amazon Q Business.</p> <p>You can configure your Lambda function using the <code>PreExtractionHookConfiguration</code> parameter if you want to apply advanced alterations on the original or raw documents.</p> <p>If you want to apply advanced alterations on the Amazon Q Business structured documents, you must configure your Lambda function using <code>PostExtractionHookConfiguration</code>.</p> <p>You can only invoke one Lambda function. However, this function can invoke other functions it requires.</p> <p>For more information, see <a href=\"https://docs.aws.amazon.com/amazonq/latest/business-use-dg/custom-document-enrichment.html\">Custom document enrichment</a>. </p>",
17781791
"refs": {
@@ -3268,6 +3281,12 @@
32683281
"ContentBlockerRule$systemMessageOverride": "<p>The configured custom message displayed to an end user informing them that they've used a blocked phrase during chat.</p>"
32693282
}
32703283
},
3284+
"SystemMessageType": {
3285+
"base": null,
3286+
"refs": {
3287+
"TextOutputEvent$systemMessageType": "<p>The type of AI-generated message in a <code>TextOutputEvent</code>. Amazon Q Business currently supports two types of messages:</p> <ul> <li> <p> <code>RESPONSE</code> - The Amazon Q Business system response.</p> </li> <li> <p> <code>GROUNDED_RESPONSE</code> - The corrected, hallucination-reduced, response returned by Amazon Q Business. Available only if hallucination reduction is supported and configured for the application and detected in the end user chat query by Amazon Q Business.</p> </li> </ul>"
3288+
}
3289+
},
32713290
"Tag": {
32723291
"base": "<p>A list of key/value pairs that identify an index, FAQ, or data source. Tag keys and values can consist of Unicode letters, digits, white space, and any of the following symbols: _ . : / = + - @.</p>",
32733292
"refs": {

generator/ServiceModels/qbusiness/qbusiness-2023-11-27.normal.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,6 +1436,7 @@
14361436
"errors":[
14371437
{"shape":"ResourceNotFoundException"},
14381438
{"shape":"InternalServerException"},
1439+
{"shape":"ConflictException"},
14391440
{"shape":"ThrottlingException"},
14401441
{"shape":"ValidationException"},
14411442
{"shape":"AccessDeniedException"},
@@ -4738,6 +4739,10 @@
47384739
"nextToken":{
47394740
"shape":"NextToken",
47404741
"documentation":"<p>If the <code>maxResults</code> response was incomplete because there is more data to retrieve, Amazon Q Business returns a pagination token in the response. You can use this pagination token to retrieve the next set of Amazon Q Business chat controls configured.</p>"
4742+
},
4743+
"hallucinationReductionConfiguration":{
4744+
"shape":"HallucinationReductionConfiguration",
4745+
"documentation":"<p> The hallucination reduction settings for your application.</p>"
47414746
}
47424747
}
47434748
},
@@ -5432,6 +5437,23 @@
54325437
"type":"list",
54335438
"member":{"shape":"GroupSummary"}
54345439
},
5440+
"HallucinationReductionConfiguration":{
5441+
"type":"structure",
5442+
"members":{
5443+
"hallucinationReductionControl":{
5444+
"shape":"HallucinationReductionControl",
5445+
"documentation":"<p>Controls whether hallucination reduction has been enabled or disabled for your application. The default status is <code>DISABLED</code>. </p>"
5446+
}
5447+
},
5448+
"documentation":"<p>Configuration information required to setup hallucination reduction. For more information, see <a href=\"amazonq/latest/qbusiness-ug/hallucination-reduction.html\">hallucination reduction</a>.</p> <note> <p>The hallucination reduction feature won't work if chat orchestration controls are enabled for your application.</p> </note>"
5449+
},
5450+
"HallucinationReductionControl":{
5451+
"type":"string",
5452+
"enum":[
5453+
"ENABLED",
5454+
"DISABLED"
5455+
]
5456+
},
54355457
"HookConfiguration":{
54365458
"type":"structure",
54375459
"members":{
@@ -8048,6 +8070,13 @@
80488070
"min":0,
80498071
"pattern":"\\P{C}*"
80508072
},
8073+
"SystemMessageType":{
8074+
"type":"string",
8075+
"enum":[
8076+
"RESPONSE",
8077+
"GROUNDED_RESPONSE"
8078+
]
8079+
},
80518080
"Tag":{
80528081
"type":"structure",
80538082
"required":[
@@ -8141,6 +8170,10 @@
81418170
"TextOutputEvent":{
81428171
"type":"structure",
81438172
"members":{
8173+
"systemMessageType":{
8174+
"shape":"SystemMessageType",
8175+
"documentation":"<p>The type of AI-generated message in a <code>TextOutputEvent</code>. Amazon Q Business currently supports two types of messages:</p> <ul> <li> <p> <code>RESPONSE</code> - The Amazon Q Business system response.</p> </li> <li> <p> <code>GROUNDED_RESPONSE</code> - The corrected, hallucination-reduced, response returned by Amazon Q Business. Available only if hallucination reduction is supported and configured for the application and detected in the end user chat query by Amazon Q Business.</p> </li> </ul>"
8176+
},
81448177
"conversationId":{
81458178
"shape":"ConversationId",
81468179
"documentation":"<p>The identifier of the conversation with which the text output event is associated.</p>"
@@ -8377,6 +8410,10 @@
83778410
"creatorModeConfiguration":{
83788411
"shape":"CreatorModeConfiguration",
83798412
"documentation":"<p>The configuration details for <code>CREATOR_MODE</code>.</p>"
8413+
},
8414+
"hallucinationReductionConfiguration":{
8415+
"shape":"HallucinationReductionConfiguration",
8416+
"documentation":"<p> The hallucination reduction settings for your application.</p>"
83808417
}
83818418
}
83828419
},

sdk/src/Services/QBusiness/Generated/Model/GetChatControlsConfigurationResponse.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public partial class GetChatControlsConfigurationResponse : AmazonWebServiceResp
3636
{
3737
private BlockedPhrasesConfiguration _blockedPhrases;
3838
private AppliedCreatorModeConfiguration _creatorModeConfiguration;
39+
private HallucinationReductionConfiguration _hallucinationReductionConfiguration;
3940
private string _nextToken;
4041
private AppliedOrchestrationConfiguration _orchestrationConfiguration;
4142
private ResponseScope _responseScope;
@@ -77,6 +78,24 @@ internal bool IsSetCreatorModeConfiguration()
7778
return this._creatorModeConfiguration != null;
7879
}
7980

81+
/// <summary>
82+
/// Gets and sets the property HallucinationReductionConfiguration.
83+
/// <para>
84+
/// The hallucination reduction settings for your application.
85+
/// </para>
86+
/// </summary>
87+
public HallucinationReductionConfiguration HallucinationReductionConfiguration
88+
{
89+
get { return this._hallucinationReductionConfiguration; }
90+
set { this._hallucinationReductionConfiguration = value; }
91+
}
92+
93+
// Check to see if HallucinationReductionConfiguration property is set
94+
internal bool IsSetHallucinationReductionConfiguration()
95+
{
96+
return this._hallucinationReductionConfiguration != null;
97+
}
98+
8099
/// <summary>
81100
/// Gets and sets the property NextToken.
82101
/// <para>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
/*
17+
* Do not modify this file. This file is generated from the qbusiness-2023-11-27.normal.json service model.
18+
*/
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Xml.Serialization;
22+
using System.Text;
23+
using System.IO;
24+
using System.Net;
25+
26+
using Amazon.Runtime;
27+
using Amazon.Runtime.Internal;
28+
29+
#pragma warning disable CS0612,CS0618,CS1570
30+
namespace Amazon.QBusiness.Model
31+
{
32+
/// <summary>
33+
/// Configuration information required to setup hallucination reduction. For more information,
34+
/// see <a href="amazonq/latest/qbusiness-ug/hallucination-reduction.html">hallucination
35+
/// reduction</a>.
36+
///
37+
/// <note>
38+
/// <para>
39+
/// The hallucination reduction feature won't work if chat orchestration controls are
40+
/// enabled for your application.
41+
/// </para>
42+
/// </note>
43+
/// </summary>
44+
public partial class HallucinationReductionConfiguration
45+
{
46+
private HallucinationReductionControl _hallucinationReductionControl;
47+
48+
/// <summary>
49+
/// Gets and sets the property HallucinationReductionControl.
50+
/// <para>
51+
/// Controls whether hallucination reduction has been enabled or disabled for your application.
52+
/// The default status is <c>DISABLED</c>.
53+
/// </para>
54+
/// </summary>
55+
public HallucinationReductionControl HallucinationReductionControl
56+
{
57+
get { return this._hallucinationReductionControl; }
58+
set { this._hallucinationReductionControl = value; }
59+
}
60+
61+
// Check to see if HallucinationReductionControl property is set
62+
internal bool IsSetHallucinationReductionControl()
63+
{
64+
return this._hallucinationReductionControl != null;
65+
}
66+
67+
}
68+
}

sdk/src/Services/QBusiness/Generated/Model/Internal/MarshallTransformations/GetChatControlsConfigurationResponseUnmarshaller.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext cont
6464
response.CreatorModeConfiguration = unmarshaller.Unmarshall(context);
6565
continue;
6666
}
67+
if (context.TestExpression("hallucinationReductionConfiguration", targetDepth))
68+
{
69+
var unmarshaller = HallucinationReductionConfigurationUnmarshaller.Instance;
70+
response.HallucinationReductionConfiguration = unmarshaller.Unmarshall(context);
71+
continue;
72+
}
6773
if (context.TestExpression("nextToken", targetDepth))
6874
{
6975
var unmarshaller = StringUnmarshaller.Instance;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
/*
17+
* Do not modify this file. This file is generated from the qbusiness-2023-11-27.normal.json service model.
18+
*/
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Globalization;
22+
using System.IO;
23+
using System.Text;
24+
using System.Xml.Serialization;
25+
26+
using Amazon.QBusiness.Model;
27+
using Amazon.Runtime;
28+
using Amazon.Runtime.Internal;
29+
using Amazon.Runtime.Internal.Transform;
30+
using Amazon.Runtime.Internal.Util;
31+
using ThirdParty.Json.LitJson;
32+
33+
#pragma warning disable CS0612,CS0618
34+
namespace Amazon.QBusiness.Model.Internal.MarshallTransformations
35+
{
36+
/// <summary>
37+
/// HallucinationReductionConfiguration Marshaller
38+
/// </summary>
39+
public class HallucinationReductionConfigurationMarshaller : IRequestMarshaller<HallucinationReductionConfiguration, JsonMarshallerContext>
40+
{
41+
/// <summary>
42+
/// Unmarshaller the response from the service to the response class.
43+
/// </summary>
44+
/// <param name="requestObject"></param>
45+
/// <param name="context"></param>
46+
/// <returns></returns>
47+
public void Marshall(HallucinationReductionConfiguration requestObject, JsonMarshallerContext context)
48+
{
49+
if(requestObject == null)
50+
return;
51+
if(requestObject.IsSetHallucinationReductionControl())
52+
{
53+
context.Writer.WritePropertyName("hallucinationReductionControl");
54+
context.Writer.Write(requestObject.HallucinationReductionControl);
55+
}
56+
57+
}
58+
59+
/// <summary>
60+
/// Singleton Marshaller.
61+
/// </summary>
62+
public readonly static HallucinationReductionConfigurationMarshaller Instance = new HallucinationReductionConfigurationMarshaller();
63+
64+
}
65+
}

0 commit comments

Comments
 (0)