@mitodl/smoot-design 0.0.0-a2e4e1e → 0.0.0-bafccd3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/bundles/{remoteTutorDrawer.es.js → aiDrawerManager.es.js} +17612 -17240
- package/dist/bundles/aiDrawerManager.es.js.map +1 -0
- package/dist/bundles/aiDrawerManager.umd.js +245 -0
- package/dist/bundles/aiDrawerManager.umd.js.map +1 -0
- package/dist/cjs/VERSION.d.ts +12 -0
- package/dist/cjs/VERSION.js +15 -0
- package/dist/cjs/ai.d.ts +3 -3
- package/dist/cjs/ai.js +5 -1
- package/dist/cjs/bundles/{RemoteTutorDrawer/RemoteTutorDrawer.d.ts → AiDrawer/AiDrawer.d.ts} +11 -13
- package/dist/cjs/bundles/{RemoteTutorDrawer/RemoteTutorDrawer.js → AiDrawer/AiDrawer.js} +27 -41
- package/dist/cjs/bundles/{RemoteTutorDrawer/RemoteTutorDrawer.stories.d.ts → AiDrawer/AiDrawer.stories.d.ts} +4 -3
- package/dist/cjs/bundles/{RemoteTutorDrawer/RemoteTutorDrawer.stories.js → AiDrawer/AiDrawer.stories.js} +32 -51
- package/dist/cjs/bundles/AiDrawer/AiDrawerManager.d.ts +12 -0
- package/dist/cjs/bundles/AiDrawer/AiDrawerManager.js +51 -0
- package/dist/cjs/bundles/AiDrawer/AiDrawerManager.stories.d.ts +6 -0
- package/dist/cjs/bundles/AiDrawer/AiDrawerManager.stories.js +267 -0
- package/dist/cjs/bundles/{RemoteTutorDrawer/RemoteTutorDrawer.test.js → AiDrawer/AiDrawerManager.test.js} +22 -18
- package/dist/cjs/bundles/{RemoteTutorDrawer → AiDrawer}/FlashcardsScreen.js +1 -1
- package/dist/cjs/bundles/aiDrawerManager.d.ts +6 -0
- package/dist/cjs/bundles/aiDrawerManager.js +44 -0
- package/dist/cjs/components/AiChat/AiChat.d.ts +3 -3
- package/dist/cjs/components/AiChat/AiChat.js +65 -53
- package/dist/cjs/components/AiChat/AiChat.stories.d.ts +0 -4
- package/dist/cjs/components/AiChat/AiChat.stories.js +5 -54
- package/dist/cjs/components/AiChat/AiChatContext.d.ts +26 -0
- package/dist/cjs/components/AiChat/AiChatContext.js +106 -0
- package/dist/cjs/components/AiChat/AiChatContext.stories.d.ts +14 -0
- package/dist/cjs/components/AiChat/AiChatContext.stories.js +75 -0
- package/dist/cjs/components/AiChat/AiChatMarkdown.stories.d.ts +15 -0
- package/dist/cjs/components/AiChat/AiChatMarkdown.stories.js +282 -0
- package/dist/cjs/components/AiChat/Markdown.d.ts +7 -0
- package/dist/cjs/components/AiChat/Markdown.js +14 -0
- package/dist/cjs/components/AiChat/test-utils/api.js +40 -1
- package/dist/cjs/components/AiChat/types.d.ts +25 -11
- package/dist/cjs/components/AiChat/types.js +1 -1
- package/dist/cjs/components/AiChat/utils.d.ts +1 -1
- package/dist/cjs/components/AiChat/utils.js +1 -1
- package/dist/cjs/components/LinkAdapter/LinkAdapter.js +1 -1
- package/dist/cjs/components/TabButtons/TabButtonList.js +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/utils/retryingFetch.d.ts +19 -0
- package/dist/cjs/utils/retryingFetch.js +98 -0
- package/dist/cjs/utils/retryingFetch.test.js +48 -0
- package/dist/esm/VERSION.d.ts +12 -0
- package/dist/esm/VERSION.js +12 -0
- package/dist/esm/ai.d.ts +3 -3
- package/dist/esm/ai.js +2 -1
- package/dist/esm/bundles/{RemoteTutorDrawer/RemoteTutorDrawer.d.ts → AiDrawer/AiDrawer.d.ts} +11 -13
- package/dist/esm/bundles/{RemoteTutorDrawer/RemoteTutorDrawer.js → AiDrawer/AiDrawer.js} +26 -40
- package/dist/esm/bundles/{RemoteTutorDrawer/RemoteTutorDrawer.stories.d.ts → AiDrawer/AiDrawer.stories.d.ts} +4 -3
- package/dist/esm/bundles/{RemoteTutorDrawer/RemoteTutorDrawer.stories.js → AiDrawer/AiDrawer.stories.js} +31 -50
- package/dist/esm/bundles/AiDrawer/AiDrawerManager.d.ts +12 -0
- package/dist/esm/bundles/AiDrawer/AiDrawerManager.js +48 -0
- package/dist/esm/bundles/AiDrawer/AiDrawerManager.stories.d.ts +6 -0
- package/dist/esm/bundles/AiDrawer/AiDrawerManager.stories.js +264 -0
- package/dist/esm/bundles/AiDrawer/AiDrawerManager.test.d.ts +1 -0
- package/dist/esm/bundles/{RemoteTutorDrawer/RemoteTutorDrawer.test.js → AiDrawer/AiDrawerManager.test.js} +22 -18
- package/dist/esm/bundles/{RemoteTutorDrawer → AiDrawer}/FlashcardsScreen.js +1 -1
- package/dist/esm/bundles/aiDrawerManager.d.ts +6 -0
- package/dist/esm/bundles/aiDrawerManager.js +41 -0
- package/dist/esm/components/AiChat/AiChat.d.ts +3 -3
- package/dist/esm/components/AiChat/AiChat.js +65 -54
- package/dist/esm/components/AiChat/AiChat.stories.d.ts +0 -4
- package/dist/esm/components/AiChat/AiChat.stories.js +4 -53
- package/dist/esm/components/AiChat/AiChatContext.d.ts +26 -0
- package/dist/esm/components/AiChat/AiChatContext.js +102 -0
- package/dist/esm/components/AiChat/AiChatContext.stories.d.ts +14 -0
- package/dist/esm/components/AiChat/AiChatContext.stories.js +72 -0
- package/dist/esm/components/AiChat/AiChatMarkdown.stories.d.ts +15 -0
- package/dist/esm/components/AiChat/AiChatMarkdown.stories.js +279 -0
- package/dist/esm/components/AiChat/Markdown.d.ts +7 -0
- package/dist/esm/components/AiChat/Markdown.js +12 -0
- package/dist/esm/components/AiChat/test-utils/api.js +40 -1
- package/dist/esm/components/AiChat/types.d.ts +25 -11
- package/dist/esm/components/AiChat/types.js +1 -1
- package/dist/esm/components/AiChat/utils.d.ts +1 -1
- package/dist/esm/components/AiChat/utils.js +1 -1
- package/dist/esm/components/LinkAdapter/LinkAdapter.js +1 -1
- package/dist/esm/components/TabButtons/TabButtonList.js +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/utils/retryingFetch.d.ts +19 -0
- package/dist/esm/utils/retryingFetch.js +96 -0
- package/dist/esm/utils/retryingFetch.test.d.ts +1 -0
- package/dist/esm/utils/retryingFetch.test.js +46 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -7
- package/dist/bundles/remoteTutorDrawer.umd.js +0 -207
- package/dist/cjs/bundles/remoteTutorDrawer.d.ts +0 -7
- package/dist/cjs/bundles/remoteTutorDrawer.js +0 -40
- package/dist/esm/bundles/remoteTutorDrawer.d.ts +0 -7
- package/dist/esm/bundles/remoteTutorDrawer.js +0 -37
- /package/dist/cjs/bundles/{RemoteTutorDrawer/RemoteTutorDrawer.test.d.ts → AiDrawer/AiDrawerManager.test.d.ts} +0 -0
- /package/dist/cjs/bundles/{RemoteTutorDrawer → AiDrawer}/FlashcardsScreen.d.ts +0 -0
- /package/dist/{esm/bundles/RemoteTutorDrawer/RemoteTutorDrawer.test.d.ts → cjs/utils/retryingFetch.test.d.ts} +0 -0
- /package/dist/esm/bundles/{RemoteTutorDrawer → AiDrawer}/FlashcardsScreen.d.ts +0 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnexpectedList = exports.NestedUnorderedOrderedList = exports.NestedOrderedUnorderedList = exports.NestedUnorderedList = exports.NestedOrderedList = exports.SimpleUnorderedList = exports.SimpleOrderedList = exports.Math = exports.Textual = exports.Typical = void 0;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const AiChat_1 = require("./AiChat");
|
|
6
|
+
const styled_1 = require("@emotion/styled");
|
|
7
|
+
const api_1 = require("./test-utils/api");
|
|
8
|
+
const better_react_mathjax_1 = require("better-react-mathjax");
|
|
9
|
+
const TEST_API_STREAMING = "http://localhost:4567/streaming";
|
|
10
|
+
const Container = styled_1.default.div({
|
|
11
|
+
width: "100%",
|
|
12
|
+
height: "500px",
|
|
13
|
+
});
|
|
14
|
+
const meta = {
|
|
15
|
+
title: "smoot-design/AI/AiChat Markdown",
|
|
16
|
+
component: AiChat_1.AiChat,
|
|
17
|
+
parameters: {
|
|
18
|
+
msw: { handlers: api_1.handlers },
|
|
19
|
+
},
|
|
20
|
+
render: (args) => React.createElement(AiChat_1.AiChat, Object.assign({}, args)),
|
|
21
|
+
decorators: (Story, context) => {
|
|
22
|
+
return (React.createElement(better_react_mathjax_1.MathJaxContext, null,
|
|
23
|
+
React.createElement(Container, null,
|
|
24
|
+
React.createElement(Story, { key: String(context.args.entryScreenEnabled) }))));
|
|
25
|
+
},
|
|
26
|
+
args: {
|
|
27
|
+
requestOpts: { apiUrl: TEST_API_STREAMING },
|
|
28
|
+
askTimTitle: "to recommend a course",
|
|
29
|
+
initialMessages: [
|
|
30
|
+
{
|
|
31
|
+
role: "assistant",
|
|
32
|
+
content: `A simple ordered list:
|
|
33
|
+
1. Item 1
|
|
34
|
+
2. Item 3
|
|
35
|
+
3. Item 3`,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
argTypes: {
|
|
40
|
+
conversationStarters: {
|
|
41
|
+
control: { type: "object", disable: true },
|
|
42
|
+
},
|
|
43
|
+
initialMessages: {
|
|
44
|
+
control: { type: "object", disable: true },
|
|
45
|
+
},
|
|
46
|
+
requestOpts: {
|
|
47
|
+
control: { type: "object", disable: true },
|
|
48
|
+
table: { readonly: true }, // See above
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
exports.default = meta;
|
|
53
|
+
exports.Typical = {
|
|
54
|
+
args: {
|
|
55
|
+
requestOpts: { apiUrl: TEST_API_STREAMING },
|
|
56
|
+
entryScreenEnabled: false,
|
|
57
|
+
conversationStarters: [],
|
|
58
|
+
initialMessages: [
|
|
59
|
+
{
|
|
60
|
+
role: "user",
|
|
61
|
+
content: "What is this course about?",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
role: "assistant",
|
|
65
|
+
content: `Let me search for the core focus of this course.
|
|
66
|
+
|
|
67
|
+
Based on the search results, this course (The Human Brain) focuses on studying how the human brain implements core perceptual and cognitive abilities of the mind. Here are the main aspects of what the course covers:
|
|
68
|
+
|
|
69
|
+
Key Focus:
|
|
70
|
+
- Examines how different parts of the brain carry out specific cognitive and perceptual functions
|
|
71
|
+
- Studies the functional organization of the human brain and how it gives rise to mental abilities
|
|
72
|
+
- Explores the relationship between mind and brain
|
|
73
|
+
|
|
74
|
+
Specific Topics Covered:
|
|
75
|
+
1. Visual perception (color, shape, motion)
|
|
76
|
+
2. Recognition of faces, places, bodies, and words
|
|
77
|
+
3. Scene perception and navigation
|
|
78
|
+
4. Numerical understanding
|
|
79
|
+
5. Speech and music perception
|
|
80
|
+
6. Language comprehension
|
|
81
|
+
7. Understanding other minds (social cognition)
|
|
82
|
+
|
|
83
|
+
Main Approaches:
|
|
84
|
+
- Examines each mental function by:
|
|
85
|
+
1. Understanding how it works in the mind (what is computed and how)
|
|
86
|
+
2. Studying its brain basis (specialized machinery, information representation, timing)
|
|
87
|
+
- Uses multiple research methods including psychophysics, neuropsychology, fMRI, and other cognitive neuroscience techniques
|
|
88
|
+
|
|
89
|
+
Important Note:
|
|
90
|
+
The course emphasizes understanding principles rather than memorizing details, and takes students to the cutting edge of the field by having them read current research papers rather than textbooks. The professor notes that while it's called "The Human Brain," it focuses on cognitive neuroscience - understanding how the brain gives rise to mental functions, rather than purely biological aspects of the brain.
|
|
91
|
+
|
|
92
|
+
The course aims to help students understand both the big questions in the field and the methods used to answer them, while bringing them to the current frontiers of cognitive neuroscience research.`,
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
exports.Textual = {
|
|
98
|
+
args: {
|
|
99
|
+
requestOpts: { apiUrl: TEST_API_STREAMING },
|
|
100
|
+
entryScreenEnabled: false,
|
|
101
|
+
conversationStarters: [],
|
|
102
|
+
initialMessages: [
|
|
103
|
+
{
|
|
104
|
+
role: "assistant",
|
|
105
|
+
content: `Here is a longer paragraph and **bold text** and *italic text*. Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
|
106
|
+
sed do eiusmod tempor [incididunt](https://mit.edu) ut labore et dolore magna aliqua. Ut enim ad minim veniam.
|
|
107
|
+
|
|
108
|
+
And some inline code, \`\`<inline></inline>\`\` and code block:
|
|
109
|
+
\`\`\`
|
|
110
|
+
def f(x):
|
|
111
|
+
print(x)
|
|
112
|
+
\`\`\``,
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
exports.Math = {
|
|
118
|
+
args: {
|
|
119
|
+
requestOpts: { apiUrl: TEST_API_STREAMING },
|
|
120
|
+
entryScreenEnabled: false,
|
|
121
|
+
conversationStarters: [],
|
|
122
|
+
initialMessages: [
|
|
123
|
+
{
|
|
124
|
+
role: "assistant",
|
|
125
|
+
content: `Some inline math: $x = \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}$
|
|
126
|
+
|
|
127
|
+
And some block math:
|
|
128
|
+
\n
|
|
129
|
+
|
|
130
|
+
$$
|
|
131
|
+
x = \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}
|
|
132
|
+
$$
|
|
133
|
+
|
|
134
|
+
Math is rendered using MathJax only if the \`useMathJax\` prop is set to true.`,
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
useMathJax: true,
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
exports.SimpleOrderedList = {
|
|
141
|
+
args: {
|
|
142
|
+
requestOpts: { apiUrl: TEST_API_STREAMING },
|
|
143
|
+
entryScreenEnabled: false,
|
|
144
|
+
conversationStarters: [],
|
|
145
|
+
initialMessages: [
|
|
146
|
+
{
|
|
147
|
+
role: "assistant",
|
|
148
|
+
content: `A simple ordered list:
|
|
149
|
+
1. Item 1
|
|
150
|
+
2. Item 2
|
|
151
|
+
3. Item 3`,
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
exports.SimpleUnorderedList = {
|
|
157
|
+
args: {
|
|
158
|
+
requestOpts: { apiUrl: TEST_API_STREAMING },
|
|
159
|
+
entryScreenEnabled: false,
|
|
160
|
+
conversationStarters: [],
|
|
161
|
+
initialMessages: [
|
|
162
|
+
{
|
|
163
|
+
role: "assistant",
|
|
164
|
+
content: `A simple unordered list:
|
|
165
|
+
- Item 1
|
|
166
|
+
- Item 2
|
|
167
|
+
- Item 3`,
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
exports.NestedOrderedList = {
|
|
173
|
+
args: {
|
|
174
|
+
requestOpts: { apiUrl: TEST_API_STREAMING },
|
|
175
|
+
entryScreenEnabled: false,
|
|
176
|
+
conversationStarters: [],
|
|
177
|
+
initialMessages: [
|
|
178
|
+
{
|
|
179
|
+
role: "assistant",
|
|
180
|
+
content: `A nested ordered list:
|
|
181
|
+
1. Item 1
|
|
182
|
+
1. Item 1.1
|
|
183
|
+
2. Item 1.2
|
|
184
|
+
2. Item 2
|
|
185
|
+
1. Item 2.1
|
|
186
|
+
2. Item 2.2
|
|
187
|
+
3. Item 3
|
|
188
|
+
1. Item 3.1
|
|
189
|
+
2. Item 3.2`,
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
exports.NestedUnorderedList = {
|
|
195
|
+
args: {
|
|
196
|
+
requestOpts: { apiUrl: TEST_API_STREAMING },
|
|
197
|
+
entryScreenEnabled: false,
|
|
198
|
+
conversationStarters: [],
|
|
199
|
+
initialMessages: [
|
|
200
|
+
{
|
|
201
|
+
role: "assistant",
|
|
202
|
+
content: `A nested unordered list:
|
|
203
|
+
- Item 1
|
|
204
|
+
- Item 1.1
|
|
205
|
+
- Item 1.2
|
|
206
|
+
- Item 2
|
|
207
|
+
- Item 2.1
|
|
208
|
+
- Item 2.2
|
|
209
|
+
- Item 3
|
|
210
|
+
- Item 3.1
|
|
211
|
+
- Item 3.2`,
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
exports.NestedOrderedUnorderedList = {
|
|
217
|
+
args: {
|
|
218
|
+
requestOpts: { apiUrl: TEST_API_STREAMING },
|
|
219
|
+
entryScreenEnabled: false,
|
|
220
|
+
conversationStarters: [],
|
|
221
|
+
initialMessages: [
|
|
222
|
+
{
|
|
223
|
+
role: "assistant",
|
|
224
|
+
content: `A nested ordered and unordered list:
|
|
225
|
+
1. Item 1
|
|
226
|
+
- Item 1.1
|
|
227
|
+
- Item 1.2
|
|
228
|
+
2. Item 2
|
|
229
|
+
- Item 2.1
|
|
230
|
+
- Item 2.2
|
|
231
|
+
3. Item 3
|
|
232
|
+
- Item 3.1
|
|
233
|
+
- Item 3.2`,
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
exports.NestedUnorderedOrderedList = {
|
|
239
|
+
args: {
|
|
240
|
+
requestOpts: { apiUrl: TEST_API_STREAMING },
|
|
241
|
+
entryScreenEnabled: false,
|
|
242
|
+
conversationStarters: [],
|
|
243
|
+
initialMessages: [
|
|
244
|
+
{
|
|
245
|
+
role: "assistant",
|
|
246
|
+
content: `A nested unordered and ordered list:
|
|
247
|
+
- Item 1
|
|
248
|
+
1. Item 1.1
|
|
249
|
+
2. Item 1.2
|
|
250
|
+
- Item 2
|
|
251
|
+
1. Item 2.1
|
|
252
|
+
2. Item 2.2
|
|
253
|
+
- Item 3
|
|
254
|
+
1. Item 3.1
|
|
255
|
+
2. Item 3.2`,
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
exports.UnexpectedList = {
|
|
261
|
+
args: {
|
|
262
|
+
requestOpts: { apiUrl: TEST_API_STREAMING },
|
|
263
|
+
entryScreenEnabled: false,
|
|
264
|
+
conversationStarters: [],
|
|
265
|
+
initialMessages: [
|
|
266
|
+
{
|
|
267
|
+
role: "assistant",
|
|
268
|
+
content: `LLMs may produce lists that are semantically nested, but do not reliably indent the markdown for the nested list items,
|
|
269
|
+
producing sibling ordered and unordered lists. We address this by assuming that if <ul> immediately follows <ol> in the DOM, it is a
|
|
270
|
+
"semantic sublist" of the last list item, and we style accordingly:
|
|
271
|
+
|
|
272
|
+
1. Item 1
|
|
273
|
+
- Semantic subitem 1.1
|
|
274
|
+
- Semantic subitem 1.2
|
|
275
|
+
|
|
276
|
+
2. Item 2
|
|
277
|
+
- Semantic subitem 2.1
|
|
278
|
+
- Semantic subitem 2.2`,
|
|
279
|
+
},
|
|
280
|
+
],
|
|
281
|
+
},
|
|
282
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const react_markdown_1 = require("react-markdown");
|
|
5
|
+
const browser_1 = require("rehype-mathjax/browser");
|
|
6
|
+
const remark_math_1 = require("remark-math");
|
|
7
|
+
const better_react_mathjax_1 = require("better-react-mathjax");
|
|
8
|
+
const Markdown = ({ children, enableMathjax }) => {
|
|
9
|
+
const remarkPlugins = enableMathjax ? [remark_math_1.default] : undefined;
|
|
10
|
+
const rehypePlugins = enableMathjax ? [browser_1.default] : undefined;
|
|
11
|
+
const markdown = (React.createElement(react_markdown_1.default, { skipHtml: true, remarkPlugins: remarkPlugins, rehypePlugins: rehypePlugins }, children));
|
|
12
|
+
return enableMathjax ? React.createElement(better_react_mathjax_1.MathJax, null, markdown) : markdown;
|
|
13
|
+
};
|
|
14
|
+
exports.default = Markdown;
|
|
@@ -17,6 +17,15 @@ const SAMPLE_RESPONSES = [
|
|
|
17
17
|
1. **[Machine Learning, Modeling, and Simulation Principles](https://xpro.mit.edu/courses/course-v1:xPRO+MLx1/)**: Offered by MIT xPRO, this course is part of the program "Machine Learning, Modeling, and Simulation: Engineering Problem-Solving in the Age of AI." It focuses on the principles of machine learning and how they can be applied to solve engineering problems, which is highly relevant for business applications of AI.
|
|
18
18
|
|
|
19
19
|
This course is not free, but it provides a certification upon completion, which can be valuable for professionals looking to apply AI in business contexts. It covers essential concepts that can help you understand how AI can be leveraged to improve business processes and decision-making.
|
|
20
|
+
Here is some inline math: $x = \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}$
|
|
21
|
+
|
|
22
|
+
And some block math:
|
|
23
|
+
\n
|
|
24
|
+
|
|
25
|
+
$$
|
|
26
|
+
x = \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}
|
|
27
|
+
$$
|
|
28
|
+
|
|
20
29
|
<!-- Comment! -->
|
|
21
30
|
`,
|
|
22
31
|
`
|
|
@@ -27,6 +36,15 @@ To understand global warming, I recommend the following resources from MIT:
|
|
|
27
36
|
2. **[Global Warming Science](https://openlearninglibrary.mit.edu/courses/course-v1:MITx+12.340x+1T2020/about)**: Another offering of the same course by MITx, available through the Open Learning Library. It provides the same in-depth exploration of the earth's climate system.
|
|
28
37
|
|
|
29
38
|
These courses are free and provide a solid foundation in understanding the scientific aspects of global warming. They are suitable for anyone interested in the topic, regardless of prior knowledge.
|
|
39
|
+
Here is some inline math: $x = \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}$
|
|
40
|
+
|
|
41
|
+
And some block math:
|
|
42
|
+
\n
|
|
43
|
+
|
|
44
|
+
$$
|
|
45
|
+
x = \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}
|
|
46
|
+
$$
|
|
47
|
+
|
|
30
48
|
<!-- Comment! -->
|
|
31
49
|
`,
|
|
32
50
|
`
|
|
@@ -39,6 +57,16 @@ Here are some courses on linear algebra that you can explore:
|
|
|
39
57
|
3. **[Quantum Information Science I, Part 1 (MITx)](https://openlearninglibrary.mit.edu/courses/course-v1:MITx+8.370.1x+1T2018/about)**: While primarily focused on quantum information science, this course requires some knowledge of linear algebra and is suitable for those interested in quantum mechanics. It is free and available through MITx.
|
|
40
58
|
|
|
41
59
|
These courses provide a comprehensive introduction to linear algebra and its applications across various fields.
|
|
60
|
+
|
|
61
|
+
Here is some inline math: $x = \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}$
|
|
62
|
+
|
|
63
|
+
And some block math:
|
|
64
|
+
\n
|
|
65
|
+
|
|
66
|
+
$$
|
|
67
|
+
x = \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}
|
|
68
|
+
$$
|
|
69
|
+
|
|
42
70
|
<!-- Comment! -->
|
|
43
71
|
`,
|
|
44
72
|
`Here are some courses on quantum computing that offer certificates:
|
|
@@ -53,7 +81,18 @@ These courses provide a comprehensive introduction to linear algebra and its app
|
|
|
53
81
|
- **Offered by**: MIT xPRO
|
|
54
82
|
- **Instructors**: Isaac Chuang, William Oliver, Peter Shor, Aram Harrow
|
|
55
83
|
|
|
56
|
-
These courses are part of professional certificate programs, and you can choose to complete the entire program or take individual courses for certification
|
|
84
|
+
These courses are part of professional certificate programs, and you can choose to complete the entire program or take individual courses for certification.
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
Here is some inline math: $x = \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}$
|
|
88
|
+
|
|
89
|
+
And some block math:
|
|
90
|
+
\n
|
|
91
|
+
|
|
92
|
+
$$
|
|
93
|
+
x = \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}
|
|
94
|
+
$$
|
|
95
|
+
`,
|
|
57
96
|
];
|
|
58
97
|
const rand = (min, max) => {
|
|
59
98
|
// min and max included
|
|
@@ -20,12 +20,24 @@ type RequestOpts = {
|
|
|
20
20
|
fetchOpts?: RequestInit;
|
|
21
21
|
onFinish?: (message: AiChatMessage) => void;
|
|
22
22
|
};
|
|
23
|
-
type
|
|
23
|
+
type AiChatContextProps = {
|
|
24
24
|
/**
|
|
25
25
|
* Changing the `chatId` will reset the chat. Changing the `chatId` to a
|
|
26
26
|
* previously used value will restore the session state.
|
|
27
27
|
*/
|
|
28
28
|
chatId?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Options for making requests to the AI service.
|
|
31
|
+
*/
|
|
32
|
+
requestOpts: RequestOpts;
|
|
33
|
+
parseContent?: (content: unknown) => string;
|
|
34
|
+
/**
|
|
35
|
+
* Initial messages to display on the chat. If not provided, the entry screen title will be used as the initial message.
|
|
36
|
+
*/
|
|
37
|
+
initialMessages?: Omit<AiChatMessage, "id">[];
|
|
38
|
+
children?: React.ReactNode;
|
|
39
|
+
};
|
|
40
|
+
type AiChatDisplayProps = {
|
|
29
41
|
/**
|
|
30
42
|
* If provided, renders the "AskTIM" title motif followed by the text.
|
|
31
43
|
*/
|
|
@@ -44,21 +56,12 @@ type AiChatProps = {
|
|
|
44
56
|
* Title to display on the entry screen, also the initial assistant message if not overridden by `initialMessages`.
|
|
45
57
|
*/
|
|
46
58
|
entryScreenTitle?: string;
|
|
47
|
-
/**
|
|
48
|
-
* Initial messages to display on the chat. If not provided, the entry screen title will be used as the initial message.
|
|
49
|
-
*/
|
|
50
|
-
initialMessages?: Omit<AiChatMessage, "id">[];
|
|
51
59
|
/**
|
|
52
60
|
* Prompt suggestions for the user, clickable on the entry screen or in the chat if the entry screen is not enabled.
|
|
53
61
|
*/
|
|
54
62
|
conversationStarters?: {
|
|
55
63
|
content: string;
|
|
56
64
|
}[];
|
|
57
|
-
/**
|
|
58
|
-
* Options for making requests to the AI service.
|
|
59
|
-
*/
|
|
60
|
-
requestOpts: RequestOpts;
|
|
61
|
-
parseContent?: (content: unknown) => string;
|
|
62
65
|
/**
|
|
63
66
|
* A message to display while the component is in a loading state.
|
|
64
67
|
*
|
|
@@ -78,5 +81,16 @@ type AiChatProps = {
|
|
|
78
81
|
* the AiChat will scroll to the bottom as chat messages are added.
|
|
79
82
|
*/
|
|
80
83
|
scrollElement?: HTMLElement | null;
|
|
84
|
+
/**
|
|
85
|
+
* If true, the chat will display math equations using MathJax.
|
|
86
|
+
* Defaults to false.
|
|
87
|
+
*/
|
|
88
|
+
useMathJax?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* If true, the chat input will be autofocused on load.
|
|
91
|
+
* Defaults to true.
|
|
92
|
+
*/
|
|
93
|
+
autofocus?: boolean;
|
|
81
94
|
} & RefAttributes<HTMLDivElement>;
|
|
82
|
-
|
|
95
|
+
type AiChatProps = AiChatContextProps & AiChatDisplayProps;
|
|
96
|
+
export type { RequestOpts, AiChatMessage, AiChatContextProps, AiChatDisplayProps, AiChatProps, };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Some of these are based on (compatible, but simplified / restricted) versions of ai/react types.
|
|
2
|
+
// Some of these are based on (compatible, but simplified / restricted) versions of @ai-sdk/react types.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UseChatOptions } from "ai/react";
|
|
1
|
+
import { UseChatOptions } from "@ai-sdk/react";
|
|
2
2
|
import type { RequestOpts } from "./types";
|
|
3
3
|
declare const useAiChat: (requestOpts: RequestOpts, opts: UseChatOptions) => import("@ai-sdk/react").UseChatHelpers & {
|
|
4
4
|
addToolResult: ({ toolCallId, result, }: {
|
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.useAiChat = void 0;
|
|
13
|
-
const react_1 = require("ai/react");
|
|
13
|
+
const react_1 = require("@ai-sdk/react");
|
|
14
14
|
const react_2 = require("react");
|
|
15
15
|
const identity = (x) => x;
|
|
16
16
|
const getFetcher = (requestOpts) => (url, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -29,6 +29,6 @@ const LinkAdapter = React.forwardRef(function LinkAdapter(_a, ref) {
|
|
|
29
29
|
var { Component } = _a, props = __rest(_a, ["Component"]);
|
|
30
30
|
const theme = (0, react_1.useTheme)();
|
|
31
31
|
const LinkComponent = Component !== null && Component !== void 0 ? Component : theme.custom.LinkAdapter;
|
|
32
|
-
return React.createElement(PlainLink, Object.assign({ as: LinkComponent, ref: ref }, props));
|
|
32
|
+
return (React.createElement(PlainLink, Object.assign({ as: LinkComponent, ref: ref }, props), props.children));
|
|
33
33
|
});
|
|
34
34
|
exports.LinkAdapter = LinkAdapter;
|
|
@@ -77,7 +77,7 @@ const TabButtonInner = React.forwardRef(
|
|
|
77
77
|
TabButtonInner.displayName = "TabButtonInner";
|
|
78
78
|
const TabLinkInner = React.forwardRef((props, ref) => {
|
|
79
79
|
const { className } = props, others = __rest(props, ["className"]);
|
|
80
|
-
return React.createElement(TabLinkStyled, Object.assign({}, defaultTabButtonProps, others, { ref: ref }));
|
|
80
|
+
return (React.createElement(TabLinkStyled, Object.assign({}, defaultTabButtonProps, others, { ref: ref }), props.children));
|
|
81
81
|
});
|
|
82
82
|
TabLinkInner.displayName = "TabLinkInner";
|
|
83
83
|
/**
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -13,4 +13,5 @@ export type { TextFieldProps } from "./components/TextField/TextField";
|
|
|
13
13
|
export { SrAnnouncer } from "./components/SrAnnouncer/SrAnnouncer";
|
|
14
14
|
export type { SrAnnouncerProps } from "./components/SrAnnouncer/SrAnnouncer";
|
|
15
15
|
export { TabButton, TabButtonLink, TabButtonList, } from "./components/TabButtons/TabButtonList";
|
|
16
|
+
export { VERSION } from "./VERSION";
|
|
16
17
|
export { VisuallyHidden } from "./components/VisuallyHidden/VisuallyHidden";
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
"use client";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.VisuallyHidden = exports.TabButtonList = exports.TabButtonLink = exports.TabButton = exports.SrAnnouncer = exports.TextField = exports.Input = exports.ActionButtonLink = exports.ActionButton = exports.ButtonLink = exports.Button = exports.createTheme = exports.ThemeProvider = exports.Global = exports.css = exports.styled = void 0;
|
|
4
|
+
exports.VisuallyHidden = exports.VERSION = exports.TabButtonList = exports.TabButtonLink = exports.TabButton = exports.SrAnnouncer = exports.TextField = exports.Input = exports.ActionButtonLink = exports.ActionButton = exports.ButtonLink = exports.Button = exports.createTheme = exports.ThemeProvider = exports.Global = exports.css = exports.styled = void 0;
|
|
5
5
|
var styled_1 = require("@emotion/styled");
|
|
6
6
|
Object.defineProperty(exports, "styled", { enumerable: true, get: function () { return styled_1.default; } });
|
|
7
7
|
var react_1 = require("@emotion/react");
|
|
@@ -26,5 +26,7 @@ var TabButtonList_1 = require("./components/TabButtons/TabButtonList");
|
|
|
26
26
|
Object.defineProperty(exports, "TabButton", { enumerable: true, get: function () { return TabButtonList_1.TabButton; } });
|
|
27
27
|
Object.defineProperty(exports, "TabButtonLink", { enumerable: true, get: function () { return TabButtonList_1.TabButtonLink; } });
|
|
28
28
|
Object.defineProperty(exports, "TabButtonList", { enumerable: true, get: function () { return TabButtonList_1.TabButtonList; } });
|
|
29
|
+
var VERSION_1 = require("./VERSION");
|
|
30
|
+
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return VERSION_1.VERSION; } });
|
|
29
31
|
var VisuallyHidden_1 = require("./components/VisuallyHidden/VisuallyHidden");
|
|
30
32
|
Object.defineProperty(exports, "VisuallyHidden", { enumerable: true, get: function () { return VisuallyHidden_1.VisuallyHidden; } });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A wrapper around fetch that retries the request on certain error codes.
|
|
3
|
+
*
|
|
4
|
+
* By default:
|
|
5
|
+
*
|
|
6
|
+
* Requests will be retried if max retries not exceeded and :
|
|
7
|
+
* - The status code is >= 400 AND NOT in the NO_RETRY_ERROR_CODES list,
|
|
8
|
+
* - OR the request promise rejected (network error)
|
|
9
|
+
*
|
|
10
|
+
* The retry delay is exponential, 1s, 2s, 4s, 8s, ... maxing at 30s.
|
|
11
|
+
*
|
|
12
|
+
* Maximum retries is 3.
|
|
13
|
+
*
|
|
14
|
+
* NOTE:
|
|
15
|
+
* - When NODE_ENV="test", the maximum retries is set 0 by default but can be
|
|
16
|
+
* set via the TEST_ENV_MAX_RETRIES environment variable.
|
|
17
|
+
*/
|
|
18
|
+
declare const retryingFetch: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>) & typeof globalThis.fetch;
|
|
19
|
+
export default retryingFetch;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const MAX_RETRIES = 3;
|
|
4
|
+
const NO_RETRY_ERROR_CODES = [400, 401, 403, 404, 405, 409, 422];
|
|
5
|
+
const BASE_RETRY_DELAY = process.env.NODE_ENV === "test" ? 10 : 1000;
|
|
6
|
+
// This is a workaround to ensure retryingFetch uses MSW's fetch version in tests.
|
|
7
|
+
// See https://github.com/jonbern/fetch-retry/issues/95#issuecomment-2613990480
|
|
8
|
+
const fetch = (...args) => window.fetch(...args);
|
|
9
|
+
// From https://github.com/jonbern/fetch-retry/blob/master/index.js
|
|
10
|
+
const fetchRetry = (fetch, { retryDelay, retryOn }) => {
|
|
11
|
+
return (input, init) => {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
const wrappedFetch = (attempt) => {
|
|
14
|
+
const _input = typeof Request !== "undefined" && input instanceof Request
|
|
15
|
+
? input.clone()
|
|
16
|
+
: input;
|
|
17
|
+
fetch(_input, init)
|
|
18
|
+
.then((response) => {
|
|
19
|
+
try {
|
|
20
|
+
Promise.resolve(retryOn(attempt, null, response))
|
|
21
|
+
.then((retryOnResponse) => {
|
|
22
|
+
if (retryOnResponse) {
|
|
23
|
+
retry(attempt, null, response);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
resolve(response);
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
.catch(reject);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
reject(error);
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
.catch((error) => {
|
|
36
|
+
try {
|
|
37
|
+
Promise.resolve(retryOn(attempt, error, null))
|
|
38
|
+
.then((retryOnResponse) => {
|
|
39
|
+
if (retryOnResponse) {
|
|
40
|
+
retry(attempt, error, null);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
reject(error);
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
.catch((error) => {
|
|
47
|
+
reject(error);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
reject(error);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
const retry = (attempt, error, response) => {
|
|
56
|
+
const delay = retryDelay(attempt, error, response);
|
|
57
|
+
setTimeout(() => {
|
|
58
|
+
wrappedFetch(++attempt);
|
|
59
|
+
}, delay);
|
|
60
|
+
};
|
|
61
|
+
wrappedFetch(0);
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* A wrapper around fetch that retries the request on certain error codes.
|
|
67
|
+
*
|
|
68
|
+
* By default:
|
|
69
|
+
*
|
|
70
|
+
* Requests will be retried if max retries not exceeded and :
|
|
71
|
+
* - The status code is >= 400 AND NOT in the NO_RETRY_ERROR_CODES list,
|
|
72
|
+
* - OR the request promise rejected (network error)
|
|
73
|
+
*
|
|
74
|
+
* The retry delay is exponential, 1s, 2s, 4s, 8s, ... maxing at 30s.
|
|
75
|
+
*
|
|
76
|
+
* Maximum retries is 3.
|
|
77
|
+
*
|
|
78
|
+
* NOTE:
|
|
79
|
+
* - When NODE_ENV="test", the maximum retries is set 0 by default but can be
|
|
80
|
+
* set via the TEST_ENV_MAX_RETRIES environment variable.
|
|
81
|
+
*/
|
|
82
|
+
const retryingFetch = fetchRetry(fetch, {
|
|
83
|
+
retryDelay: (attempt, _error, _response) => {
|
|
84
|
+
return Math.min(BASE_RETRY_DELAY * Math.pow(2, attempt), 30000);
|
|
85
|
+
},
|
|
86
|
+
retryOn: (attempt, _error, response) => {
|
|
87
|
+
if (attempt >= MAX_RETRIES) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
if (response) {
|
|
91
|
+
if (response.status < 400)
|
|
92
|
+
return false;
|
|
93
|
+
return !NO_RETRY_ERROR_CODES.includes(response.status);
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
exports.default = retryingFetch;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const retryingFetch_1 = require("./retryingFetch");
|
|
13
|
+
const msw_1 = require("msw");
|
|
14
|
+
const node_1 = require("msw/node");
|
|
15
|
+
const counter = jest.fn(); // use jest.fn as counter because it resets on each test
|
|
16
|
+
const NETWORK_SUCCESS_URL = "http://localhost:3456/success";
|
|
17
|
+
const NETWORK_ERROR_URL = "http://localhost:3456/error";
|
|
18
|
+
const server = (0, node_1.setupServer)(msw_1.http.get(NETWORK_SUCCESS_URL, (_a) => __awaiter(void 0, [_a], void 0, function* ({ request }) {
|
|
19
|
+
var _b;
|
|
20
|
+
counter();
|
|
21
|
+
const url = new URL(request.url);
|
|
22
|
+
const status = +((_b = url.searchParams.get("status")) !== null && _b !== void 0 ? _b : 200);
|
|
23
|
+
return msw_1.HttpResponse.text(`Status ${status}`, { status });
|
|
24
|
+
})), msw_1.http.get(NETWORK_ERROR_URL, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
counter();
|
|
26
|
+
return msw_1.HttpResponse.error();
|
|
27
|
+
})));
|
|
28
|
+
beforeAll(() => server.listen());
|
|
29
|
+
afterEach(() => server.resetHandlers());
|
|
30
|
+
afterAll(() => server.close());
|
|
31
|
+
describe("retryingFetch", () => {
|
|
32
|
+
beforeAll(() => { });
|
|
33
|
+
test.each([200, 201, 202, 367, 400, 401, 403])("should not retry on %s", (status) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
const result = yield (0, retryingFetch_1.default)(`${NETWORK_SUCCESS_URL}?status=${status}`);
|
|
35
|
+
expect(yield result.text()).toBe(`Status ${status}`);
|
|
36
|
+
expect(counter).toHaveBeenCalledTimes(1);
|
|
37
|
+
}));
|
|
38
|
+
test.each([429, 500, 501, 502, 503])("should retry on %s", (status) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
+
const result = yield (0, retryingFetch_1.default)(`${NETWORK_SUCCESS_URL}?status=${status}`);
|
|
40
|
+
expect(yield result.text()).toBe(`Status ${status}`);
|
|
41
|
+
expect(counter).toHaveBeenCalledTimes(4);
|
|
42
|
+
}));
|
|
43
|
+
test("should retry on error", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
const result = yield (0, retryingFetch_1.default)(NETWORK_ERROR_URL).catch((err) => err);
|
|
45
|
+
expect(result).toBeInstanceOf(Error);
|
|
46
|
+
expect(counter).toHaveBeenCalledTimes(4);
|
|
47
|
+
}));
|
|
48
|
+
});
|