aws-sdk-bedrockagentruntime 1.31.0 → 1.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0456f26043768c8a899bebf3fe9e02f7f5ee664c2543ad1ab5ae243d97d00040
4
- data.tar.gz: 8e3b743740e6dba682763df127ede599c8a13d1c298984daeee302c59a9935b0
3
+ metadata.gz: 9a5c8f9ada774c7b6b0f076b035f69819f5b0d0c04912808fda03f994b242e96
4
+ data.tar.gz: 9142d0bc53700130ddda7545064b22ae00b04e60057c0643add3f5cfa1cb59c5
5
5
  SHA512:
6
- metadata.gz: c01cf4655c0cbb656e2245f6253c761a656feec75ed4872ea78bd66c8f9b363c34ced4d77d28202b238b0f459c584cc29078de74cdc76ad31868bec447c884ba
7
- data.tar.gz: 1a6a16f958c93536a30eb437c21d5b590d92c7f129edcc31c0d1fd6d74ef6c37e606c5816213ac64446e7cec62ff759f00b239f2eee87a89bd867fd0017cf275
6
+ metadata.gz: 5e5d6f501e8d9cc30c2310099696aebf003fbc3e9d2d228276643178ea15f29c819537d5942a6f63e66bfc5e7656b62a81f2fca55e114422476a91af7d22ad96
7
+ data.tar.gz: 54e0b35d92200a5b96f66ab97b14ebe698f5ff7aa4f0ed0334522b28dad7451b0270f632a4e2f75bf97c4849b8da4a3ae0ca43dbb6ca5b4d4b52ac3cb97c3461
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  Unreleased Changes
2
2
  ------------------
3
3
 
4
+ 1.32.0 (2024-11-20)
5
+ ------------------
6
+
7
+ * Feature - Releasing new Prompt Optimization to enhance your prompts for improved performance
8
+
4
9
  1.31.0 (2024-11-08)
5
10
  ------------------
6
11
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.31.0
1
+ 1.32.0
@@ -1248,7 +1248,7 @@ module Aws::BedrockAgentRuntime
1248
1248
  # Invokes an alias of a flow to run the inputs that you specify and
1249
1249
  # return the output of each node as a stream. If there's an error, the
1250
1250
  # error is returned. For more information, see [Test a flow in Amazon
1251
- # Bedrock][1] in the Amazon Bedrock User Guide.
1251
+ # Bedrock][1] in the [Amazon Bedrock User Guide][2].
1252
1252
  #
1253
1253
  # <note markdown="1"> The CLI doesn't support streaming operations in Amazon Bedrock,
1254
1254
  # including `InvokeFlow`.
@@ -1258,6 +1258,7 @@ module Aws::BedrockAgentRuntime
1258
1258
  #
1259
1259
  #
1260
1260
  # [1]: https://docs.aws.amazon.com/bedrock/latest/userguide/flows-test.html
1261
+ # [2]: https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-service.html
1261
1262
  #
1262
1263
  # @option params [Boolean] :enable_trace
1263
1264
  # Specifies whether to return the trace for the flow or not. Traces
@@ -1566,6 +1567,242 @@ module Aws::BedrockAgentRuntime
1566
1567
  req.send_request(options, &block)
1567
1568
  end
1568
1569
 
