Skip to content
This repository was archived by the owner on Sep 28, 2023. It is now read-only.

Commit 57daa17

Browse files
committed
V0.4.0 improvements + added code review
1 parent f5193c9 commit 57daa17

File tree

10 files changed

+190
-119
lines changed

10 files changed

+190
-119
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ Primary functions, have ChatGPT:
88
- **Explain** - Explain the content of your code cell, ELI5 style.
99
- **Debug** - Help you debug an error message in your code cell.
1010
- **Complete** - Help you complete a code snippet in your code cell.
11-
- **Fun** - Provide a fun or helpful fact about your code cell.
11+
- **Review** - Provide a code review of your code cell.
1212

13-
**Project status:** Beta - Bugs likely - If you run into issues or have feature suggestions --> Submit them as an issue!
13+
**Project status:** Stable - but ChatGPT changes frequently - if you run into problems or have feature suggestions --> Submit them as an issue!
1414

1515
**Major acknowledgements:**
1616

@@ -85,7 +85,5 @@ Please report any issues or feature requests on the GitHub Issue tab. I will try
8585
- [x] Add Jupyter Lab support
8686
- [x] Refactor prompt engineering
8787
- [x] Add copy-paste functionality and/or auto-adding
88-
- [ ] Add Google Colab support
89-
- [ ] Add shortcuts
9088
- [ ] Add interupt button
9189
- [ ] Add integration tests

package-lock.json

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"expiry-map": "^2.0.0",
1616
"github-markdown-css": "^5.1.0",
1717
"lodash-es": "^4.17.21",
18+
"marked": "^4.2.12",
1819
"preact": "^10.11.3",
1920
"prop-types": "^15.8.1",
2021
"punycode": "^2.1.1",
@@ -26,6 +27,7 @@
2627
},
2728
"devDependencies": {
2829
"@types/lodash-es": "^4.17.6",
30+
"@types/marked": "^4.0.8",
2931
"@types/uuid": "^9.0.0",
3032
"@types/webextension-polyfill": "^0.9.2",
3133
"@typescript-eslint/eslint-plugin": "^5.47.0",

src/content-script/ChatGPTQuery.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { Answer } from '../messaging'
77
import ChatGPTFeedback from './ChatGPTFeedback'
88
import './highlight.scss'
99
import { promptSettings } from './prompt-configs.js'
10+
import { marked } from 'marked';
11+
1012

1113
interface Props {
1214
question: string,
@@ -67,12 +69,18 @@ function ChatGPTQuery(props: Props) {
6769
}
6870
}, [error])
6971

72+
const showPrompt = (event: React.MouseEvent<HTMLAnchorElement>) => {
73+
event.preventDefault();
74+
const html = marked(props.question);
75+
window.open('', '_blank')?.document.write(html);
76+
};
77+
7078
if (answer) {
7179
const prompt = promptSettings[props.type]
7280
return (
7381
<div id="answer" className="markdown-body gpt-inner" dir="auto">
7482
<div className="gpt-header">
75-
<p>{prompt.title}</p>
83+
<p>{prompt.title} (<a href = "#" onClick={showPrompt}>see prompt</a>)</p>
7684
<ChatGPTFeedback messageId={answer.messageId} conversationId={answer.conversationId} siteName={props.siteName}/>
7785
</div>
7886
<ReactMarkdown rehypePlugins={[[rehypeHighlight, { detect: true }]]}>

src/content-script/ChatGPTQueryBuilder.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function BuildQuery(type : string, siteName : string) : string {
147147
} else if (type == "debug") {
148148
query = promptTemplates["debug"](prev_cell_text, code, stderr_text)
149149
} else {
150-
query = promptTemplates["fun"](prev_cell_text, code)
150+
query = promptTemplates["review"](prev_cell_text, code)
151151
}
152152

153153
//console.log(query)

src/content-script/Interface.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function Button(props: Props) {
1212
const isNotebook = props.siteName == "notebook"
1313
return (
1414
<button className="btn btn-default btn-xs chat-gpt-button" onClick={props.onClick } disabled={props.disabled} style= {{marginTop: isNotebook ? '-0.5px' : '4px' }} title={props.name} >
15-
<props.icon size='small' className="icon" /> {isNotebook && props.name}
15+
<props.icon size='small' className="icon" />
1616
</button>
1717
)
1818

src/content-script/prompt-configs.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
Icon,
33
ProjectRoadmapIcon,
44
BugIcon,
5-
GiftIcon,
5+
CodeReviewIcon,
66
CommandPaletteIcon,
77
PaintbrushIcon,
88
} from '@primer/octicons-react'
@@ -41,10 +41,10 @@ export const promptSettings: Record<string, PromptSettings> = {
4141
maxCharPrevCells: 1250,
4242

4343
},
44-
fun : {
45-
buttonLabel : "Fun",
46-
buttonIcon : GiftIcon,
47-
title : "ChatGPT - Fun",
48-
maxCharPrevCells: 500,
44+
review : {
45+
buttonLabel : "Review",
46+
buttonIcon : CodeReviewIcon,
47+
title : "ChatGPT - Code Review",
48+
maxCharPrevCells: 1250,
4949
}
5050
}

0 commit comments

Comments
 (0)