File tree 1 file changed +10
-0
lines changed
api/core/model_runtime/model_providers/bedrock/llm
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,16 @@ def _generate_with_converse(
194
194
if model_info ["support_tool_use" ] and tools :
195
195
parameters ["toolConfig" ] = self ._convert_converse_tool_config (tools = tools )
196
196
try :
197
+ # for issue #10976
198
+ # add placeholder for conversation because that bedrock-runtime doesn't support two users
199
+ # FIXME: when bedrock-runtime support two users, we should remove this placeholder
200
+ conversations_list = parameters ["messages" ]
201
+ # if two roles next to each other, insert a placeholder('role': 'assistant') for conversation
202
+ for i in range (len (conversations_list ) - 1 ):
203
+ if conversations_list [i ]["role" ] == "user" and conversations_list [i + 1 ]["role" ] == "user" :
204
+ # insert a placeholder for assistant and it can not be empty string
205
+ conversations_list .insert (i + 1 , {"role" : "assistant" , "content" : [{"text" : "placeholder" }]})
206
+
197
207
if stream :
198
208
response = bedrock_client .converse_stream (** parameters )
199
209
return self ._handle_converse_stream_response (
You can’t perform that action at this time.
0 commit comments