1570
+ # Optimizes a prompt for the task that you specify. For more
1571
+ # information, see [Optimize a prompt][1] in the [Amazon Bedrock User
1572
+ # Guide][2].
1573
+ #
1574
+ #
1575
+ #
1576
+ # [1]: https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-management-optimize.html
1577
+ # [2]: https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-service.html
1578
+ #
1579
+ # @option params [required, Types::InputPrompt] :input
1580
+ # Contains the prompt to optimize.
1581
+ #
1582
+ # @option params [required, String] :target_model_id
1583
+ # The unique identifier of the model that you want to optimize the
1584
+ # prompt for.
1585
+ #
1586
+ # @return [Types::OptimizePromptResponse] Returns a {Seahorse::Client::Response response} object which responds to the following methods:
1587
+ #
1588
+ # * {Types::OptimizePromptResponse#optimized_prompt #optimized_prompt} => Types::OptimizedPromptStream
1589
+ #
1590
+ # @example EventStream Operation Example
1591
+ #
1592
+ # You can process the event once it arrives immediately, or wait until the
1593
+ # full response is complete and iterate through the eventstream enumerator.
1594
+ #
1595
+ # To interact with event immediately, you need to register #optimize_prompt
1596
+ # with callbacks. Callbacks can be registered for specific events or for all
1597
+ # events, including error events.
1598
+ #
1599
+ # Callbacks can be passed into the `:event_stream_handler` option or within a
1600
+ # block statement attached to the #optimize_prompt call directly. Hybrid
1601
+ # pattern of both is also supported.
1602
+ #
1603
+ # `:event_stream_handler` option takes in either a Proc object or
1604
+ # Aws::BedrockAgentRuntime::EventStreams::OptimizedPromptStream object.
1605
+ #
1606
+ # Usage pattern a): Callbacks with a block attached to #optimize_prompt
1607
+ # Example for registering callbacks for all event types and an error event
1608
+ #
1609
+ # client.optimize_prompt( # params input# ) do |stream|
1610
+ # stream.on_error_event do |event|
1611
+ # # catch unmodeled error event in the stream
1612
+ # raise event
1613
+ # # => Aws::Errors::EventError
1614
+ # # event.event_type => :error
1615
+ # # event.error_code => String
1616
+ # # event.error_message => String
1617
+ # end
1618
+ #
1619
+ # stream.on_event do |event|
1620
+ # # process all events arrive
1621
+ # puts event.event_type
1622
+ # ...
1623
+ # end
1624
+ #
1625
+ # end
1626
+ #
1627
+ # Usage pattern b): Pass in `:event_stream_handler` for #optimize_prompt
1628
+ #
1629
+ # 1) Create a Aws::BedrockAgentRuntime::EventStreams::OptimizedPromptStream object
1630
+ # Example for registering callbacks with specific events
1631
+ #
1632
+ # handler = Aws::BedrockAgentRuntime::EventStreams::OptimizedPromptStream.new
1633
+ # handler.on_access_denied_exception_event do |event|
1634
+ # event # => Aws::BedrockAgentRuntime::Types::accessDeniedException
1635
+ # end
1636
+ # handler.on_analyze_prompt_event_event do |event|
1637
+ # event # => Aws::BedrockAgentRuntime::Types::analyzePromptEvent
1638
+ # end
1639
+ # handler.on_bad_gateway_exception_event do |event|
1640
+ # event # => Aws::BedrockAgentRuntime::Types::badGatewayException
1641
+ # end
1642
+ # handler.on_dependency_failed_exception_event do |event|
1643
+ # event # => Aws::BedrockAgentRuntime::Types::dependencyFailedException
1644
+ # end
1645
+ # handler.on_internal_server_exception_event do |event|
1646
+ # event # => Aws::BedrockAgentRuntime::Types::internalServerException
1647
+ # end
1648
+ # handler.on_optimized_prompt_event_event do |event|
1649
+ # event # => Aws::BedrockAgentRuntime::Types::optimizedPromptEvent
1650
+ # end
1651
+ # handler.on_throttling_exception_event do |event|
1652
+ # event # => Aws::BedrockAgentRuntime::Types::throttlingException
1653
+ # end
1654
+ # handler.on_validation_exception_event do |event|
1655
+ # event # => Aws::BedrockAgentRuntime::Types::validationException
1656
+ # end
1657
+ #
1658
+ # client.optimize_prompt( # params input #, event_stream_handler: handler)
1659
+ #
1660
+ # 2) Use a Ruby Proc object
1661
+ # Example for registering callbacks with specific events
1662
+ #
1663
+ # handler = Proc.new do |stream|
1664
+ # stream.on_access_denied_exception_event do |event|
1665
+ # event # => Aws::BedrockAgentRuntime::Types::accessDeniedException
1666
+ # end
1667
+ # stream.on_analyze_prompt_event_event do |event|
1668
+ # event # => Aws::BedrockAgentRuntime::Types::analyzePromptEvent
1669
+ # end
1670
+ # stream.on_bad_gateway_exception_event do |event|
1671
+ # event # => Aws::BedrockAgentRuntime::Types::badGatewayException
1672
+ # end
1673
+ # stream.on_dependency_failed_exception_event do |event|
1674
+ # event # => Aws::BedrockAgentRuntime::Types::dependencyFailedException
1675
+ # end
1676
+ # stream.on_internal_server_exception_event do |event|
1677
+ # event # => Aws::BedrockAgentRuntime::Types::internalServerException
1678
+ # end
1679
+ # stream.on_optimized_prompt_event_event do |event|
1680
+ # event # => Aws::BedrockAgentRuntime::Types::optimizedPromptEvent
1681
+ # end
1682
+ # stream.on_throttling_exception_event do |event|
1683
+ # event # => Aws::BedrockAgentRuntime::Types::throttlingException
1684
+ # end
1685
+ # stream.on_validation_exception_event do |event|
1686
+ # event # => Aws::BedrockAgentRuntime::Types::validationException
1687
+ # end
1688
+ # end
1689
+ #
1690
+ # client.optimize_prompt( # params input #, event_stream_handler: handler)
1691
+ #
1692
+ # Usage pattern c): Hybrid pattern of a) and b)
1693
+ #
1694
+ # handler = Aws::BedrockAgentRuntime::EventStreams::OptimizedPromptStream.new
1695
+ # handler.on_access_denied_exception_event do |event|
1696
+ # event # => Aws::BedrockAgentRuntime::Types::accessDeniedException
1697
+ # end
1698
+ # handler.on_analyze_prompt_event_event do |event|
1699
+ # event # => Aws::BedrockAgentRuntime::Types::analyzePromptEvent
1700
+ # end
1701
+ # handler.on_bad_gateway_exception_event do |event|
1702
+ # event # => Aws::BedrockAgentRuntime::Types::badGatewayException
1703
+ # end
1704
+ # handler.on_dependency_failed_exception_event do |event|
1705
+ # event # => Aws::BedrockAgentRuntime::Types::dependencyFailedException
1706
+ # end
1707
+ # handler.on_internal_server_exception_event do |event|
1708
+ # event # => Aws::BedrockAgentRuntime::Types::internalServerException
1709
+ # end
1710
+ # handler.on_optimized_prompt_event_event do |event|
1711
+ # event # => Aws::BedrockAgentRuntime::Types::optimizedPromptEvent
1712
+ # end
1713
+ # handler.on_throttling_exception_event do |event|
1714
+ # event # => Aws::BedrockAgentRuntime::Types::throttlingException
1715
+ # end
1716
+ # handler.on_validation_exception_event do |event|
1717
+ # event # => Aws::BedrockAgentRuntime::Types::validationException
1718
+ # end
1719
+ #
1720
+ # client.optimize_prompt( # params input #, event_stream_handler: handler) do |stream|
1721
+ # stream.on_error_event do |event|
1722
+ # # catch unmodeled error event in the stream
1723
+ # raise event
1724
+ # # => Aws::Errors::EventError
1725
+ # # event.event_type => :error
1726
+ # # event.error_code => String
1727
+ # # event.error_message => String
1728
+ # end
1729
+ # end
1730
+ #
1731
+ # You can also iterate through events after the response complete.
1732
+ #
1733
+ # Events are available at resp.optimized_prompt # => Enumerator
1734
+ # For parameter input example, please refer to following request syntax
1735
+ #
1736
+ # @example Request syntax with placeholder values
1737
+ #
1738
+ # resp = client.optimize_prompt({
1739
+ # input: { # required
1740
+ # text_prompt: {
1741
+ # text: "TextPromptTextString", # required
1742
+ # },
1743
+ # },
1744
+ # target_model_id: "OptimizePromptRequestTargetModelIdString", # required
1745
+ # })
1746
+ #
1747
+ # @example Response structure
1748
+ #
1749
+ # All events are available at resp.optimized_prompt:
1750
+ # resp.optimized_prompt #=> Enumerator
1751
+ # resp.optimized_prompt.event_types #=> [:access_denied_exception, :analyze_prompt_event, :bad_gateway_exception, :dependency_failed_exception, :internal_server_exception, :optimized_prompt_event, :throttling_exception, :validation_exception]
1752
+ #
1753
+ # For :access_denied_exception event available at #on_access_denied_exception_event callback and response eventstream enumerator:
1754
+ # event.message #=> String
1755
+ #
1756
+ # For :analyze_prompt_event event available at #on_analyze_prompt_event_event callback and response eventstream enumerator:
1757
+ # event.message #=> String
1758
+ #
1759
+ # For :bad_gateway_exception event available at #on_bad_gateway_exception_event callback and response eventstream enumerator:
1760
+ # event.message #=> String
1761
+ # event.resource_name #=> String
1762
+ #
1763
+ # For :dependency_failed_exception event available at #on_dependency_failed_exception_event callback and response eventstream enumerator:
1764
+ # event.message #=> String
1765
+ # event.resource_name #=> String
1766
+ #
1767
+ # For :internal_server_exception event available at #on_internal_server_exception_event callback and response eventstream enumerator:
1768
+ # event.message #=> String
1769
+ #
1770
+ # For :optimized_prompt_event event available at #on_optimized_prompt_event_event callback and response eventstream enumerator:
1771
+ # event.optimized_prompt.text_prompt.text #=> String
1772
+ #
1773
+ # For :throttling_exception event available at #on_throttling_exception_event callback and response eventstream enumerator:
1774
+ # event.message #=> String
1775
+ #
1776
+ # For :validation_exception event available at #on_validation_exception_event callback and response eventstream enumerator:
1777
+ # event.message #=> String
1778
+ #
1779
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-agent-runtime-2023-07-26/OptimizePrompt AWS API Documentation
1780
+ #
1781
+ # @overload optimize_prompt(params = {})
1782
+ # @param [Hash] params ({})
1783
+ def optimize_prompt(params = {}, options = {}, &block)
1784
+ params = params.dup
1785
+ event_stream_handler = case handler = params.delete(:event_stream_handler)
1786
+ when EventStreams::OptimizedPromptStream then handler
1787
+ when Proc then EventStreams::OptimizedPromptStream.new.tap(&handler)
1788
+ when nil then EventStreams::OptimizedPromptStream.new
1789
+ else
1790
+ msg = "expected :event_stream_handler to be a block or "\
1791
+ "instance of Aws::BedrockAgentRuntime::EventStreams::OptimizedPromptStream"\
1792
+ ", got `#{handler.inspect}` instead"
1793
+ raise ArgumentError, msg
1794
+ end
1795
+
1796
+ yield(event_stream_handler) if block_given?
1797
+
1798
+ req = build_request(:optimize_prompt, params)
1799
+
1800
+ req.context[:event_stream_handler] = event_stream_handler
1801
+ req.handlers.add(Aws::Binary::DecodeHandler, priority: 95)
1802
+
1803
+ req.send_request(options, &block)
1804
+ end
1805
+
1569
1806
  # Queries a knowledge base and retrieves information from it.
