|
34 | 34 | from semantic_kernel.contents.function_call_content import FunctionCallContent |
35 | 35 | from semantic_kernel.contents.streaming_chat_message_content import STREAMING_CMC_ITEM_TYPES as STREAMING_ITEM_TYPES |
36 | 36 | from semantic_kernel.contents.streaming_chat_message_content import StreamingChatMessageContent |
| 37 | +from semantic_kernel.contents.streaming_reasoning_content import StreamingReasoningContent |
37 | 38 | from semantic_kernel.contents.streaming_text_content import StreamingTextContent |
| 39 | +from semantic_kernel.contents.reasoning_content import ReasoningContent |
38 | 40 | from semantic_kernel.contents.text_content import TextContent |
39 | 41 | from semantic_kernel.contents.utils.author_role import AuthorRole |
40 | 42 | from semantic_kernel.contents.utils.finish_reason import FinishReason |
@@ -302,9 +304,9 @@ def _create_chat_message_content( |
302 | 304 | items: list[CMC_ITEM_TYPES] = [] |
303 | 305 | if candidate.content and candidate.content.parts: |
304 | 306 | for idx, part in enumerate(candidate.content.parts): |
305 | | - if part.thought: |
306 | | - continue |
307 | | - if part.text: |
| 307 | + if getattr(part, "thought", False): |
| 308 | + items.append(ReasoningContent(text=part.text, inner_content=response, metadata=response_metadata)) |
| 309 | + elif part.text: |
308 | 310 | items.append(TextContent(text=part.text, inner_content=response, metadata=response_metadata)) |
309 | 311 | elif part.function_call: |
310 | 312 | fc_metadata: dict[str, Any] = {} |
@@ -359,9 +361,16 @@ def _create_streaming_chat_message_content( |
359 | 361 | items: list[STREAMING_ITEM_TYPES] = [] |
360 | 362 | if candidate.content and candidate.content.parts: |
361 | 363 | for idx, part in enumerate(candidate.content.parts): |
362 | | - if part.thought: |
363 | | - continue |
364 | | - if part.text: |
| 364 | + if getattr(part, "thought", False): |
| 365 | + items.append( |
| 366 | + StreamingReasoningContent( |
| 367 | + choice_index=candidate.index or 0, |
| 368 | + text=part.text, |
| 369 | + inner_content=chunk, |
| 370 | + metadata=response_metadata, |
| 371 | + ) |
| 372 | + ) |
| 373 | + elif part.text: |
365 | 374 | items.append( |
366 | 375 | StreamingTextContent( |
367 | 376 | choice_index=candidate.index or 0, |
|
0 commit comments