Skip to content

Commit 123da67

Browse files
Recommendation bot UI (#2019)
* Update chat page to use Smoot Design AiChat * Homepage "Ask TIM" button and drawer entry screen * Hook up entry screen prompt and suggestions. Hover styling * Syllabus bot layout styles * Replace SVG images with Remixicon * Fix button selector for test * Remove send code * Latest smoot-design branch commit * fix lockfile * Match Input types * Install git on the docker build container * Install git in the container * Imperative handle approach for appending initial message * Prevent firing sppend twice if render between timer * fix lockfile * Starters as buttons for accessibility and disabled adornment button style * Upgrade smoot-design and remove nlux * Fix disabled hover --------- Co-authored-by: Chris Chudzicki <[email protected]>
1 parent b28659f commit 123da67

26 files changed

+659
-785
lines changed

frontends/main/Dockerfile.web

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ FROM node:22-alpine
5757

5858
RUN apk update
5959
RUN apk add --no-cache libc6-compat
60+
RUN apk add --no-cache git
6061

6162
WORKDIR /app
6263

frontends/main/package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@
1414
"@emotion/cache": "^11.13.1",
1515
"@emotion/styled": "^11.11.0",
1616
"@mitodl/course-search-utils": "3.3.2",
17-
"@mitodl/smoot-design": "^3.0.1",
17+
"@mitodl/smoot-design": "^3.2.0",
1818
"@next/bundle-analyzer": "^14.2.15",
19-
"@nlux/react": "^2.17.1",
20-
"@nlux/themes": "^2.17.1",
2119
"@remixicon/react": "^4.2.0",
2220
"@sentry/nextjs": "^8.36.0",
2321
"@tanstack/react-query": "^5.66",
+15
Loading

frontends/main/src/app-pages/ChatPage/ChatPage.tsx

+49-49
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,61 @@
11
"use client"
2-
import React, { useMemo } from "react"
3-
import { makeSend } from "./send"
42

5-
import { FeatureFlags } from "@/common/feature_flags"
6-
import { useFeatureFlagEnabled } from "posthog-js/react"
7-
import StyledContainer from "@/page-components/StyledContainer/StyledContainer"
3+
import React from "react"
84
import { styled } from "ol-components"
9-
import { NluxAiChat } from "@/page-components/Nlux-AiChat/AiChat"
5+
import { getCsrfToken } from "@/common/utils"
6+
import { AiChat, AiChatProps } from "@mitodl/smoot-design/ai"
107

11-
const StyledChat = styled(NluxAiChat)({
12-
maxHeight: "60vh",
13-
flex: 1,
8+
const Container = styled.div({
9+
margin: "40px auto",
10+
width: "60%",
1411
})
1512

16-
const CONVERSATION_OPTIONS = {
17-
conversationStarters: [
18-
{
19-
prompt:
20-
"I'm interested in courses on quantum computing that offer certificates.",
21-
},
22-
{
23-
prompt:
24-
"I want to learn about global warming, can you recommend any videos?",
25-
},
26-
{
27-
prompt:
28-
"I am curious about AI applications for business. Do you have any free courses about that?",
29-
},
30-
{
31-
prompt:
32-
"I would like to learn about linear regression, preferably at no cost.",
33-
},
34-
],
35-
}
13+
const INITIAL_MESSAGES: AiChatProps["initialMessages"] = [
14+
{
15+
content: "What do you want to learn about today?",
16+
role: "assistant",
17+
},
18+
]
19+
20+
export const STARTERS = [
21+
{
22+
content:
23+
"I'm interested in courses on quantum computing that offer certificates.",
24+
},
25+
{
26+
content:
27+
"I want to learn about global warming, can you recommend any videos?",
28+
},
29+
{
30+
content:
31+
"I am curious about AI applications for business. Do you have any free courses about that?",
32+
},
33+
{
34+
content:
35+
"I would like to learn about linear regression, preferably at no cost.",
36+
},
37+
]
3638

3739
const ChatPage = () => {
38-
const recommendationBotEnabled = useFeatureFlagEnabled(
39-
FeatureFlags.RecommendationBot,
40-
)
41-
const send = useMemo(() => {
42-
return makeSend({ url: "/api/v0/chat_agent/" })
43-
}, [])
4440
return (
45-
<StyledContainer>
46-
{
47-
// eslint-disable-next-line no-constant-condition
48-
recommendationBotEnabled ? (
49-
<StyledChat
50-
key={"agent"}
51-
send={send}
52-
conversationOptions={CONVERSATION_OPTIONS}
53-
/>
54-
) : (
55-
<></>
56-
)
57-
}
58-
</StyledContainer>
41+
<Container>
42+
<AiChat
43+
askTimTitle="to recommend a course"
44+
initialMessages={INITIAL_MESSAGES}
45+
conversationStarters={STARTERS}
46+
requestOpts={{
47+
apiUrl: `${process.env.NEXT_PUBLIC_MITOL_API_BASE_URL}/api/v0/chat_agent/`,
48+
fetchOpts: {
49+
headers: {
50+
"X-CSRFToken": getCsrfToken(),
51+
},
52+
},
53+
transformBody: (messages) => ({
54+
message: messages[messages.length - 1].content,
55+
}),
56+
}}
57+
/>
58+
</Container>
5959
)
6060
}
6161

frontends/main/src/app-pages/ChatPage/send.ts

-78
This file was deleted.

0 commit comments

Comments
 (0)