Skip to content

Commit a7be1ee

Browse files
kevin-lanngithub-actions[bot]
authored andcommitted
Auto-formatted the code using Prettier
1 parent 2a209e7 commit a7be1ee

File tree

10 files changed

+147
-53
lines changed

10 files changed

+147
-53
lines changed

course-matrix/backend/src/config/config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import { config } from "dotenv";
66
const configFile = `./.env`;
77
config({ path: configFile });
88

9-
const {
10-
PORT,
11-
NODE_ENV,
12-
CLIENT_APP_URL,
13-
DATABASE_URL,
9+
const {
10+
PORT,
11+
NODE_ENV,
12+
CLIENT_APP_URL,
13+
DATABASE_URL,
1414
DATABASE_KEY,
1515
OPENAI_API_KEY,
16-
} = process.env;
16+
} = process.env;
1717

1818
/**
1919
* Configuration object containing environment variables.
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
import asyncHandler from "../middleware/asyncHandler";
22
import { Request, Response } from "express";
3-
import{ createOpenAI } from '@ai-sdk/openai';
4-
import { streamText } from 'ai';
3+
import { createOpenAI } from "@ai-sdk/openai";
4+
import { streamText } from "ai";
55

66
const openai = createOpenAI({
77
baseURL: process.env.OPENAI_BASE_URL,
88
// apiKey: process.env.OPENAI_API_KEY
99
});
1010

11-
console.log("Connected to OpenAI API")
11+
console.log("Connected to OpenAI API");
1212

1313
export const chat = asyncHandler(async (req: Request, res: Response) => {
1414
const { messages } = req.body;
1515
const result = streamText({
16-
model: openai('gpt-4o-mini'),
16+
model: openai("gpt-4o-mini"),
1717
system:
1818
`You are an AI chatbot assistant named Morpheus for an application called Course Matrix. ` +
1919
`Course Matrix is a AI-powered platform designed to streamline the course selection` +
2020
`and timetable creation process for undergraduate students at University of Toronto Scarborough (UTSC).` +
21-
`Its key features are: ` +
21+
`Its key features are: ` +
2222
`1. Ability to automatically generate timetables for users in 1 click based on their` +
2323
`preselected courses and personal preferences like times and dates.` +
2424
`2. Integration with AI to let users create timetables and ask questions about` +
@@ -29,4 +29,4 @@ export const chat = asyncHandler(async (req: Request, res: Response) => {
2929
});
3030

3131
result.pipeDataStreamToResponse(res);
32-
});
32+
});

course-matrix/backend/src/index.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ const HOST = "localhost";
2323
let server: Server;
2424
const swaggerDocs = swaggerjsdoc(swaggerOptions);
2525

26-
app.use(cors({
27-
origin: config.CLIENT_APP_URL,
28-
methods: ['POST'],
29-
credentials: true,
30-
allowedHeaders: ['Content-Type']
31-
}));
26+
app.use(
27+
cors({
28+
origin: config.CLIENT_APP_URL,
29+
methods: ["POST"],
30+
credentials: true,
31+
allowedHeaders: ["Content-Type"],
32+
}),
33+
);
3234
app.use(express.json());
3335
app.use(cookieParser());
3436
app.use(express.urlencoded({ extended: true }));
@@ -42,7 +44,7 @@ app.use("/auth", authRouter);
4244
app.use("/api/courses", coursesRouter);
4345
app.use("/api/departments", departmentsRouter);
4446
app.use("/api/offerings", offeringsRouter);
45-
app.use("/api/ai", aiRouter)
47+
app.use("/api/ai", aiRouter);
4648

4749
/**
4850
* Root route to test the backend server.
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import express from "express";
2-
import {
3-
chat
4-
} from '../controllers/aiController'
2+
import { chat } from "../controllers/aiController";
53

64
export const aiRouter = express.Router();
75

8-
aiRouter.post('/chat', chat)
6+
aiRouter.post("/chat", chat);

course-matrix/frontend/src/components/assistant-ui/markdown-text.tsx

Lines changed: 108 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,64 +66,154 @@ const useCopyToClipboard = ({
6666

6767
const defaultComponents = memoizeMarkdownComponents({
6868
h1: ({ className, ...props }) => (
69-
<h1 className={cn("mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0", className)} {...props} />
69+
<h1
70+
className={cn(
71+
"mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0",
72+
className,
73+
)}
74+
{...props}
75+
/>
7076
),
7177
h2: ({ className, ...props }) => (
72-
<h2 className={cn("mb-4 mt-8 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0", className)} {...props} />
78+
<h2
79+
className={cn(
80+
"mb-4 mt-8 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0",
81+
className,
82+
)}
83+
{...props}
84+
/>
7385
),
7486
h3: ({ className, ...props }) => (
75-
<h3 className={cn("mb-4 mt-6 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0", className)} {...props} />
87+
<h3
88+
className={cn(
89+
"mb-4 mt-6 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0",
90+
className,
91+
)}
92+
{...props}
93+
/>
7694
),
7795
h4: ({ className, ...props }) => (
78-
<h4 className={cn("mb-4 mt-6 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0", className)} {...props} />
96+
<h4
97+
className={cn(
98+
"mb-4 mt-6 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0",
99+
className,
100+
)}
101+
{...props}
102+
/>
79103
),
80104
h5: ({ className, ...props }) => (
81-
<h5 className={cn("my-4 text-lg font-semibold first:mt-0 last:mb-0", className)} {...props} />
105+
<h5
106+
className={cn(
107+
"my-4 text-lg font-semibold first:mt-0 last:mb-0",
108+
className,
109+
)}
110+
{...props}
111+
/>
82112
),
83113
h6: ({ className, ...props }) => (
84-
<h6 className={cn("my-4 font-semibold first:mt-0 last:mb-0", className)} {...props} />
114+
<h6
115+
className={cn("my-4 font-semibold first:mt-0 last:mb-0", className)}
116+
{...props}
117+
/>
85118
),
86119
p: ({ className, ...props }) => (
87-
<p className={cn("mb-5 mt-5 text-sm leading-7 first:mt-0 last:mb-0", className)} {...props} />
120+
<p
121+
className={cn(
122+
"mb-5 mt-5 text-sm leading-7 first:mt-0 last:mb-0",
123+
className,
124+
)}
125+
{...props}
126+
/>
88127
),
89128
a: ({ className, ...props }) => (
90-
<a className={cn("text-primary font-medium underline underline-offset-4", className)} {...props} />
129+
<a
130+
className={cn(
131+
"text-primary font-medium underline underline-offset-4",
132+
className,
133+
)}
134+
{...props}
135+
/>
91136
),
92137
blockquote: ({ className, ...props }) => (
93-
<blockquote className={cn("border-l-2 pl-6 italic", className)} {...props} />
138+
<blockquote
139+
className={cn("border-l-2 pl-6 italic", className)}
140+
{...props}
141+
/>
94142
),
95143
ul: ({ className, ...props }) => (
96-
<ul className={cn("my-5 ml-6 list-disc [&>li]:mt-2", className)} {...props} />
144+
<ul
145+
className={cn("my-5 ml-6 list-disc [&>li]:mt-2", className)}
146+
{...props}
147+
/>
97148
),
98149
ol: ({ className, ...props }) => (
99-
<ol className={cn("my-5 ml-6 list-decimal [&>li]:mt-2", className)} {...props} />
150+
<ol
151+
className={cn("my-5 ml-6 list-decimal [&>li]:mt-2", className)}
152+
{...props}
153+
/>
100154
),
101155
hr: ({ className, ...props }) => (
102156
<hr className={cn("my-5 border-b", className)} {...props} />
103157
),
104158
table: ({ className, ...props }) => (
105-
<table className={cn("my-5 w-full border-separate border-spacing-0 overflow-y-auto", className)} {...props} />
159+
<table
160+
className={cn(
161+
"my-5 w-full border-separate border-spacing-0 overflow-y-auto",
162+
className,
163+
)}
164+
{...props}
165+
/>
106166
),
107167
th: ({ className, ...props }) => (
108-
<th className={cn("bg-muted px-4 py-2 text-left font-bold first:rounded-tl-lg last:rounded-tr-lg [&[align=center]]:text-center [&[align=right]]:text-right", className)} {...props} />
168+
<th
169+
className={cn(
170+
"bg-muted px-4 py-2 text-left font-bold first:rounded-tl-lg last:rounded-tr-lg [&[align=center]]:text-center [&[align=right]]:text-right",
171+
className,
172+
)}
173+
{...props}
174+
/>
109175
),
110176
td: ({ className, ...props }) => (
111-
<td className={cn("border-b border-l px-4 py-2 text-left last:border-r [&[align=center]]:text-center [&[align=right]]:text-right", className)} {...props} />
177+
<td
178+
className={cn(
179+
"border-b border-l px-4 py-2 text-left last:border-r [&[align=center]]:text-center [&[align=right]]:text-right",
180+
className,
181+
)}
182+
{...props}
183+
/>
112184
),
113185
tr: ({ className, ...props }) => (
114-
<tr className={cn("m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg", className)} {...props} />
186+
<tr
187+
className={cn(
188+
"m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg",
189+
className,
190+
)}
191+
{...props}
192+
/>
115193
),
116194
sup: ({ className, ...props }) => (
117-
<sup className={cn("[&>a]:text-xs [&>a]:no-underline", className)} {...props} />
195+
<sup
196+
className={cn("[&>a]:text-xs [&>a]:no-underline", className)}
197+
{...props}
198+
/>
118199
),
119200
pre: ({ className, ...props }) => (
120-
<pre className={cn("overflow-x-auto rounded-b-lg bg-black p-4 text-white", className)} {...props} />
201+
<pre
202+
className={cn(
203+
"overflow-x-auto rounded-b-lg bg-black p-4 text-white",
204+
className,
205+
)}
206+
{...props}
207+
/>
121208
),
122209
code: function Code({ className, ...props }) {
123210
const isCodeBlock = useIsMarkdownCodeBlock();
124211
return (
125212
<code
126-
className={cn(!isCodeBlock && "bg-muted rounded border font-semibold", className)}
213+
className={cn(
214+
!isCodeBlock && "bg-muted rounded border font-semibold",
215+
className,
216+
)}
127217
{...props}
128218
/>
129219
);

course-matrix/frontend/src/components/assistant-ui/thread-list.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ export const ThreadList: FC = () => {
2020
const ThreadListNew: FC = () => {
2121
return (
2222
<ThreadListPrimitive.New asChild>
23-
<Button className="data-[active]:bg-muted hover:bg-muted flex items-center justify-start gap-1 rounded-lg px-2.5 py-2 text-start" variant="ghost">
23+
<Button
24+
className="data-[active]:bg-muted hover:bg-muted flex items-center justify-start gap-1 rounded-lg px-2.5 py-2 text-start"
25+
variant="ghost"
26+
>
2427
<PlusIcon />
2528
New Thread
2629
</Button>

course-matrix/frontend/src/components/assistant-ui/thread.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import { Button } from "@/components/ui/button";
2323
import { MarkdownText } from "@/components/assistant-ui/markdown-text";
2424
import { TooltipIconButton } from "@/components/assistant-ui/tooltip-icon-button";
2525

26-
2726
export const Thread: FC = () => {
2827
return (
2928
<ThreadPrimitive.Root
@@ -79,7 +78,8 @@ const ThreadWelcome: FC = () => {
7978
<AvatarFallback>M</AvatarFallback>
8079
</Avatar>
8180
<p className="mt-4 font-medium">
82-
Hi my name is <span className="text-primary">Morpheus</span>. How can I help you today?
81+
Hi my name is <span className="text-primary">Morpheus</span>. How
82+
can I help you today?
8383
</p>
8484
</div>
8585
<ThreadWelcomeSuggestions />
@@ -271,7 +271,10 @@ const BranchPicker: FC<BranchPickerPrimitive.Root.Props> = ({
271271
return (
272272
<BranchPickerPrimitive.Root
273273
hideWhenSingleBranch
274-
className={cn("text-muted-foreground inline-flex items-center text-xs", className)}
274+
className={cn(
275+
"text-muted-foreground inline-flex items-center text-xs",
276+
className,
277+
)}
275278
{...rest}
276279
>
277280
<BranchPickerPrimitive.Previous asChild>
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { Assistant } from "@/pages/Assistant/assistant"
1+
import { Assistant } from "@/pages/Assistant/assistant";
22

33
const AssistantPage = () => {
4-
return (
5-
<Assistant />
6-
)
7-
}
4+
return <Assistant />;
5+
};
86

9-
export default AssistantPage
7+
export default AssistantPage;

course-matrix/frontend/src/pages/Dashboard/Dashboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const Dashboard = () => {
7777
<Route path="/" element={<Navigate to="home" replace />} />
7878
<Route path="/home" element={<>Home</>} />
7979
<Route path="/timetable" element={<TimetableBuilder />} />
80-
<Route path="/assistant" element={<AssistantPage/>} />
80+
<Route path="/assistant" element={<AssistantPage />} />
8181
</Routes>
8282
</div>
8383
</SidebarInset>

course-matrix/frontend/tailwind.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ export default {
8787
},
8888
plugins: [
8989
require("tailwindcss-animate"),
90-
require("@assistant-ui/react-ui/tailwindcss")({ shadcn: true })
90+
require("@assistant-ui/react-ui/tailwindcss")({ shadcn: true }),
9191
],
9292
};

0 commit comments

Comments
 (0)