1570
1807
  #
1571
1808
  # @option params [required, String] :knowledge_base_id
@@ -1954,7 +2191,7 @@ module Aws::BedrockAgentRuntime
1954
2191
  tracer: tracer
1955
2192
  )
1956
2193
  context[:gem_name] = 'aws-sdk-bedrockagentruntime'
1957
- context[:gem_version] = '1.31.0'
2194
+ context[:gem_version] = '1.32.0'
1958
2195
  Seahorse::Client::Request.new(handlers, context)
1959
2196
  end
1960
2197
 
@@ -26,6 +26,7 @@ module Aws::BedrockAgentRuntime
26
26
  AgentAliasId = Shapes::StringShape.new(name: 'AgentAliasId')
27
27
  AgentId = Shapes::StringShape.new(name: 'AgentId')
28
28
  AgentVersion = Shapes::StringShape.new(name: 'AgentVersion')
29
+ AnalyzePromptEvent = Shapes::StructureShape.new(name: 'AnalyzePromptEvent')
29
30
  ApiContentMap = Shapes::MapShape.new(name: 'ApiContentMap')
30
31
  ApiInvocationInput = Shapes::StructureShape.new(name: 'ApiInvocationInput')
31
32
  ApiParameter = Shapes::StructureShape.new(name: 'ApiParameter')
@@ -145,6 +146,7 @@ module Aws::BedrockAgentRuntime
145
146
  InferenceConfiguration = Shapes::StructureShape.new(name: 'InferenceConfiguration')
