Skip to content

Commit bc5aa37

Browse files
authored
Merge pull request #53 from vickeykumar/development
Added dsa questions prompt to generate dsa questions
2 parents 1b1d88d + 1b4b45c commit bc5aa37

19 files changed

+1593
-84
lines changed

install_prerequisite.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,20 @@ else
137137
rm -rf evcxr-v0.17.0-x86_64-unknown-linux-gnu
138138
fi
139139

140-
140+
#install rappel, nasm and set all the required dependencies
141+
if [ -e "/usr/local/bin/rappel" ]; then
142+
echo "File /usr/local/bin/rappel exists."
143+
else
144+
echo "File /usr/local/bin/rappel does not exist. installing..."
145+
apt-get install -y --no-install-recommends libedit-dev
146+
apt-get install -y --no-install-recommends nasm
147+
git clone https://github.com/yrp604/rappel.git
148+
cd rappel
149+
make
150+
ln -s $GOTTY_DIR/rappel/bin/rappel /usr/local/bin/rappel
151+
chmod 755 /usr/local/bin/rappel
152+
cd ..
153+
fi
141154

142155
#install gointerpreter
143156
git clone https://github.com/vickeykumar/Go-interpreter.git
@@ -236,6 +249,7 @@ if [ $run_tests -eq 1 ]; then
236249
"sqlite3 --version"
237250
"tsc --version"
238251
"ts-node --version"
252+
"echo "nop" | rappel"
239253
)
240254

241255

src/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ bindata:
3333
bindata/static: bindata
3434
mkdir bindata/static
3535

36-
bindata/static/index.html: bindata/static resources/index.html resources/profile.html resources/robots.txt jsconsole/build/static/jsconsole.html
36+
bindata/static/index.html: bindata/static resources/index.html resources/profile.html resources/practice.html resources/robots.txt jsconsole/build/static/jsconsole.html
3737
cp resources/index.html bindata/static/index.html
3838
cp resources/profile.html bindata/static/profile.html
39+
cp resources/practice.html bindata/static/practice.html
3940
cp resources/robots.txt bindata/static/robots.txt
4041
cp jsconsole/build/static/jsconsole.html bindata/static/jsconsole.html
4142

src/containers/container.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var Commands2memLimitMap = map[string]int64{
3535
"evcxr": 50, // rust REPL
3636
"sqlite3": 10,
3737
"ts-node": 50,
38+
"rappel": 2,
3839
}
3940

4041
var memLimitMutex sync.Mutex

src/resources/chat-widget/src/index.ts

Lines changed: 127 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,29 @@ const WIDGET_MESSAGES_HISTORY_CONTAINER_ID =
1313
const WIDGET_THINKING_BUBBLE_ID = "chat-widget__thinking_bubble";
1414
const CHAT_LIST_KEY = "chat-list"
1515

