Skip to content

Commit

Permalink
add write documentation shortcut, unreset vscode css
Browse files Browse the repository at this point in the history
  • Loading branch information
timkmecl committed Jan 3, 2023
1 parent 9dde3e9 commit ff4dbaa
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 10 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This Visual Studio Code extension allows you to use the [unofficial ChatGPT API]

<br>

**💥Make sure to follow the installation instructions carefully! Due to changes introduced by OpenAI, this extension may not work for some and only produce 403 errors - version using official GPT-3 API coming soon💥**
**💥Make sure to follow the installation instructions carefully! Due to changes introduced by OpenAI, this extension may not work for some and only produce 403/429 errors - try [version using GPT3](https://github.com/timkmecl/codegpt) via official OpenAI API in this case ([marketplace](https://marketplace.visualstudio.com/items?itemName=timkmecl.codegpt3)) 💥**

<br>

Expand All @@ -25,6 +25,10 @@ This Visual Studio Code extension allows you to use the [unofficial ChatGPT API]
## Features
- 💡 **Ask general questions** or use code snippets from the editor to query ChatGPT via an input box in the sidebar
- 🖱️ Right click on a code selection and run one of the context menu **shortcuts**
- automatically write documentation for your code
- explain the selected code
- refactor or optimize it
- find problems with it
- 💻 View ChatGPT's responses in a panel next to the editor
- 🚀 See the response as it is being generated **in real time**
- 💬 Ask **follow-up questions** to the response (conversation context is maintained)
Expand Down
35 changes: 28 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"onCommand:chatgpt.explain",
"onCommand:chatgpt.refactor",
"onCommand:chatgpt.optimize",
"onCommand:chatgpt.problems"
"onCommand:chatgpt.findProblems",
"onCommand:chatgpt.documentation"
],
"main": "./dist/extension.js",
"contributes": {
Expand All @@ -57,6 +58,10 @@
"command": "chatgpt.optimize",
"title": "ChatGPT: Optimize selection"
},
{
"command": "chatgpt.documentation",
"title": "ChatGPT: Write documentation"
},
{
"command": "chatgpt.conversationId",
"title": "Set ChatGPT conversation ID"
Expand Down Expand Up @@ -92,6 +97,11 @@
"command": "chatgpt.optimize",
"when": "editorHasSelection",
"group": "chatgpt-menu-group@5"
},
{
"command": "chatgpt.documentation",
"when": "editorHasSelection",
"group": "chatgpt-menu-group@6"
}
],
"commandPalette": [
Expand All @@ -114,6 +124,10 @@
"command": "chatgpt.optimize",
"when": "editorHasSelection"
},
{
"command": "chatgpt.documentation",
"when": "editorHasSelection"
},
{
"command": "chatgpt.conversationId"
},
Expand Down Expand Up @@ -179,32 +193,39 @@
},
"chatgpt.promptPrefix.findProblems": {
"type": "string",
"default": "Find problems with the following code, fix them and explain what was wrong (Do not change anything else): ",
"default": "Find problems with the following code, fix them and explain what was wrong (Do not change anything else, if there are no problems say so): ",
"description": "The prompt prefix used for finding problems in the selected code",
"order": 5
},
"chatgpt.promptPrefix.documentation": {
"type": "string",
"default": "Write documentation for the following code: ",
"description": "The prompt prefix used for writing documentation for the selected code",
"order": 7
},
"chatgpt.promptPrefix.optimize": {
"type": "string",
"default": "Optimize the following code: ",
"default": "Optimize the following code if there is anything to improve, if not say so: ",
"description": "The prompt prefix used for optimizing the selected code",
"order": 6
},
"chatgpt.keepConversation": {
"type": "boolean",
"default": true,
"description": "Keep the conversation going by using the same conversation ID for all requests (allows follow-up questions)",
"order": 7
},"chatgpt.timeoutLength": {
"order": 8
},
"chatgpt.timeoutLength": {
"type": "number",
"default": "120",
"description": "How long should the request wait for a response before timing out (in seconds)",
"order": 8
"order": 9
},
"chatgpt.selectedInsideCodeblock": {
"type": "boolean",
"default": true,
"description": "Append selected code as a codeblock (```...code...```) instead of plain text",
"order": 9
"order": 10
}
}
}
Expand Down
13 changes: 11 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export function activate(context: vscode.ExtensionContext) {
vscode.commands.registerCommand('chatgpt.refactor', () => commandHandler('promptPrefix.refactor')),
vscode.commands.registerCommand('chatgpt.optimize', () => commandHandler('promptPrefix.optimize')),
vscode.commands.registerCommand('chatgpt.findProblems', () => commandHandler('promptPrefix.findProblems')),
vscode.commands.registerCommand('chatgpt.documentation', () => commandHandler('promptPrefix.documentation')),
vscode.commands.registerCommand('chatgpt.resetConversation', provider.resetConversation),
vscode.commands.registerCommand('chatgpt.conversationId', setConversationId)
);
Expand Down Expand Up @@ -334,8 +335,16 @@ class ChatGPTViewProvider implements vscode.WebviewViewProvider {
white-space: pre;
}
p {
padding-top: 0.25rem;
padding-bottom: 0.25rem;
padding-top: 0.3rem;
padding-bottom: 0.3rem;
}
/* overrides vscodes style reset, displays as if inside web browser */
ul, ol {
list-style: initial !important;
margin-left: 10px !important;
}
h1, h2, h3, h4, h5, h6 {
font-weight: bold !important;
}
</style>
</head>
Expand Down

0 comments on commit ff4dbaa

Please sign in to comment.