Skip to content

add auto request feature #34

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

Open
wants to merge 39 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9a19173
adjustment structure
Wzixiao May 31, 2023
d082a57
remove raw files
Wzixiao May 31, 2023
f2bba1f
Modify comments
Wzixiao May 31, 2023
6557afd
adjustment structure
Wzixiao May 31, 2023
4d8b503
fix removeJupyterOutput bug
Wzixiao May 31, 2023
651bd5e
fix removeJupyterOutput bug
Wzixiao May 31, 2023
0449e97
Modifying Fixbugs
Wzixiao May 31, 2023
10cff1b
Change the new structure
Wzixiao May 31, 2023
2ce7eb0
Change the new structure
Wzixiao May 31, 2023
680fbd3
remove log
Wzixiao May 31, 2023
e970c1c
remove log
Wzixiao May 31, 2023
854c36d
new comments
Wzixiao May 31, 2023
ef19291
remove code
Wzixiao May 31, 2023
30871f5
add fixbug
Wzixiao Jun 1, 2023
76420d0
Modify comments
Wzixiao Jun 1, 2023
aad82ec
Modify comments
Wzixiao Jun 1, 2023
1438e8a
Modify Method Name
Wzixiao Jun 1, 2023
13eccfb
add fixbug test file
Wzixiao Jun 1, 2023
55fad87
add fixbug test file
Wzixiao Jun 1, 2023
b3c6c77
add middle in center
Wzixiao Jun 1, 2023
debe916
alert
Wzixiao Jun 1, 2023
15335b8
remove require output
Wzixiao Jun 1, 2023
43ec61d
merge new_get_code
Wzixiao Jun 1, 2023
75ed50f
Fixbug preparation work
Wzixiao Jun 1, 2023
4253032
add full fix bug function
Wzixiao Jun 1, 2023
a9ca391
merge main
Wzixiao Jun 1, 2023
02621ca
Adjusting code structure
Wzixiao Jun 1, 2023
2023917
Adjusting code structure
Wzixiao Jun 1, 2023
66bc15a
fix insert bug
Wzixiao Jun 1, 2023
c17986e
fix cursor not in cell bug
Wzixiao Jun 2, 2023
9009c47
add redundance
Wzixiao Jun 2, 2023
53268bd
add commont
Wzixiao Jun 2, 2023
29a62c3
resert
Wzixiao Jun 2, 2023
aaf2424
add maxtoken
Wzixiao Jun 2, 2023
08bdbd5
modify maxtoken
Wzixiao Jun 2, 2023
568228a
add auto request feature
chenJuZ Jun 2, 2023
e75088e
remove log
Wzixiao Jun 2, 2023
e6be61b
fix 'fixbug' function lose efficacy bug
Wzixiao Jun 2, 2023
9d0f613
Resolve potential errors
Wzixiao Jun 2, 2023
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
240 changes: 240 additions & 0 deletions examples/fixing_bug_example.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"id": "1114df89",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'printa' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[4], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m# print \"Hello, World!\"\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m \u001b[43mprinta\u001b[49m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mHello, World!\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
"\u001b[1;31mNameError\u001b[0m: name 'printa' is not defined"
]
}
],
"source": [
"# print \"Hello, World!\"\n",
"printa(\"Hello, World!\")"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "88fe6fb4",
"metadata": {},
"outputs": [
{
"ename": "SyntaxError",
"evalue": "expected ':' (3930893725.py, line 1)",
"output_type": "error",
"traceback": [
"\u001b[1;36m Cell \u001b[1;32mIn[5], line 1\u001b[1;36m\u001b[0m\n\u001b[1;33m if x == 5\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m expected ':'\n"
]
}
],
"source": [
"if x == 5\n",
" print(\"x == 5\")"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "b73b834e",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'y' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[30], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m x \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m10\u001b[39m\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43my\u001b[49m)\n",
"\u001b[1;31mNameError\u001b[0m: name 'y' is not defined"
]
}
],
"source": [
"x = 10\n",
"print(y)"
]
},
{
"cell_type": "code",
"execution_count": 39,
"id": "72409629",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'calculate_sum' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[39], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mcalculate_sum\u001b[49m(\u001b[38;5;241m5\u001b[39m, \u001b[38;5;241m10\u001b[39m)\n",
"\u001b[1;31mNameError\u001b[0m: name 'calculate_sum' is not defined"
]
}
],
"source": [
"calculate_sum(5, 10)"
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "c0c74cd8",
"metadata": {},
"outputs": [
{
"ename": "TypeError",
"evalue": "can only concatenate str (not \"int\") to str",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[40], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m x \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mHello\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 2\u001b[0m y \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m5\u001b[39m\n\u001b[1;32m----> 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mx\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43m \u001b[49m\u001b[43my\u001b[49m)\n",
"\u001b[1;31mTypeError\u001b[0m: can only concatenate str (not \"int\") to str"
]
}
],
"source": [
"x = \"Hello\"\n",
"y = 5\n",
"print(x + y)"
]
},
{
"cell_type": "code",
"execution_count": 44,
"id": "3315c57c",
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "'dict' object has no attribute 'name'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[44], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m person \u001b[38;5;241m=\u001b[39m {\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAlice\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mage\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;241m30\u001b[39m}\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mperson\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mname\u001b[49m)\n",
"\u001b[1;31mAttributeError\u001b[0m: 'dict' object has no attribute 'name'"
]
}
],
"source": [
"person = {\"name\": \"Alice\", \"age\": 30}\n",
"print(person.name)"
]
},
{
"cell_type": "code",
"execution_count": 42,
"id": "bcd5e7b4",
"metadata": {},
"outputs": [
{
"ename": "ZeroDivisionError",
"evalue": "division by zero",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mZeroDivisionError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[42], line 3\u001b[0m\n\u001b[0;32m 1\u001b[0m x \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m10\u001b[39m\n\u001b[0;32m 2\u001b[0m y \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m\n\u001b[1;32m----> 3\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[43mx\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m/\u001b[39;49m\u001b[43m \u001b[49m\u001b[43my\u001b[49m\n",
"\u001b[1;31mZeroDivisionError\u001b[0m: division by zero"
]
}
],
"source": [
"x = 10\n",
"y = 0\n",
"result = x / y"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "1eb252b2",
"metadata": {},
"outputs": [
{
"ename": "KeyError",
"evalue": "'city'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mKeyError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[1], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m my_dict \u001b[38;5;241m=\u001b[39m {\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mAlice\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mage\u001b[39m\u001b[38;5;124m\"\u001b[39m: \u001b[38;5;241m30\u001b[39m}\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43mmy_dict\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mcity\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m)\n",
"\u001b[1;31mKeyError\u001b[0m: 'city'"
]
}
],
"source": [
"my_dict = {\"name\": \"Alice\", \"age\": 30}\n",
"print(my_dict[\"city\"])"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "b076aeb0",
"metadata": {},
"outputs": [
{
"ename": "ImportError",
"evalue": "cannot import name 'load_adigits' from 'sklearn.datasets' (C:\\Users\\redam\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\datasets\\__init__.py)",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mImportError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[30], line 2\u001b[0m\n\u001b[0;32m 1\u001b[0m \u001b[38;5;66;03m# load Digits Dataset from sklearn\u001b[39;00m\n\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01msklearn\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mdatasets\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m load_adigits\n\u001b[0;32m 3\u001b[0m digits \u001b[38;5;241m=\u001b[39m load_adigits()\n",
"\u001b[1;31mImportError\u001b[0m: cannot import name 'load_adigits' from 'sklearn.datasets' (C:\\Users\\redam\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\sklearn\\datasets\\__init__.py)"
]
}
],
"source": [
"# load Digits Dataset from sklearn\n",
"from sklearn.datasets import load_adigits\n",
"digits = load_adigits()\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bf5758fd",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
31 changes: 2 additions & 29 deletions src/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,34 +66,7 @@ animation.startWaitingAnimation = (activeTextarea) => {
// Add a new <style> element to the <head> element
document.head.appendChild(styleElement);

// get cursor element
const cursorElement = activeTextarea.querySelector('div.CodeMirror-cursor')
const style = window.getComputedStyle(cursorElement);
// Which line
const lineIndex = Math.round(parseFloat(style.getPropertyValue('top')) / 17)
// Obtain element for all line
const linesElement = activeTextarea.getElementsByClassName('CodeMirror-line')
// the code span elements for this active line
const currectLineSpanList = linesElement[lineIndex].querySelectorAll('span span')

// deprecate:Set the animated font dom element when it waits
// As a code hint carrier
const animationElement = document.createElement('span');

animationElement.classList.add("per-insert-code")
animationElement.style.color = 'grey';

// Insert gray code hints, If the active line has no span tag
if (currectLineSpanList.length == 0) {
const withAllCodeSpan = linesElement[lineIndex].querySelectorAll('span')
// creates an element in a unique code carrier, as long as the mouse exists, the code carrier exists
withAllCodeSpan[withAllCodeSpan.length - 1].appendChild(animationElement)
} else {
// Insert new hint code in the last code span
const withAllCodeSpan = linesElement[lineIndex].childNodes
withAllCodeSpan[withAllCodeSpan.length - 1].insertAdjacentElement('afterend', animationElement);
}



// Waiting steps, 0.333 seconds per step
let timeLeft = 90;
Expand All @@ -107,7 +80,7 @@ animation.startWaitingAnimation = (activeTextarea) => {
}

}, 333)
return [animationInterval, animationElement, activeCellParentElement]
return [animationInterval, activeCellParentElement]
}


Expand Down
8 changes: 5 additions & 3 deletions src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const api = {


const cleanUpBigcodeOutput = (suggestion, isLastLine) => {
suggestion = suggestion.replace("# -*- coding: utf-8 -*-\n\n", "")
suggestion = suggestion.replace("# -*- coding: utf-8 -*-\n\n", "").replace(/\t/g, ' ')
let outPutIndex = suggestion.indexOf('<jupyter_output>')

if (outPutIndex != -1){
Expand Down Expand Up @@ -83,8 +83,10 @@ api.sendToBigcode = async (code, url, token, isLastLine) => {
stream: false,
parameters: {
return_full_text: false,
stop: ["<jupyter_output>"]
}
stop: ["<jupyter_output>"],
max_new_tokens: 20
},

}

if (!isLastLine){
Expand Down
Loading