146
147
  InputFile = Shapes::StructureShape.new(name: 'InputFile')
147
148
  InputFiles = Shapes::ListShape.new(name: 'InputFiles')
149
+ InputPrompt = Shapes::UnionShape.new(name: 'InputPrompt')
148
150
  InputText = Shapes::StringShape.new(name: 'InputText')
149
151
  Integer = Shapes::IntegerShape.new(name: 'Integer')
150
152
  InternalServerException = Shapes::StructureShape.new(name: 'InternalServerException')
@@ -191,6 +193,12 @@ module Aws::BedrockAgentRuntime
191
193
  NodeType = Shapes::StringShape.new(name: 'NodeType')
192
194
  NonBlankString = Shapes::StringShape.new(name: 'NonBlankString')
193
195
  Observation = Shapes::StructureShape.new(name: 'Observation')
196
+ OptimizePromptRequest = Shapes::StructureShape.new(name: 'OptimizePromptRequest')
197
+ OptimizePromptRequestTargetModelIdString = Shapes::StringShape.new(name: 'OptimizePromptRequestTargetModelIdString')
198
+ OptimizePromptResponse = Shapes::StructureShape.new(name: 'OptimizePromptResponse')
199
+ OptimizedPrompt = Shapes::UnionShape.new(name: 'OptimizedPrompt')
200
+ OptimizedPromptEvent = Shapes::StructureShape.new(name: 'OptimizedPromptEvent')
201
+ OptimizedPromptStream = Shapes::StructureShape.new(name: 'OptimizedPromptStream')
194
202
  OrchestrationConfiguration = Shapes::StructureShape.new(name: 'OrchestrationConfiguration')
195
203
  OrchestrationModelInvocationOutput = Shapes::StructureShape.new(name: 'OrchestrationModelInvocationOutput')
196
204
  OrchestrationTrace = Shapes::UnionShape.new(name: 'OrchestrationTrace')
@@ -270,7 +278,9 @@ module Aws::BedrockAgentRuntime
270
278
  SummaryText = Shapes::StringShape.new(name: 'SummaryText')
271
279
  Temperature = Shapes::FloatShape.new(name: 'Temperature')
272
280
  TextInferenceConfig = Shapes::StructureShape.new(name: 'TextInferenceConfig')
281
+ TextPrompt = Shapes::StructureShape.new(name: 'TextPrompt')
273
282
  TextPromptTemplate = Shapes::StringShape.new(name: 'TextPromptTemplate')
283
+ TextPromptTextString = Shapes::StringShape.new(name: 'TextPromptTextString')
274
284
  TextResponsePart = Shapes::StructureShape.new(name: 'TextResponsePart')
275
285
  ThrottlingException = Shapes::StructureShape.new(name: 'ThrottlingException')
276
286
  TopK = Shapes::IntegerShape.new(name: 'TopK')
@@ -303,6 +313,9 @@ module Aws::BedrockAgentRuntime
303
313
  AdditionalModelRequestFields.key = Shapes::ShapeRef.new(shape: AdditionalModelRequestFieldsKey)
304
314
  AdditionalModelRequestFields.value = Shapes::ShapeRef.new(shape: AdditionalModelRequestFieldsValue)
305
315
 
316
+ AnalyzePromptEvent.add_member(:message, Shapes::ShapeRef.new(shape: String, location_name: "message"))
317
+ AnalyzePromptEvent.struct_class = Types::AnalyzePromptEvent
318
+
306
319
  ApiContentMap.key = Shapes::ShapeRef.new(shape: String)
307
320
  ApiContentMap.value = Shapes::ShapeRef.new(shape: PropertyParameters)
308
321
 
@@ -654,6 +667,12 @@ module Aws::BedrockAgentRuntime
654
667
 
655
668
  InputFiles.member = Shapes::ShapeRef.new(shape: InputFile)
656
669
 
670
+ InputPrompt.add_member(:text_prompt, Shapes::ShapeRef.new(shape: TextPrompt, location_name: "textPrompt"))
671
+ InputPrompt.add_member(:unknown, Shapes::ShapeRef.new(shape: nil, location_name: 'unknown'))
672
+ InputPrompt.add_member_subclass(:text_prompt, Types::InputPrompt::TextPrompt)
673
+ InputPrompt.add_member_subclass(:unknown, Types::InputPrompt::Unknown)
674
+ InputPrompt.struct_class = Types::InputPrompt
675
+
657
676
  InternalServerException.add_member(:message, Shapes::ShapeRef.new(shape: NonBlankString, location_name: "message"))
658
677
  InternalServerException.struct_class = Types::InternalServerException
659
678
 
@@ -786,6 +805,34 @@ module Aws::BedrockAgentRuntime
786
805
  Observation.add_member(:type, Shapes::ShapeRef.new(shape: Type, location_name: "type"))
787
806
  Observation.struct_class = Types::Observation
788
807
 