16+
const interviewPrompt = `
17+
You are an expert coding interviewer conducting a technical interview. Your goal is to assess the candidate's ability to solve a coding problem independently.
18+
19+
### Interview Process:
20+
1. Start by presenting the problem statement and constraints clearly from IDE.
21+
2. Do NOT give the solution or direct hints unless the user explicitly asks for help or is stuck.
22+
3. Encourage the candidate to **think aloud** and explain their approach.
23+
4. If the candidate provides an incorrect approach, ask **clarifying questions** to guide them.
24+
5. Only give small hints when necessary, helping them think in the right direction without revealing the full solution.
25+
6. Use Socratic questioning to probe their understanding:
26+
- "What data structure might be useful for this problem?"
27+
- "Can you optimize your current approach?"
28+
- "What are the edge cases you need to consider?"
29+
7. If the candidate asks for a full solution, politely **decline** and encourage them to try again.
30+
8. If they are truly stuck (e.g., multiple failed attempts), provide a **small hint** to unblock them.
31+
9. Once they reach a correct approach, let them implement it and provide constructive feedback.
32+
33+
### Response Guidelines:
34+
- Be professional and supportive but **not too helpful**.
35+
- Encourage the user to debug their code rather than fixing it for them.
36+
- Give feedback in a way that promotes learning and problem-solving skills.
37+
`
38+
1639
function generateFiveCharUUID(): string {
1740
// Generate a UUID and extract the first 5 characters
1841
const uuid: string = crypto.randomUUID();
@@ -108,17 +131,24 @@ const MAX_HISTORY_SIZE = 20;
108131
// Initialize the conversationHistory array
109132
let conversationHistory: MessageType[] = [];
110133

134+
function getcurrentIDECode(): MessageType {
135+
let idecodemsg = {
136+
role: "system",
137+
content: `Openrepl IDE/Editor real-time Code Content user is working on,
138+
(refer this code whenever user ask to debug editor/ide
139+
code without providing any code in message): `+ fetchEditorContent(),
140+
}
141+
return idecodemsg;
142+
}
143+
111144
// Function to add a message to the conversation history
112145
function addMessageToHistory(role: string, content: string, uid: string=UID): void {
113146
if (role=="user") {
114147
// to handle multiple peer users
115148
content = `[${role}-${uid}] ` + content;
116149
if (conversationHistory.length >= NUM_MANDATORY_ENTRIES) {
117150
// update editors content to msg history everytime user writes/sends message
118-
conversationHistory[NUM_MANDATORY_ENTRIES-1] = {
119-
role: "system",
120-
content: "Openrepl IDE/Editor Code Content: "+ fetchEditorContent(),
121-
}
151+
conversationHistory[NUM_MANDATORY_ENTRIES-1] = getcurrentIDECode();
122152
}
123153
}
124154

@@ -225,8 +255,16 @@ async function init() {
225255
);
226256
open({ target } as Event);
227257
}
228-
addMessageToHistory("system", "welcome to openrepl.com!! I am Genie. your OpenRepl AI assistant.");
229-
addMessageToHistory("system", "documentation: "+documentation);
258+
259+
let welcomeprompt = "welcome to openrepl.com!! you are Genie. An OpenRepl AI";
260+
// only four permanent prompts
261+
if (window.location.pathname.includes("practice")) {
262+
addMessageToHistory("system", welcomeprompt+" Interviewer.");
263+
addMessageToHistory("system", interviewPrompt);
264+
} else {
265+
addMessageToHistory("system", welcomeprompt+" Assistant.");
266+
addMessageToHistory("system", "documentation: "+documentation);
267+
}
230268
addMessageToHistory("system", "keywords: "+ keywords);
231269
addMessageToHistory("system", "Openrepl IDE/EditorCodeContent: "+ fetchEditorContent());
232270
setupFBListener();
@@ -256,6 +294,87 @@ const trap = createFocusTrap(containerElement, {
256294
allowOutsideClick: true,
257295
});
258296

297+
function makeResizable(containerElement: HTMLElement, target: HTMLElement) {
298+
// Create a resizer div
299+
const resizer = document.createElement("div");
300+
resizer.innerHTML = `
301+
<svg width="20" height="20" viewBox="0 0 20 20">
302+
<line x1="4" y1="16" x2="16" y2="4" stroke="gray" stroke-width="2" />
303+
<line x1="8" y1="16" x2="16" y2="8" stroke="gray" stroke-width="2" />
304+
</svg>
305+
`;
306+
resizer.style.position = "absolute";
307+
resizer.style.left = "5px";
308+
resizer.style.top = "5px";
309+
resizer.style.cursor = "nwse-resize";
310+
resizer.style.opacity = "0.7";
311+
resizer.style.transition = "opacity 0.2s";
312+
resizer.style.display = "flex";
313+
resizer.style.alignItems = "center";
314+
resizer.style.justifyContent = "center";
315+
resizer.style.width = "15px";
316+
resizer.style.height = "15px";
317+
318+
// Style the container for a modern feel
319+
Object.assign(containerElement.style, {
320+
position: "absolute",
321+
borderRadius: "10px",
322+
boxShadow: "0 4px 10px rgba(0, 0, 0, 0.2)",
323+
overflow: "hidden",
324+
resize: "none", // Disable native resize
325+
transition: "width 0.2s ease, height 0.2s ease",
326+
});
327+
328+
containerElement.appendChild(resizer);
329+
330+
let isResizing = false;
331+
332+
resizer.addEventListener("mousedown", (e) => {
333+
e.preventDefault();
334+
isResizing = true;
335+
336+
const startX = e.clientX;
337+
const startY = e.clientY;
338+
const startWidth = containerElement.offsetWidth;
339+
const startHeight = containerElement.offsetHeight;
340+
341+
function resize(e: MouseEvent) {
342+
if (!isResizing) return;
343+
const newWidth = Math.max(150, startWidth + (startX - e.clientX)); // Min width: 150px
344+
const newHeight = Math.max(100, startHeight + (startY - e.clientY)); // Min height: 100px
345+
containerElement.style.width = `${newWidth}px`;
346+
containerElement.style.height = `${newHeight}px`;
347+
348+
// Recompute floating position to keep alignment
349+
updatePosition();
350+
}
351+
352+
function stopResize() {
353+
isResizing = false;
354+
document.removeEventListener("mousemove", resize);
355+
document.removeEventListener("mouseup", stopResize);
356+
}
357+
358+
document.addEventListener("mousemove", resize);
359+
document.addEventListener("mouseup", stopResize);
360+
});
361+
362+
function updatePosition() {
363+
computePosition(target, containerElement, {
364+
placement: "top-start",
365+
middleware: [flip(), shift({ crossAxis: true, padding: 8 })],
366+
strategy: "fixed",
367+
}).then(({ x, y }) => {
368+
Object.assign(containerElement.style, {
369+
left: `${x}px`,
370+
top: `${y}px`,
371+
});
372+
});
373+
}
374+
375+
return updatePosition; // Return the function so it can be used if needed
376+
}
377+
259378
function open(e: Event) {
260379
if (config.closeOnOutsideClick) {
261380
document.body.appendChild(optionalBackdrop);
@@ -293,6 +412,7 @@ function open(e: Event) {
293412
});
294413
});
295414

