Code Monkey home page Code Monkey logo

chatgpt-helper's Introduction

ChatGPT Helper

This is an extension to quickly query OpenAI's ChatGPT (both GPT-3.5 and GPT-4) from VS Code. A ChatGPT Plus subcription is not required to use this extension.

GPT-3.5, which powers ChatGPT, is a large language model made by OpenAI. The official GPT-3.5 API costs $0.002 / 1K tokens for both prompts and responses, where 1,000 tokens is approximately 750 words, so $1 would buy approximately 375,000 words.

Alternatively, you can opt to use GPT-4, GPT-3.5's successor, which is an even more powerful model. The API is currently invite-only, however you can sign up for the waitlist here. The API is more expensive than GPT-3.5, costing $0.03 / 1K tokens for prompts and $0.06 / 1K tokens for responses, meaning $1 would buy approximately 12,500 words of prompts and 6,250 words of response..

To use this extension, you must provide an OpenAI API token linked to an account with billing set up; costs for using the API are charged directly to your OpenAI account.

Features

Ask why your code's not working

  1. Select the code you want to ask about. If you want to ask about the whole file, do not select any text.
  2. Right click inside the editor and select ChatGPT: Ask why code isn't working.
  3. Wait for the response. It will appear in a new tab.

Ask to explain your code

  1. Select the code you want to ask about. If you want to ask about the whole file, do not select any text.
  2. Right click inside the editor and select ChatGPT: Ask to explain code.
  3. Wait for the response. It will appear in a new tab.

Ask a free-form question

Use the "ChatGPT: Ask a question" command in the Command Palette:

  1. Press Ctrl + Shift + P to open the Command Palette.
  2. Begin typing ChatGPT: Ask a question, and select it when it appears.
  3. Enter the question you'd like to ask.
  4. Wait for the response. It will appear in a new tab.

Authentication

When you first query ChatGPT, you will be prompted to enter an OpenAI API key. This is used by the extension to access the API and is only sent to OpenAI.

To find your OpenAI API key:

  1. Go to https://platform.openai.com/account/api-keys. You will need to log in (or sign up) to your OpenAI account.
  2. Click "Create new secret key", and copy it.
  3. You should then paste it into VS Code when prompted.

You must also have billing set up on your OpenAI account (see Pricing below).

Changing API key

Once your OpenAI API key has been set you can update it using the "ChatGPT: Change OpenAI API key" command in the Command Palette:

  1. Press Ctrl + Shift + P to open the Command Palette.
  2. Begin typing ChatGPT: Change OpenAI API key, and select it when it appears.
  3. Enter your OpenAI API key (see above instructions on how to find).

Pricing

The GPT-3.5 API is charged by OpenAI at $0.002 / 1K tokens, while the GPT-4 API comes at $0.03 / 1K tokens. This is charged directly to your OpenAI account. To use this extension, you must set up billing on your account. Find more info about pricing at https://openai.com/pricing#chat.

Configuration

Switching Between Models

In order to switch the model between GPT-3.5 (default) and GPT-4:

  1. Ctrl + , to open Preferences.
  2. Search for chatgpt-helper.model.
  3. Use the dropdown to switch between GPT-3.5 and GPT-4.

chatgpt-helper's People

Contributors

kiranvshah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

chatgpt-helper's Issues

Asking ChatGPT to explain code returns blank page

I just installed this 4.1.0

Asking a general question seems to work however right clicking code and asking for an explanation returns Querying ChatGPT. This may take some time... and then just a blank page.

The following errors are displayed for the extension host log.

`2023-04-13 12:54:49.579 [error] SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at IncomingMessage. (c:\Users\rmurphy.vscode\extensions\kiranshah.chatgpt-helper-4.1.0\dist\extension.js:1:959)
at IncomingMessage.emit (node:events:526:28)
at Readable.read (node:internal/streams/readable:527:10)
at flow (node:internal/streams/readable:1011:34)
at resume_ (node:internal/streams/readable:992:3)
at process.processTicksAndRejections (node:internal/process/task_queues:83:21)

2023-04-13 12:54:49.580 [error] SyntaxError: Unexpected token h in JSON at position 2
at JSON.parse ()
at IncomingMessage. (c:\Users\rmurphy.vscode\extensions\kiranshah.chatgpt-helper-4.1.0\dist\extension.js:1:959)
at IncomingMessage.emit (node:events:526:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Readable.push (node:internal/streams/readable:228:10)
at HTTPParser.parserOnBody (node:_http_common:141:24)
at TLSSocket.socketOnData (node:_http_client:482:22)
at TLSSocket.emit (node:events:526:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Readable.push (node:internal/streams/readable:228:10)
at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)`

My vscode setup...

