From 9c8bfe0c9b5f273ae7ac30285a048b9f01524170 Mon Sep 17 00:00:00 2001 From: Chris Kent <8364109+thechriskent@users.noreply.github.com> Date: Thu, 8 Feb 2024 12:44:03 -0500 Subject: [PATCH] Markdown Toggle Makes it easier to compare/contrast what Markdown support adds --- .../components/AssistantResponse.tsx | 8 +++++++- .../chatStreaming/components/ChatStreaming.tsx | 17 +++++++++++++---- .../components/IChatStreamingState.ts | 1 + .../chatStreaming/components/MessagesList.tsx | 3 ++- .../chatStreaming/components/UserMessage.tsx | 10 ++++++++++ 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/samples/react-azure-openai-api-stream/src/webparts/chatStreaming/components/AssistantResponse.tsx b/samples/react-azure-openai-api-stream/src/webparts/chatStreaming/components/AssistantResponse.tsx index 38ece9b39..ffd7af6b1 100644 --- a/samples/react-azure-openai-api-stream/src/webparts/chatStreaming/components/AssistantResponse.tsx +++ b/samples/react-azure-openai-api-stream/src/webparts/chatStreaming/components/AssistantResponse.tsx @@ -6,6 +6,7 @@ import MarkdownContent from "./MarkdownContent"; export interface IAssistantResponseProps { message: string; + disableMarkdown?: boolean; } export default class AssistantResponse extends React.Component< @@ -19,7 +20,12 @@ export default class AssistantResponse extends React.Component<
- {this.props.message} + {this.props.disableMarkdown && +

{this.props.message}

+ } + {!this.props.disableMarkdown && + {this.props.message} + }
diff --git a/samples/react-azure-openai-api-stream/src/webparts/chatStreaming/components/ChatStreaming.tsx b/samples/react-azure-openai-api-stream/src/webparts/chatStreaming/components/ChatStreaming.tsx index 0b687849c..e064f7db2 100644 --- a/samples/react-azure-openai-api-stream/src/webparts/chatStreaming/components/ChatStreaming.tsx +++ b/samples/react-azure-openai-api-stream/src/webparts/chatStreaming/components/ChatStreaming.tsx @@ -25,7 +25,8 @@ export default class ChatStreaming extends React.Component - + {this.state.thinking && ( @@ -52,9 +53,11 @@ export default class ChatStreaming extends React.Component @@ -175,4 +178,10 @@ export default class ChatStreaming extends React.Component { @@ -27,7 +28,7 @@ export default class MessagesList extends React.Component } - return + return }); return ( diff --git a/samples/react-azure-openai-api-stream/src/webparts/chatStreaming/components/UserMessage.tsx b/samples/react-azure-openai-api-stream/src/webparts/chatStreaming/components/UserMessage.tsx index 24b56cbc6..c097ef8ce 100644 --- a/samples/react-azure-openai-api-stream/src/webparts/chatStreaming/components/UserMessage.tsx +++ b/samples/react-azure-openai-api-stream/src/webparts/chatStreaming/components/UserMessage.tsx @@ -7,6 +7,8 @@ export interface IUserMessageProps { sendQuery: () => Promise; controller: AbortController; textFieldValue: string; + disableMarkdown?: boolean; + toggleMarkdown: () => void; } export default class UserMessage extends React.Component { @@ -37,6 +39,7 @@ export default class UserMessage extends React.Component ariaLabel="Stop" onClick={() => this.props.controller.abort()} /> + );