95 |
96 | {messages.map((message) => (
97 |
98 | {isChatError(message) ? (
99 | <>{getErrorMessage(message)}>
100 | ) : (
101 |
102 |
103 | {message.content}
104 |
105 |
106 | )}
107 |
108 | ))}
109 |
110 |
111 |
112 | setInput(e.target.value)}
116 | onKeyDown={(e) => {
117 | if (e.key === "Enter" && e.shiftKey) {
118 | e.preventDefault();
119 | sendMessage();
120 | }
121 | }}
122 | minRows={1}
123 | maxRows={4}
124 | />
125 |
126 | setStreaming(!streaming)}
129 | >
130 | Streaming
131 |
132 |
133 |
134 | );
135 | }
136 |
--------------------------------------------------------------------------------
/ChatApp.React/src/Readme.tsx:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Corporation.
2 | // Licensed under the MIT License.
3 |
4 | import React, { useEffect, useState } from "react";
5 | import ReactMarkdown from "react-markdown";
6 | import gfm from "remark-gfm";
7 | import { Prism } from "react-syntax-highlighter";
8 | import readmeContent from "../README.md";
9 |
10 | const components = {
11 | code(props: any) {
12 | const { children, className, node, ...rest } = props;
13 | const match = /language-(\w+)/.exec(className || "");
14 | return match ? (
15 |