808
+ OptimizePromptRequest.add_member(:input, Shapes::ShapeRef.new(shape: InputPrompt, required: true, location_name: "input"))
809
+ OptimizePromptRequest.add_member(:target_model_id, Shapes::ShapeRef.new(shape: OptimizePromptRequestTargetModelIdString, required: true, location_name: "targetModelId"))
810
+ OptimizePromptRequest.struct_class = Types::OptimizePromptRequest
811
+
812
+ OptimizePromptResponse.add_member(:optimized_prompt, Shapes::ShapeRef.new(shape: OptimizedPromptStream, required: true, eventstream: true, location_name: "optimizedPrompt"))
813
+ OptimizePromptResponse.struct_class = Types::OptimizePromptResponse
814
+ OptimizePromptResponse[:payload] = :optimized_prompt
815
+ OptimizePromptResponse[:payload_member] = OptimizePromptResponse.member(:optimized_prompt)
816
+
817
+ OptimizedPrompt.add_member(:text_prompt, Shapes::ShapeRef.new(shape: TextPrompt, location_name: "textPrompt"))
818
+ OptimizedPrompt.add_member(:unknown, Shapes::ShapeRef.new(shape: nil, location_name: 'unknown'))
819
+ OptimizedPrompt.add_member_subclass(:text_prompt, Types::OptimizedPrompt::TextPrompt)
820
+ OptimizedPrompt.add_member_subclass(:unknown, Types::OptimizedPrompt::Unknown)
821
+ OptimizedPrompt.struct_class = Types::OptimizedPrompt
822
+
823
+ OptimizedPromptEvent.add_member(:optimized_prompt, Shapes::ShapeRef.new(shape: OptimizedPrompt, location_name: "optimizedPrompt"))
824
+ OptimizedPromptEvent.struct_class = Types::OptimizedPromptEvent
825
+
826
+ OptimizedPromptStream.add_member(:access_denied_exception, Shapes::ShapeRef.new(shape: AccessDeniedException, location_name: "accessDeniedException"))
827
+ OptimizedPromptStream.add_member(:analyze_prompt_event, Shapes::ShapeRef.new(shape: AnalyzePromptEvent, event: true, location_name: "analyzePromptEvent"))
828
+ OptimizedPromptStream.add_member(:bad_gateway_exception, Shapes::ShapeRef.new(shape: BadGatewayException, location_name: "badGatewayException"))
829
+ OptimizedPromptStream.add_member(:dependency_failed_exception, Shapes::ShapeRef.new(shape: DependencyFailedException, location_name: "dependencyFailedException"))
830
+ OptimizedPromptStream.add_member(:internal_server_exception, Shapes::ShapeRef.new(shape: InternalServerException, location_name: "internalServerException"))
831
+ OptimizedPromptStream.add_member(:optimized_prompt_event, Shapes::ShapeRef.new(shape: OptimizedPromptEvent, event: true, location_name: "optimizedPromptEvent"))
832
+ OptimizedPromptStream.add_member(:throttling_exception, Shapes::ShapeRef.new(shape: ThrottlingException, location_name: "throttlingException"))
833
+ OptimizedPromptStream.add_member(:validation_exception, Shapes::ShapeRef.new(shape: ValidationException, location_name: "validationException"))
834
+ OptimizedPromptStream.struct_class = Types::OptimizedPromptStream
835
+
789
836
  OrchestrationConfiguration.add_member(:additional_model_request_fields, Shapes::ShapeRef.new(shape: AdditionalModelRequestFields, location_name: "additionalModelRequestFields"))
790
837
  OrchestrationConfiguration.add_member(:inference_config, Shapes::ShapeRef.new(shape: InferenceConfig, location_name: "inferenceConfig"))
791
838
  OrchestrationConfiguration.add_member(:prompt_template, Shapes::ShapeRef.new(shape: PromptTemplate, location_name: "promptTemplate"))
@@ -1057,6 +1104,9 @@ module Aws::BedrockAgentRuntime
1057
1104
  TextInferenceConfig.add_member(:top_p, Shapes::ShapeRef.new(shape: TopP, location_name: "topP"))
1058
1105
  TextInferenceConfig.struct_class = Types::TextInferenceConfig
1059
1106
 
1107
+ TextPrompt.add_member(:text, Shapes::ShapeRef.new(shape: TextPromptTextString, required: true, location_name: "text"))
1108
+ TextPrompt.struct_class = Types::TextPrompt
1109
+
1060
1110
  TextResponsePart.add_member(:span, Shapes::ShapeRef.new(shape: Span, location_name: "span"))
1061
1111
  TextResponsePart.add_member(:text, Shapes::ShapeRef.new(shape: String, location_name: "text"))
1062
1112
  TextResponsePart.struct_class = Types::TextResponsePart
@@ -1186,6 +1236,20 @@ module Aws::BedrockAgentRuntime
1186
1236
  o.errors << Shapes::ShapeRef.new(shape: ServiceQuotaExceededException)
1187
1237
  end)
1188
1238
 