Version: 1.77.1 (user setup)
Commit: b7886d7461186a5eac768481578c1d7ca80e2d21
Date: 2023-04-04T23:21:11.906Z
Electron: 19.1.11
Chromium: 102.0.5005.196
Node.js: 16.14.2
V8: 10.2.154.26-electron.0
OS: Windows_NT x64 10.0.19045
Sandboxed: Yes

sponsorship opportunity

Hi @kiranvshah, love the extension you have built. I'd love to talk a little about sponsorship/collaboration opportunities.

What would be the best way to get in touch with you?

Cannot find and use the extension

I installed and enabled the extension, but it doesn't show in the extension sidebar, even the deprecated shows. So now I cannot use the chatgpt helper, even though I tried to reinstall or enable it several times.

image

freeform questions don't return code

    So I tryed now to ask ChatPGT to write a code for me inside VCcode, but the answers return no code, but just normal flat text messages. This is total diffenent than asking ChatGPT for Code on the openAI WebSite. What I am making worng? Thanks

Originally posted by @chreiter in #25 (comment)

Typo in README: 1$ / 0.002$ * 750 = 375K

Just a minor typo in README, but has stricken me when reading.

GPT-3.5, which powers ChatGPT, is a large language model designed to answer general queries. The official GPT-3.5 API costs $0.002 / 1K tokens, where 1,000 tokens is approximately 750 words, so **$1 would buy approximately 2 million words**.

use official chatgpt api

add an option to change the model to use the official chatgpt api. entering of openai api token should remain the same. codex should be kept as an alternative option as a free tier.

openai blog post: https://openai.com/blog/introducing-chatgpt-and-whisper-apis
using openai api to make chat completions: https://platform.openai.com/docs/api-reference/chat
chatgpt api guide: https://platform.openai.com/docs/guides/chat/introduction
gpt-3.5-turbo model should be used as this will receive updates

[error] TypeError: Cannot read properties of undefined (reading '0')

Hi,

I'm using Visual Studio Code 1.80.2 with ChatGPT v4.1.0.

I entered my OpenAI API key and when I select small block of code, ex.:
for (int i = 0; i < (int)str.length() ; i++)
{
if ((str[i] < '0') || (str[i] > '9')) return false;
}

and select
"ChatGPT: Ask to explain code" from Palette

I get new empty window and error at Extension Host Log:

2023-08-10 12:19:02.272 [error] TypeError: Cannot read properties of undefined (reading '0')
at IncomingMessage. (/Users/user/.vscode/extensions/kiranshah.chatgpt-helper-4.1.0/dist/extension.js:1:986)
at IncomingMessage.emit (node:events:513:28)
at IncomingMessage.emit (node:domain:489:12)
at Readable.read (node:internal/streams/readable:527:10)
at flow (node:internal/streams/readable:1011:34)
at resume_ (node:internal/streams/readable:992:3)
at process.processTicksAndRejections (node:internal/process/task_queues:83:21)

add prettier config file

Copied from personal notes:

Prettier (client)

Note
For Prettier to work as intended, ensure you follow the instructions to set up for the whole project.

Installing Prettier on client

In the terminal, in /clients:

npm i -D prettier

Adding Prettier scripts on client

Then, in client/package.json, under scripts, add the following two scripts:

"prettier:check": "prettier --check . --ignore-path ../.prettierignore",
"prettier:write": "prettier --write . --ignore-path ../.prettierignore"

Setting up Prettier config files

.prettierrc.json

Create a new file at root called .prettierrc.json with the following contents (can be amended if you wish):

{
	"tabWidth": 2,
	"useTabs": true,
	"semi": false,
	"singleQuote": false,
	"quoteProps": "as-needed",
	"jsxSingleQuote": false,
	"trailingComma": "all",
	"bracketSpacing": true,
	"jsxBracketSameLine": false,
	"arrowParens": "always",
	"proseWrap": "never",
	"htmlWhitespaceSensitivity": "ignore",
	"endOfLine": "lf",
	"embeddedLanguageFormatting": "auto"
}

[!abstract] Prettier Options

.prettierignore

Create a new file at root called .prettierignore with the following contents:

build
node_modules
package-lock.json

extensions.json

Create a new file at .vscode/extensions.json with the following contents:

{
	"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
}

In the VS Code command palette (Ctrl+Shift+P), run the command Extensions: Show Recommended Extensions, then install both ESLint and Prettier if not already installed

settings.json

Create a new file at .vscode/settings.json with the following contents:

{
	"editor.tabSize": 2,
	"editor.insertSpaces": false,
	"editor.detectIndentation": false,
	"editor.formatOnSave": true,
	"editor.defaultFormatter": "esbenp.prettier-vscode",
	"editor.formatOnPaste": true,
	"editor.formatOnType": true,
	"files.eol": "\n"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.