415+
makeResizable(containerElement, target);
296416
trap.activate();
297417

298418
if (config.closeOnOutsideClick) {
@@ -486,7 +606,7 @@ async function submit(e: Event) {
486606
const data = {
487607
...config.user,
488608
model: config.model,
489-
messages: conversationHistory,
609+
messages: [...conversationHistory, getcurrentIDECode()],
490610
temperature: config.temperature,
491611
max_tokens: config.max_tokens,
492612
stream: config.responseIsAStream,

src/resources/chat-widget/src/widget.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
width: 100%;
167167
height: 100%;
168168
background-image: url('images/genie-large.png'); /* Path to your animated GIF */
169-
background-size: cover; /* Make the background cover the entire container */
169+
background-size: contain; /* Make the background contained */
170170
background-position: center; /* Center the background image */
171171
background-repeat: no-repeat; /* Prevent the background image from repeating */
172172
opacity: 0.5; /* Adjust opacity as needed */

src/resources/css/scribbler-global.css

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
--terminal-bg-color: black;
2424
--gutter-rotate: 90deg; /* Initial rotation angle */
2525
--gutter-right: 3px;
26+
--modal-duration: 1s;
27+
--clear-color: #ebebec;
28+
--shadow-color: rgba(0, 0, 0, 0.3);
29+
--overlay-color: rgba(0, 0, 0, 0.6);
2630
}
2731

2832
/* normalized */
@@ -506,4 +510,33 @@ input[type=text],[type=email], select, textarea, email {
506510
.rev-accent-background {
507511
background: var(--rev-accent-color);
508512
}
509-
/* them classes ends */
513+
/* them classes ends */
514+
515+
/* loaders */
516+
.loader, #loader {
517+
position: absolute;
518+
left: 50%;
519+
top: 50%;
520+
z-index: 11;
521+
width: 150px;
522+
height: 150px;
523+
margin: -75px 0 0 -75px;
524+
border: 16px solid #f3f3f3;
525+
border-radius: 50%;
526+
border-top: 16px solid #64CEAA;
527+
width: 80px;
528+
height: 80px;
529+
-webkit-animation: spin 1s linear infinite;
530+
animation: spin 1s linear infinite;
531+
}
532+
533+
@-webkit-keyframes spin {
534+
0% { -webkit-transform: rotate(0deg); }
535+
100% { -webkit-transform: rotate(360deg); }
536+
}
537+
538+
@keyframes spin {
539+
0% { transform: rotate(0deg); }
540+
100% { transform: rotate(360deg); }
541+
}
542+
/* loader ends */

src/resources/css/scribbler-landing.css

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -771,33 +771,6 @@ h2 {
771771
padding-right:10px;
772772
}
773773

774-
#loader {
775-
position: absolute;
776-
left: 50%;
777-
top: 50%;
778-
z-index: 11;
779-
width: 150px;
780-
height: 150px;
781-
margin: -75px 0 0 -75px;
782-
border: 16px solid #f3f3f3;
783-
border-radius: 50%;
784-
border-top: 16px solid #64CEAA;
785-
width: 80px;
786-
height: 80px;
787-
-webkit-animation: spin 1s linear infinite;
788-
animation: spin 1s linear infinite;
789-
}
790-
791-
@-webkit-keyframes spin {
792-
0% { -webkit-transform: rotate(0deg); }
793-
100% { -webkit-transform: rotate(360deg); }
794-
}
795-
796-
@keyframes spin {
797-
0% { transform: rotate(0deg); }
798-
100% { transform: rotate(360deg); }
799-
}
800-
801774
/* tooltip */
802775

803776
.tooltip {

0 commit comments

Comments
 (0)