1239
+ api.add_operation(:optimize_prompt, Seahorse::Model::Operation.new.tap do |o|
1240
+ o.name = "OptimizePrompt"
1241
+ o.http_method = "POST"
1242
+ o.http_request_uri = "/optimize-prompt"
1243
+ o.input = Shapes::ShapeRef.new(shape: OptimizePromptRequest)
1244
+ o.output = Shapes::ShapeRef.new(shape: OptimizePromptResponse)
1245
+ o.errors << Shapes::ShapeRef.new(shape: ValidationException)
1246
+ o.errors << Shapes::ShapeRef.new(shape: InternalServerException)
1247
+ o.errors << Shapes::ShapeRef.new(shape: DependencyFailedException)
1248
+ o.errors << Shapes::ShapeRef.new(shape: BadGatewayException)
1249
+ o.errors << Shapes::ShapeRef.new(shape: ThrottlingException)
1250
+ o.errors << Shapes::ShapeRef.new(shape: AccessDeniedException)
1251
+ end)
1252
+
1189
1253
  api.add_operation(:retrieve, Seahorse::Model::Operation.new.tap do |o|
1190
1254
  o.name = "Retrieve"
1191
1255
  o.http_method = "POST"
@@ -192,6 +192,75 @@ module Aws::BedrockAgentRuntime
192
192
  attr_reader :event_emitter
193
193
 
194
194
  end
195
+ class OptimizedPromptStream
196
+
197
+ def initialize
198
+ @event_emitter = Aws::EventEmitter.new
199
+ end
200
+
201
+ def on_access_denied_exception_event(&block)
202
+ @event_emitter.on(:access_denied_exception, block) if block_given?
203
+ end
204
+
205
+ def on_analyze_prompt_event_event(&block)
206
+ @event_emitter.on(:analyze_prompt_event, block) if block_given?
207
+ end
208
+
209
+ def on_bad_gateway_exception_event(&block)
210
+ @event_emitter.on(:bad_gateway_exception, block) if block_given?
211
+ end
212
+
213
+ def on_dependency_failed_exception_event(&block)
214
+ @event_emitter.on(:dependency_failed_exception, block) if block_given?
215
+ end
216
+
217
+ def on_internal_server_exception_event(&block)
218
+ @event_emitter.on(:internal_server_exception, block) if block_given?
219
+ end
220
+
221
+ def on_optimized_prompt_event_event(&block)
222
+ @event_emitter.on(:optimized_prompt_event, block) if block_given?
223
+ end
224
+
225
+ def on_throttling_exception_event(&block)
226
+ @event_emitter.on(:throttling_exception, block) if block_given?
227
+ end
228
+
229
+ def on_validation_exception_event(&block)
230
+ @event_emitter.on(:validation_exception, block) if block_given?
231
+ end
232
+
233
+ def on_error_event(&block)
234
+ @event_emitter.on(:error, block) if block_given?
235
+ end
236
+
237
+ def on_initial_response_event(&block)
238
+ @event_emitter.on(:initial_response, block) if block_given?
239
+ end
240
+
241
+ def on_unknown_event(&block)
242
+ @event_emitter.on(:unknown_event, block) if block_given?
243
+ end
244
+
245
+ def on_event(&block)
246
+ on_access_denied_exception_event(&block)
247
+ on_analyze_prompt_event_event(&block)
248
+ on_bad_gateway_exception_event(&block)
249
+ on_dependency_failed_exception_event(&block)
250
+ on_internal_server_exception_event(&block)
251
+ on_optimized_prompt_event_event(&block)
252
+ on_throttling_exception_event(&block)
253
+ on_validation_exception_event(&block)
254
+ on_error_event(&block)
255
+ on_initial_response_event(&block)
256
+ on_unknown_event(&block)
257
+ end
258
+
259
+ # @api private
260
+ # @return Aws::EventEmitter
261
+ attr_reader :event_emitter
262
+
263
+ end
195
264
 
196
265
  end
197
266
  end
@@ -27,11 +27,12 @@ module Aws::BedrockAgentRuntime
27
27
 
28
28
  # Contains information about the action group being invoked. For more
29
29
  # information about the possible structures, see the InvocationInput tab
30
- # in [OrchestrationTrace][1] in the Amazon Bedrock User Guide.
30
+ # in [OrchestrationTrace][1] in the [Amazon Bedrock User Guide][2].
31
31
  #
32
32
  #
33
33
  #
34
34
  # [1]: https://docs.aws.amazon.com/bedrock/latest/userguide/trace-orchestration.html
35
+ # [2]: https://docs.aws.amazon.com/bedrock/latest/userguide/what-is-service.html
35
36
  #
36
37
  # @!attribute [rw] action_group_name
37
38
  # The name of the action group.
@@ -102,6 +103,22 @@ module Aws::BedrockAgentRuntime
102
103
  include Aws::Structure
103
104
  end
104
105
 
106
+ # An event in which the prompt was analyzed in preparation for
107
+ # optimization.
108
+ #
109
+ # @!attribute [rw] message
110
+ # A message describing the analysis of the prompt.
111
+ # @return [String]
112
+ #
113
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-agent-runtime-2023-07-26/AnalyzePromptEvent AWS API Documentation
114
+ #
115
+ class AnalyzePromptEvent < Struct.new(
116
+ :message,
117
+ :event_type)
118
+ SENSITIVE = []
119
+ include Aws::Structure
120
+ end
121
+
105
122
  # Contains information about the API operation that the agent predicts
106
123
  # should be called.
107
124
  #
@@ -1769,6 +1786,27 @@ module Aws::BedrockAgentRuntime
1769
1786
  include Aws::Structure
1770
1787
  end
1771
1788
 
1789
+ # Contains information about the prompt to optimize.
1790
+ #
1791
+ # @note InputPrompt is a union - when making an API calls you must set exactly one of the members.
1792
+ #
1793
+ # @!attribute [rw] text_prompt
1794
+ # Contains information about the text prompt to optimize.
1795
+ # @return [Types::TextPrompt]
1796
+ #
1797
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-agent-runtime-2023-07-26/InputPrompt AWS API Documentation
1798
+ #
1799
+ class InputPrompt < Struct.new(
1800
+ :text_prompt,
1801
+ :unknown)
1802
+ SENSITIVE = [:text_prompt]
1803
+ include Aws::Structure
1804
+ include Aws::Structure::Union
1805
+
1806
+ class TextPrompt < InputPrompt; end
1807
+ class Unknown < InputPrompt; end
1808
+ end
1809
+
1772
1810
  # An internal server error occurred. Retry your request.
1773
1811
  #
1774
1812
  # @!attribute [rw] message
@@ -2527,6 +2565,73 @@ module Aws::BedrockAgentRuntime
2527
2565
  include Aws::Structure
2528
2566
  end
2529
2567
 
2568
+ # @!attribute [rw] input
2569
+ # Contains the prompt to optimize.
2570
+ # @return [Types::InputPrompt]
2571
+ #
2572
+ # @!attribute [rw] target_model_id
2573
+ # The unique identifier of the model that you want to optimize the
2574
+ # prompt for.
2575
+ # @return [String]
2576
+ #
2577
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-agent-runtime-2023-07-26/OptimizePromptRequest AWS API Documentation
2578
+ #
2579
+ class OptimizePromptRequest < Struct.new(
2580
+ :input,
2581
+ :target_model_id)
2582
+ SENSITIVE = []
2583
+ include Aws::Structure
2584
+ end
2585
+
2586
+ # @!attribute [rw] optimized_prompt
2587
+ # The prompt after being optimized for the task.
2588
+ # @return [Types::OptimizedPromptStream]
2589
+ #
2590
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-agent-runtime-2023-07-26/OptimizePromptResponse AWS API Documentation
2591
+ #
2592
+ class OptimizePromptResponse < Struct.new(
2593
+ :optimized_prompt)
2594
+ SENSITIVE = []
2595
+ include Aws::Structure
2596
+ end
2597
+
2598
+ # Contains information about the optimized prompt.
2599
+ #
2600
+ # @note OptimizedPrompt is a union - when returned from an API call exactly one value will be set and the returned type will be a subclass of OptimizedPrompt corresponding to the set member.
2601
+ #
2602
+ # @!attribute [rw] text_prompt
2603
+ # Contains information about the text in the prompt that was
2604
+ # optimized.
2605
+ # @return [Types::TextPrompt]
2606
+ #
2607
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-agent-runtime-2023-07-26/OptimizedPrompt AWS API Documentation
2608
+ #
2609
+ class OptimizedPrompt < Struct.new(
2610
+ :text_prompt,
2611
+ :unknown)
2612
+ SENSITIVE = [:text_prompt]
2613
+ include Aws::Structure
2614
+ include Aws::Structure::Union
2615
+
2616
+ class TextPrompt < OptimizedPrompt; end
2617
+ class Unknown < OptimizedPrompt; end
2618
+ end
2619
+
2620
+ # An event in which the prompt was optimized.
2621
+ #
2622
+ # @!attribute [rw] optimized_prompt
2623
+ # Contains information about the optimized prompt.
2624
+ # @return [Types::OptimizedPrompt]
2625
+ #
2626
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-agent-runtime-2023-07-26/OptimizedPromptEvent AWS API Documentation
2627
+ #
2628
+ class OptimizedPromptEvent < Struct.new(
2629
+ :optimized_prompt,
2630
+ :event_type)
2631
+ SENSITIVE = []
2632
+ include Aws::Structure
2633
+ end
2634
+
2530
2635
  # Settings for how the model processes the prompt prior to retrieval and
2531
2636
  # generation.
2532
2637
  #
@@ -3949,6 +4054,20 @@ module Aws::BedrockAgentRuntime
3949
4054
  include Aws::Structure
3950
4055
  end
3951
4056
 
4057
+ # Contains information about the text prompt to optimize.
4058
+ #
4059
+ # @!attribute [rw] text
4060
+ # The text in the text prompt to optimize.
4061
+ # @return [String]
4062
+ #
4063
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-agent-runtime-2023-07-26/TextPrompt AWS API Documentation
4064
+ #
4065
+ class TextPrompt < Struct.new(
4066
+ :text)
4067
+ SENSITIVE = []
4068
+ include Aws::Structure
4069
+ end
4070
+
3952
4071
  # Contains the part of the generated text that contains a citation,
3953
4072
  # alongside where it begins and ends.
3954
4073
  #
@@ -4166,6 +4285,30 @@ module Aws::BedrockAgentRuntime
4166
4285
 
4167
4286
  end
4168
4287
 
4288
+ # The stream containing events in the prompt optimization process.
4289
+ #
4290
+ # EventStream is an Enumerator of Events.
4291
+ # #event_types #=> Array, returns all modeled event types in the stream
4292
+ #
4293
+ # @see http://docs.aws.amazon.com/goto/WebAPI/bedrock-agent-runtime-2023-07-26/OptimizedPromptStream AWS API Documentation
4294
+ #
4295
+ class OptimizedPromptStream < Enumerator
4296
+
4297
+ def event_types
4298
+ [
4299
+ :access_denied_exception,
4300
+ :analyze_prompt_event,
4301
+ :bad_gateway_exception,
4302
+ :dependency_failed_exception,
4303
+ :internal_server_exception,
4304
+ :optimized_prompt_event,
4305
+ :throttling_exception,
4306
+ :validation_exception
4307
+ ]
4308
+ end
4309
+
4310
+ end
4311
+
4169
4312
  # The response from invoking the agent and associated citations and
4170
4313
  # trace information.
4171
4314
  #
@@ -55,7 +55,7 @@ module Aws::BedrockAgentRuntime
55
55
  autoload :Endpoints, 'aws-sdk-bedrockagentruntime/endpoints'
56
56
  autoload :EventStreams, 'aws-sdk-bedrockagentruntime/event_streams'
57
57
 
58
- GEM_VERSION = '1.31.0'
58
+ GEM_VERSION = '1.32.0'
59
59
 
60
60
  end
61
61
 
data/sig/client.rbs CHANGED
@@ -265,6 +265,21 @@ module Aws
265
265
  ) ?{ (*untyped) -> void } -> _InvokeFlowResponseSuccess
