From d3f53df9671a37378a6c1f228789a51b19fd49bb Mon Sep 17 00:00:00 2001 From: Andrew Zhang Date: Tue, 31 Jan 2023 17:53:27 -0800 Subject: [PATCH] Added ChatGPT to extension --- README.md | 13 ++++++++++++- package-lock.json | 2 +- package.json | 12 +++++++----- src/extension.ts | 7 ++++--- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f7bbd09..8f2fd9d 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,15 @@ Scribe AI is a ChatGPT-like extension for VS Code. Now you can have an AI chatbo 🔗 VSCode Marketplace +  + +# 📢 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. +  + +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. + +   # 🌟 Preview @@ -122,7 +131,8 @@ To find your OpenAI API key:   > **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!   @@ -130,6 +140,7 @@ To find your OpenAI API key: - 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) - Chatbot icon by Icons8 diff --git a/package-lock.json b/package-lock.json index 97d7f20..87ffe5f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "scribeai", - "version": "1.1.0", + "version": "1.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 07d2c6e..859d565 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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)." } diff --git a/src/extension.ts b/src/extension.ts index e12ed38..d69b324 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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); @@ -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]; @@ -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, @@ -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]; }