Skip to content

Commit 157b406

Browse files
fix: adjust AI button placement and fix fractions in prompt
1 parent 5f0a220 commit 157b406

File tree

5 files changed

+22
-28
lines changed

5 files changed

+22
-28
lines changed

calc-backend/src/controllers/gemini.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export async function askIntegral(req: Request, res: Response) {
1919
config: {
2020
maxOutputTokens: 225,
2121
temperature: 0.3,
22-
systemInstruction: "You are a calculus 1 tutor. You will brielfy summarize the integral asked in the context of a Riemann Sum to a student. The student has a program to let them visualize their function that has their function graphed and they can move a slider to change the amount of rectangles in the Riemann Sum. Try to limit yourself to 150 words. You should use html tags for math symbols, instead of '^' use <sup></sup> and instead of '/' for fractions you can use &frasl;"
22+
systemInstruction: "You are a calculus 1 tutor. You will brielfy summarize the integral asked in the context of a Riemann Sum to a student. The student has a program to let them visualize their function that has their function graphed and they can move a slider to change the amount of rectangles in the Riemann Sum. Try to limit yourself to 150 words. You should use html tags for math symbols, instead of '^' use <sup></sup>"
2323
},
2424
});
2525

calc-frontend/src/App/RootLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ function RootLayout(){
1313
<>
1414
<ScrollRestoration/>
1515
<div className="flex flex-col">
16-
<div className="header flex items-center justify-between gap-4">
16+
<div className="header flex items-center justify-between gap-[15px]">
1717

18-
<div className="flex items-center gap-2">
18+
<div className="flex items-center gap-[8px]">
1919
<Link to ='/'>
2020
<h1 className="w-fit font-medium">Calc Visualizer</h1>
2121
</Link>

calc-frontend/src/components/ui/AskAIButtonIntegral.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function AskAIButtonIntegral({
2222
const [open, setOpen] = useState(false);
2323
const [loading, setLoading] = useState(false);
2424
const [markdownText, setMarkdownText] = useState(
25-
`## 🤖 Ask AI\n\n### Graph your function, then click above for an explanation!`
25+
`### 🤖 Ask AI\n### Graph your function, then click above for an explanation!`
2626
);
2727

2828
const handleAskAI = async () => {
@@ -46,7 +46,7 @@ function AskAIButtonIntegral({
4646
onAIResponseComplete();
4747

4848
} catch (error) {
49-
setMarkdownText(`## ❌ An error occured, please try again`);
49+
setMarkdownText(`### ❌ An error occured, please try again`);
5050
console.error(error);
5151
} finally {
5252
setLoading(false);
@@ -56,7 +56,7 @@ function AskAIButtonIntegral({
5656
// the user has created a new graph
5757
useEffect(() => {
5858
if(key !== ''){
59-
setMarkdownText(`## 🤖 Ask AI\n\n### Click above for an explanation!`);
59+
setMarkdownText(`### 🤖 Ask AI\n### Click above for an explanation!`);
6060
}
6161
},[key])
6262

@@ -66,10 +66,10 @@ function AskAIButtonIntegral({
6666
onClick={() => {
6767
setOpen(true);
6868
}}
69-
className="cursor-pointer relative w-16 h-16 rounded-xl p-0.5 bg-gradient-to-tr from-pink-500 via-yellow-400 to-blue-500 hover:scale-105 transition-transform"
69+
className="cursor-pointer relative w-15 h-15 rounded-xl p-0.5 bg-gradient-to-tr from-pink-500 via-yellow-400 to-blue-500 hover:scale-105 transition-transform"
7070
>
7171
<div className="flex flex-col items-center justify-center w-full h-full bg-gray-800 text-white rounded-xl text-xs font-medium">
72-
<div className="text-lg font-bold mb-1">?</div>
72+
<div className="text-lg font-bold">?</div>
7373
Ask AI
7474
</div>
7575
</button>
@@ -85,16 +85,16 @@ function AskAIButtonIntegral({
8585
<div className="flex justify-between items-center mb-2 border-b-2 border-solid gap-2">
8686
{canAskAI ? (
8787
<button onClick={handleAskAI} className="cursor-pointer pb-1">
88-
<h2 className="text-xl font-semibold">{`Ask AI About: ${func}`}</h2>
88+
<h3 className="font-semibold">{`Ask AI About: ${func}`}</h3>
8989
</button>
9090
) : (
9191
<button
9292
className="cursor-pointer pb-1"
9393
onClick={() => setOpen(false)}
9494
>
95-
<h2 className="text-l font-medium">
95+
<h3 className="font-medium">
9696
Generate a New Function to Ask a Question
97-
</h2>
97+
</h3>
9898
</button>
9999
)}
100100

calc-frontend/src/components/ui/SaveFunctionButton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function SaveFunctionButton({onSave, saving, enableSave}: {onSave: (session: Ses
2020

2121
if(saving){
2222
return (
23-
<button className="back-button ml-[1rem]">
23+
<button className="back-button">
2424
<div className="animate-spin w-[1.125rem] h-[1.125rem] border-3 border-t-transparent border-white rounded-full"></div>
2525
</button>
2626
)
@@ -32,7 +32,7 @@ function SaveFunctionButton({onSave, saving, enableSave}: {onSave: (session: Ses
3232
<TooltipProvider delayDuration={0}>
3333
<Tooltip>
3434
<TooltipTrigger asChild>
35-
<button className="back-button ml-[1rem] disabled">Save Function</button>
35+
<button className="back-button disabled">Save Function</button>
3636
</TooltipTrigger>
3737

3838
<TooltipContent className="tooltip-content">
@@ -45,7 +45,7 @@ function SaveFunctionButton({onSave, saving, enableSave}: {onSave: (session: Ses
4545
}
4646

4747
return (
48-
<button className="back-button ml-[1rem]" onClick={handleClick}>
48+
<button className="back-button" onClick={handleClick}>
4949
Save Function
5050
</button>
5151
)

calc-frontend/src/pages/CustomIntegral.tsx

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ function CustomInt() {
105105
newFunc = generateFunction(funcLatex, python_code ?? true)
106106
}
107107
catch{
108-
setCanAskAI(false);
109108
setFormatCheck('Please enter a valid function')
110109
return 1
111110
}
@@ -118,7 +117,6 @@ function CustomInt() {
118117
// check if bounds are valid
119118
if(checkBounds !== 'success'){
120119
setFormatCheck(checkBounds)
121-
setCanAskAI(false);
122120
return 1
123121
}
124122

@@ -133,10 +131,10 @@ function CustomInt() {
133131
// check that new graph is different from old one
134132
if(newFuncKey !== funcKey){
135133
setFuncKey(newFuncKey)
134+
setCanAskAI(true);
136135
}
137136

138137
setFormatCheck('')
139-
setCanAskAI(true);
140138
setJsFunc(generateFunction(editMF.current.latex(), false));
141139

142140
return 0
@@ -176,14 +174,17 @@ function CustomInt() {
176174

177175
return(
178176
<div>
179-
<div style={{display:'flex', justifyContent:'space-between'}}>
177+
<div className="gap-[15px]" style={{display:'flex', justifyContent:'space-between'}}>
180178
<Link to="/integrals" tabIndex={-1}>
181179
<button className="back-button"> Back</button>
182180
</Link>
183-
184-
<SaveFunctionButton onSave={saveFunction} saving={saving} enableSave={enableSave}></SaveFunctionButton>
185181

186-
<div></div>
182+
<div>
183+
<SaveFunctionButton onSave={saveFunction} saving={saving} enableSave={enableSave}></SaveFunctionButton>
184+
</div>
185+
186+
<AskAIButton func={jsFunc} lowerBound={bounds[0]} upperBound={bounds[1]} key={funcKey}
187+
canAskAI={canAskAI} onAIResponseComplete={handleAIResponseComplete}/>
187188
</div>
188189

189190
<div className="center-header flex flex-wrap justify-center gap-[.5rem]" style={{alignItems:"center"}}>
@@ -206,13 +207,6 @@ function CustomInt() {
206207
<button className="go-button brighten mb-[.5rem]" onClick={()=>generateOutput()}>Graph</button>
207208
</div>
208209

209-
<div style={{display:'grid'}}>
210-
<div className="" style={{position:'fixed', zIndex:'1', justifySelf:'end'}}>
211-
<AskAIButton func={jsFunc} lowerBound={bounds[0]} upperBound={bounds[1]} key={funcKey}
212-
canAskAI={canAskAI} onAIResponseComplete={handleAIResponseComplete}/>
213-
</div>
214-
</div>
215-
216210
{
217211
formatCheck === ''? func === ''? null :
218212
<div className="graph-outer-box" style={{justifyContent: "center", marginTop:'.5rem'}}>

0 commit comments

Comments
 (0)