266
266
  | (Hash[Symbol, untyped] params, ?Hash[Symbol, untyped] options) ?{ (*untyped) -> void } -> _InvokeFlowResponseSuccess
267
267
 
268
+ interface _OptimizePromptResponseSuccess
269
+ include ::Seahorse::Client::_ResponseSuccess[Types::OptimizePromptResponse]
270
+ def optimized_prompt: () -> Types::OptimizedPromptStream
271
+ end
272
+ # https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/BedrockAgentRuntime/Client.html#optimize_prompt-instance_method
273
+ def optimize_prompt: (
274
+ input: {
275
+ text_prompt: {
276
+ text: ::String
277
+ }?
278
+ },
279
+ target_model_id: ::String
280
+ ) ?{ (*untyped) -> void } -> _OptimizePromptResponseSuccess
281
+ | (Hash[Symbol, untyped] params, ?Hash[Symbol, untyped] options) ?{ (*untyped) -> void } -> _OptimizePromptResponseSuccess
282
+
268
283
  interface _RetrieveResponseSuccess
269
284
  include ::Seahorse::Client::_ResponseSuccess[Types::RetrieveResponse]
270
285
  def next_token: () -> ::String
data/sig/types.rbs CHANGED
@@ -31,6 +31,12 @@ module Aws::BedrockAgentRuntime
31
31
  SENSITIVE: [:text]
