Skip to content

Commit

Permalink
Added ChatGPT to extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Zhang committed Feb 1, 2023
1 parent d7c0f7a commit d3f53df
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ Scribe AI is a ChatGPT-like extension for VS Code. Now you can have an AI chatbo
<a href="https://marketplace.visualstudio.com/items?itemName=AndrewZhang.scribeai">🔗 VSCode Marketplace</a>
</h4>

&nbsp;

# 📢 v1.1.1 Update: ChatGPT Now Available
You can now choose ChatGPT as the model you want to use by heading to `Code` -> `Preferences` -> `Settings`, find `ScribeAI` under `Extensions` and choose `ChatGPT` as your model.
&nbsp;

The GPT3 models are also now more performant thanks to experimentation with prompt engineering and tuning additional parameters. You can now expect to get longer and more detailed responses.


&nbsp;

# 🌟 Preview
Expand Down Expand Up @@ -122,14 +131,16 @@ To find your OpenAI API key:
&nbsp;

> **Note**
> Temporarily, the extension is using Codex, a similar GPT model by OpenAI, instead of ChatGPT, since the official ChatGPT API is not out yet. We do this because using unofficial ChatGPT API is unsupported by OpenAI and it's not reliable. Our team has figured out a way to simulate ChatGPT using OpenAI's current available GPT models. You can choose between `code-davinci-002` and `text-davinci-003` in the User Settings. When the official ChatGPT API is out our team will immediately offer an option to choose the ChatGPT model.
> Temporarily, the extension is using Codex, a similar GPT model by OpenAI, instead of ChatGPT, since the official ChatGPT API is not out yet. We do this because using unofficial ChatGPT API is unsupported by OpenAI and it's not reliable. Our team has figured out a way to simulate ChatGPT using OpenAI's current available GPT models. You can choose between `code-davinci-002` and `text-davinci-003` in the User Settings. When the official ChatGPT API is out our team will immediately offer an option to choose the ChatGPT model.
> UPDATE: ChatGPT API is now out and we've added it to our extension. You can now find it in the settings to start using it!
&nbsp;

# ❤️ Support and Gratitude
- This wouldn't have been possible without OpenAI's API to access its AI services.
- I want to thank the wonderful VS Code community and all the developers that maintain VS Code.
- If you like this extension and found it useful, please consider donating me as I am only a new grad developer and any amount of donation will be of tremendous help and encourage me to keep going.
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/C0C0I5XTZ)

- <a target="_blank" href="https://icons8.com/icon/uZrQP6cYos2I/chatbot">Chatbot icon by Icons8</a>

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "scribeai",
"displayName": "ScribeAI - ChatGPT like extension for VSCode",
"description": "🚀 Use ChatGPT like AI chatbot right inside VSCode to enhance and automate your coding with AI-powered assistance",
"version": "1.1.0",
"displayName": "ScribeAI - ChatGPT & GPT extension for VSCode",
"description": "🚀 Use ChatGPT & GPT right inside VSCode to enhance and automate your coding with AI-powered assistance",
"version": "1.1.1",
"publisher": "AndrewZhang",
"private": true,
"icon": "resources/chatbot.png",
Expand Down Expand Up @@ -212,11 +212,13 @@
"default": "code-davinci-002",
"enum": [
"code-davinci-002",
"text-davinci-003"
"text-davinci-003",
"ChatGPT"
],
"enumDescriptions": [
"The Codex models are descendants of GPT-3 models that can understand and generate code.",
"GPT-3 models can understand and generate natural language."
"GPT-3 models can understand and generate natural language.",
"Large language model trained by OpenAI that is optimized for dialogue."
],
"markdownDescription": "Choose the OpenAI model you want to use for generating your AI responses.\n\nYou can find more details about each model and their pricing [here](https://beta.openai.com/docs/models)."
}
Expand Down
7 changes: 4 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export async function activate(context: vscode.ExtensionContext) {
*/
function generatePromptV2(question: string, thread: vscode.CommentThread) {
const rolePlay =
"I want you to act as a highly intelligent AI chatbot that has deep understanding of any coding language and its API documentations. I will provide you with a code block and your role is to provide a comprehensive answer to any questions or requests that I will ask about the code block.";
"I want you to act as a highly intelligent AI chatbot that has deep understanding of any coding language and its API documentations. I will provide you with a code block and your role is to provide a comprehensive answer to any questions or requests that I will ask about the code block. Please answer in as much detail as possible and not be limited to brevity. It is very important that you provide verbose answers.";
//const codeBlock = "class Log:\n def __init__(self, path):\n dirname = os.path.dirname(path)\n os.makedirs(dirname, exist_ok=True)\n f = open(path, \"a+\")\n\n # Check that the file is newline-terminated\n size = os.path.getsize(path)\n if size > 0:\n f.seek(size - 1)\n end = f.read(1)\n if end != \"\\n\":\n f.write(\"\\n\")\n self.f = f\n self.path = path\n\n def log(self, event):\n event[\"_event_id\"] = str(uuid.uuid4())\n json.dump(event, self.f)\n self.f.write(\"\\n\")\n\n def state(self):\n state = {\"complete\": set(), \"last\": None}\n for line in open(self.path):\n event = json.loads(line)\n if event[\"type\"] == \"submit\" and event[\"success\"]:\n state[\"complete\"].add(event[\"id\"])\n state[\"last\"] = event\n return state";
const codeBlock = getCommentThreadCode(thread);

Expand Down Expand Up @@ -286,6 +286,7 @@ export async function activate(context: vscode.ExtensionContext) {
const code = getCommentThreadCode(reply.thread);
const thread = reply.thread;
const prompt = generatePromptV1(question, thread);
const model = vscode.workspace.getConfiguration('scribeai').get('models') + "";
const humanComment = new NoteComment(question, vscode.CommentMode.Preview, { name: 'VS Code', iconPath: vscode.Uri.parse("https://img.icons8.com/fluency/96/null/user-male-circle.png") }, thread, thread.comments.length ? 'canDelete' : undefined);
thread.comments = [...thread.comments, humanComment];

Expand All @@ -302,7 +303,7 @@ export async function activate(context: vscode.ExtensionContext) {
}

const response = await openai.createCompletion({
model: vscode.workspace.getConfiguration('scribeai').get('models') + "",
model: model === "ChatGPT" ? "text-chat-davinci-002-20230126" : model,
prompt: prompt,
//prompt: generatePromptV2(question, thread),
temperature: 0,
Expand All @@ -314,7 +315,7 @@ export async function activate(context: vscode.ExtensionContext) {
});

const responseText = response.data.choices[0].text ? response.data.choices[0].text : 'An error occured. Please try again...';
const AIComment = new NoteComment(responseText.trim(), vscode.CommentMode.Preview, { name: 'Scribe AI', iconPath: vscode.Uri.parse("https://img.icons8.com/fluency/96/null/chatbot.png") }, thread, thread.comments.length ? 'canDelete' : undefined);
const AIComment = new NoteComment(responseText.trim().replace("<|im_end|>", ""), vscode.CommentMode.Preview, { name: 'Scribe AI', iconPath: vscode.Uri.parse("https://img.icons8.com/fluency/96/null/chatbot.png") }, thread, thread.comments.length ? 'canDelete' : undefined);
thread.comments = [...thread.comments, AIComment];
}

Expand Down

0 comments on commit d3f53df

Please sign in to comment.