@@ -209,7 +209,7 @@ def openai_completion_params(model: str, config: GenerateConfig, tools: bool) ->
209209 return params
210210
211211
212- def openai_assistant_content (message : ChatMessageAssistant ) -> str :
212+ def openai_assistant_content (message : ChatMessageAssistant , include_reasoning = True ) -> str :
213213 # In agent bridge scenarios, we could encounter concepts such as reasoning and
214214 # .internal use in the ChatMessageAssistant that are not supported by the OpenAI
215215 # choices API. This code smuggles that data into the plain text so that it
@@ -220,7 +220,7 @@ def openai_assistant_content(message: ChatMessageAssistant) -> str:
220220 else :
221221 content = ''
222222 for c in message .content :
223- if c .type == 'reasoning' :
223+ if c .type == 'reasoning' and include_reasoning :
224224 attribs = ''
225225 if c .signature is not None :
226226 attribs = f'{ attribs } signature="{ c .signature } "'
@@ -239,11 +239,14 @@ def openai_assistant_content(message: ChatMessageAssistant) -> str:
239239 return content
240240
241241
242- def openai_chat_choices (choices : List [ChatCompletionChoice ]) -> List [Choice ]:
242+ def openai_chat_choices (choices : List [ChatCompletionChoice ], include_reasoning : bool = True ) -> List [Choice ]:
243243 oai_choices : List [Choice ] = []
244244
245245 for index , choice in enumerate (choices ):
246- content = openai_assistant_content (choice .message )
246+ # Handle content
247+ content = openai_assistant_content (choice .message , include_reasoning = include_reasoning )
248+
249+ # Handle tool calls
247250 if choice .message .tool_calls :
248251 tool_calls = [openai_chat_tool_call (tc ) for tc in choice .message .tool_calls ]
249252 else :
0 commit comments