Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommendation bot UI #2019

Merged
merged 19 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontends/main/Dockerfile.web
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ FROM node:22-alpine

RUN apk update
RUN apk add --no-cache libc6-compat
RUN apk add --no-cache git

WORKDIR /app

Expand Down
4 changes: 1 addition & 3 deletions frontends/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
"@emotion/cache": "^11.13.1",
"@emotion/styled": "^11.11.0",
"@mitodl/course-search-utils": "3.3.2",
"@mitodl/smoot-design": "^3.0.1",
"@mitodl/smoot-design": "^3.2.0",
"@next/bundle-analyzer": "^14.2.15",
"@nlux/react": "^2.17.1",
"@nlux/themes": "^2.17.1",
"@remixicon/react": "^4.2.0",
"@sentry/nextjs": "^8.36.0",
"@tanstack/react-query": "^4.36.1",
Expand Down
15 changes: 15 additions & 0 deletions frontends/main/public/images/icons/tim.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
98 changes: 49 additions & 49 deletions frontends/main/src/app-pages/ChatPage/ChatPage.tsx
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
"use client"
import React, { useMemo } from "react"
import { makeSend } from "./send"

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

const StyledChat = styled(NluxAiChat)({
maxHeight: "60vh",
flex: 1,
const Container = styled.div({
margin: "40px auto",
width: "60%",
})

const CONVERSATION_OPTIONS = {
conversationStarters: [
{
prompt:
"I'm interested in courses on quantum computing that offer certificates.",
},
{
prompt:
"I want to learn about global warming, can you recommend any videos?",
},
{
prompt:
"I am curious about AI applications for business. Do you have any free courses about that?",
},
{
prompt:
"I would like to learn about linear regression, preferably at no cost.",
},
],
}
const INITIAL_MESSAGES: AiChatProps["initialMessages"] = [
{
content: "What do you want to learn about today?",
role: "assistant",
},
]

export const STARTERS = [
{
content:
"I'm interested in courses on quantum computing that offer certificates.",
},
{
content:
"I want to learn about global warming, can you recommend any videos?",
},
{
content:
"I am curious about AI applications for business. Do you have any free courses about that?",
},
{
content:
"I would like to learn about linear regression, preferably at no cost.",
},
]

const ChatPage = () => {
const recommendationBotEnabled = useFeatureFlagEnabled(
FeatureFlags.RecommendationBot,
)
const send = useMemo(() => {
return makeSend({ url: "/api/v0/chat_agent/" })
}, [])
return (
<StyledContainer>
{
// eslint-disable-next-line no-constant-condition
recommendationBotEnabled ? (
<StyledChat
key={"agent"}
send={send}
conversationOptions={CONVERSATION_OPTIONS}
/>
) : (
<></>
)
}
</StyledContainer>
<Container>
<AiChat
askTimTitle="to recommend a course"
initialMessages={INITIAL_MESSAGES}
conversationStarters={STARTERS}
requestOpts={{
apiUrl: `${process.env.NEXT_PUBLIC_MITOL_API_BASE_URL}/api/v0/chat_agent/`,
fetchOpts: {
headers: {
"X-CSRFToken": getCsrfToken(),
},
},
transformBody: (messages) => ({
message: messages[messages.length - 1].content,
}),
}}
/>
</Container>
)
}

Expand Down
78 changes: 0 additions & 78 deletions frontends/main/src/app-pages/ChatPage/send.ts

This file was deleted.

Loading
Loading