@@ -41,6 +41,12 @@ extension BedrockService {
4141 /// BedrockLibraryError.invalidSDKResponse if the response body is missing
4242 /// - Returns: A ConverseReplyStream object that gives access to the high-level stream of ConverseStreamElements objects
4343 /// or the low-level stream provided by the AWS SDK.
44+ @available (
45+ * ,
46+ deprecated,
47+ message:
48+ " Use converseStream(with:conversation:...) that takes History instead of [Message]. This func will be removed in the next major version. "
49+ )
4450 public func converseStream(
4551 with model: BedrockModel ,
4652 conversation: [ Message ] ,
@@ -52,6 +58,52 @@ extension BedrockService {
5258 tools: [ Tool ] ? = nil ,
5359 enableReasoning: Bool ? = false ,
5460 maxReasoningTokens: Int ? = nil
61+ ) async throws -> ConverseReplyStream {
62+ // Convert [Message] array to History
63+ let history = History ( conversation)
64+
65+ return try await converseStream (
66+ with: model,
67+ conversation: history,
68+ maxTokens: maxTokens,
69+ temperature: temperature,
70+ topP: topP,
71+ stopSequences: stopSequences,
72+ systemPrompts: systemPrompts,
73+ tools: tools,
74+ enableReasoning: enableReasoning,
75+ maxReasoningTokens: maxReasoningTokens
76+ )
77+ }
78+
79+ /// Converse with a model using the Bedrock Converse Streaming API
80+ /// - Parameters:
81+ /// - model: The BedrockModel to converse with
82+ /// - conversation: Array of previous messages in the conversation
83+ /// - maxTokens: Optional maximum number of tokens to generate
84+ /// - temperature: Optional temperature parameter for controlling randomness
85+ /// - topP: Optional top-p parameter for nucleus sampling
86+ /// - stopSequences: Optional array of sequences where generation should stop
87+ /// - systemPrompts: Optional array of system prompts to guide the conversation
88+ /// - tools: Optional array of tools the model can use
89+ /// - Throws: BedrockLibraryError.notSupported for parameters or functionalities that are not supported
90+ /// BedrockLibraryError.invalidParameter for invalid parameters
91+ /// BedrockLibraryError.invalidPrompt if the prompt is empty or too long
92+ /// BedrockLibraryError.invalidModality for invalid modality from the selected model
93+ /// BedrockLibraryError.invalidSDKResponse if the response body is missing
94+ /// - Returns: A ConverseReplyStream object that gives access to the high-level stream of ConverseStreamElements objects
95+ /// or the low-level stream provided by the AWS SDK.
96+ public func converseStream(
97+ with model: BedrockModel ,
98+ conversation: History ,
99+ maxTokens: Int ? = nil ,
100+ temperature: Double ? = nil ,
101+ topP: Double ? = nil ,
102+ stopSequences: [ String ] ? = nil ,
103+ systemPrompts: [ String ] ? = nil ,
104+ tools: [ Tool ] ? = nil ,
105+ enableReasoning: Bool ? = false ,
106+ maxReasoningTokens: Int ? = nil
55107 ) async throws -> ConverseReplyStream {
56108 do {
57109 guard model. hasConverseStreamingModality ( ) else {
0 commit comments