32
32
  end
33
33
 
34
+ class AnalyzePromptEvent
35
+ attr_accessor message: ::String
36
+ attr_accessor event_type: untyped
37
+ SENSITIVE: []
38
+ end
39
+
34
40
  class ApiInvocationInput
35
41
  attr_accessor action_group: ::String
36
42
  attr_accessor action_invocation_type: ("RESULT" | "USER_CONFIRMATION" | "USER_CONFIRMATION_AND_RESULT")
@@ -475,6 +481,17 @@ module Aws::BedrockAgentRuntime
475
481
  SENSITIVE: []
476
482
  end
477
483
 
484
+ class InputPrompt
485
+ attr_accessor text_prompt: Types::TextPrompt
486
+ attr_accessor unknown: untyped
487
+ SENSITIVE: [:text_prompt]
488
+
489
+ class TextPrompt < InputPrompt
490
+ end
491
+ class Unknown < InputPrompt
492
+ end
493
+ end
494
+
478
495
  class InternalServerException
479
496
  attr_accessor message: ::String
480
497
  attr_accessor event_type: untyped
@@ -649,6 +666,34 @@ module Aws::BedrockAgentRuntime
649
666
  SENSITIVE: [:reprompt_response]
650
667
  end
651
668
 
669
+ class OptimizePromptRequest
670
+ attr_accessor input: Types::InputPrompt
671
+ attr_accessor target_model_id: ::String
672
+ SENSITIVE: []
673
+ end
674
+
675
+ class OptimizePromptResponse
676
+ attr_accessor optimized_prompt: Types::OptimizedPromptStream
677
+ SENSITIVE: []
678
+ end
679
+
680
+ class OptimizedPrompt
681
+ attr_accessor text_prompt: Types::TextPrompt
682
+ attr_accessor unknown: untyped
683
+ SENSITIVE: [:text_prompt]
684
+
685
+ class TextPrompt < OptimizedPrompt
686
+ end
687
+ class Unknown < OptimizedPrompt
688
+ end
689
+ end
690
+
691
+ class OptimizedPromptEvent
692
+ attr_accessor optimized_prompt: Types::OptimizedPrompt
693
+ attr_accessor event_type: untyped
694
+ SENSITIVE: []
695
+ end
696
+
652
697
  class OrchestrationConfiguration
653
698
  attr_accessor additional_model_request_fields: ::Hash[::String, untyped]
654
699
  attr_accessor inference_config: Types::InferenceConfig
@@ -999,6 +1044,11 @@ module Aws::BedrockAgentRuntime
999
1044
  SENSITIVE: []
1000
1045
  end
1001
1046
 
1047
+ class TextPrompt
1048
+ attr_accessor text: ::String
1049
+ SENSITIVE: []
1050
+ end
1051
+
1002
1052
  class TextResponsePart
1003
1053
  attr_accessor span: Types::Span
1004
1054
  attr_accessor text: ::String
@@ -1060,6 +1110,10 @@ module Aws::BedrockAgentRuntime
1060
1110
  def event_types: () -> [:access_denied_exception, :bad_gateway_exception, :conflict_exception, :dependency_failed_exception, :flow_completion_event, :flow_output_event, :flow_trace_event, :internal_server_exception, :resource_not_found_exception, :service_quota_exceeded_exception, :throttling_exception, :validation_exception]
1061
1111
  end
1062
1112
 
1113
+ class OptimizedPromptStream < Enumerator[untyped, untyped]
1114
+ def event_types: () -> [:access_denied_exception, :analyze_prompt_event, :bad_gateway_exception, :dependency_failed_exception, :internal_server_exception, :optimized_prompt_event, :throttling_exception, :validation_exception]
1115
+ end
1116
+
1063
1117
  class ResponseStream < Enumerator[untyped, untyped]
1064
1118
  def event_types: () -> [:access_denied_exception, :bad_gateway_exception, :chunk, :conflict_exception, :dependency_failed_exception, :files, :internal_server_exception, :resource_not_found_exception, :return_control, :service_quota_exceeded_exception, :throttling_exception, :trace, :validation_exception]
1065
1119
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws-sdk-bedrockagentruntime
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.31.0
4
+ version: 1.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amazon Web Services
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-08 00:00:00.000000000 Z
11
+ date: 2024-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-core