├── .eslintrc.json ├── .gitignore ├── .node-version ├── .npmrc ├── .vscode ├── extensions.json ├── launch.json ├── settings.json └── tasks.json ├── .vscodeignore ├── LICENSE ├── README.md ├── README_EN.md ├── assets ├── logo.png ├── logo.svg └── readme │ ├── docs_assistants.png │ ├── docs_chat.png │ ├── docs_completion.png │ └── docs_settings_new.png ├── l10n └── bundle.l10n.zh-cn.json ├── media ├── main.js ├── scripts │ ├── highlight.min.js │ ├── showdown.min.js │ └── tailwind.min.js └── styles │ ├── styles.771a66d94c0526be.css │ ├── styles.c100.css │ ├── styles.c101.css │ ├── styles.c110.css │ ├── styles.c111.css │ ├── styles.c116.css │ ├── styles.c117.css │ └── styles.c48.css ├── package.json ├── package.nls.json ├── package.nls.zh-cn.json ├── src ├── ChatMemory.ts ├── CodeShellCompletionProvider.ts ├── CodeShellWebviewViewProvider.ts ├── CreatePrompt.ts ├── Utils.ts ├── consts.ts ├── extension.ts ├── request │ ├── commons.ts │ ├── event-source.ts │ ├── fetch-stream.ts │ └── inline-completion.ts └── test │ ├── runTest.ts │ └── suite │ ├── extension.test.ts │ └── index.ts ├── tsconfig.json ├── wasm ├── tree-sitter-c.wasm ├── tree-sitter-c_sharp.wasm ├── tree-sitter-cpp.wasm ├── tree-sitter-dart.wasm ├── tree-sitter-go.wasm ├── tree-sitter-java.wasm ├── tree-sitter-javascript.wasm ├── tree-sitter-php.wasm ├── tree-sitter-python.wasm ├── tree-sitter-ruby.wasm ├── tree-sitter-rust.wasm ├── tree-sitter-tsx.wasm ├── tree-sitter-typescript.wasm └── tree-sitter.wasm └── webpack.config.js /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "parserOptions": { 5 | "ecmaVersion": 6, 6 | "sourceType": "module" 7 | }, 8 | "plugins": [ 9 | "@typescript-eslint" 10 | ], 11 | "rules": { 12 | "@typescript-eslint/naming-convention": "warn", 13 | "@typescript-eslint/semi": "warn", 14 | "curly": "warn", 15 | "eqeqeq": "warn", 16 | "no-throw-literal": "warn", 17 | "semi": "off" 18 | }, 19 | "ignorePatterns": [ 20 | "out", 21 | "dist", 22 | "**/*.d.ts" 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | dist 3 | node_modules 4 | .vscode-test/ 5 | *.vsix 6 | .DS_Store 7 | .idea/ 8 | package-lock.json 9 | -------------------------------------------------------------------------------- /.node-version: -------------------------------------------------------------------------------- 1 | v18.16.1 -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | registry=https://registry.npmmirror.com -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | // See http://go.microsoft.com/fwlink/?LinkId=827846 3 | // for the documentation about the extensions.json format 4 | "recommendations": ["dbaeumer.vscode-eslint", "amodio.tsl-problem-matcher"] 5 | } 6 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that compiles the extension and then opens it inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Run Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "args": [ 13 | "--extensionDevelopmentPath=${workspaceFolder}" 14 | ], 15 | "outFiles": [ 16 | "${workspaceFolder}/dist/**/*.js" 17 | ], 18 | "preLaunchTask": "${defaultBuildTask}" 19 | }, 20 | { 21 | "name": "Extension Tests", 22 | "type": "extensionHost", 23 | "request": "launch", 24 | "args": [ 25 | "--extensionDevelopmentPath=${workspaceFolder}", 26 | "--extensionTestsPath=${workspaceFolder}/out/test/suite/index" 27 | ], 28 | "outFiles": [ 29 | "${workspaceFolder}/out/**/*.js", 30 | "${workspaceFolder}/dist/**/*.js" 31 | ], 32 | "preLaunchTask": "tasks: watch-tests" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | "files.exclude": { 4 | "out": false, // set this to true to hide the "out" folder with the compiled JS files 5 | "dist": false // set this to true to hide the "dist" folder with the compiled JS files 6 | }, 7 | "search.exclude": { 8 | "out": true, // set this to false to include "out" folder in search results 9 | "dist": true // set this to false to include "dist" folder in search results 10 | }, 11 | // Turn off tsc task auto detection since we have the necessary tasks as npm scripts 12 | "typescript.tsc.autoDetect": "off" 13 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // See https://go.microsoft.com/fwlink/?LinkId=733558 2 | // for the documentation about the tasks.json format 3 | { 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "type": "npm", 8 | "script": "watch", 9 | "problemMatcher": "$ts-webpack-watch", 10 | "isBackground": true, 11 | "presentation": { 12 | "reveal": "never", 13 | "group": "watchers" 14 | }, 15 | "group": { 16 | "kind": "build", 17 | "isDefault": true 18 | } 19 | }, 20 | { 21 | "type": "npm", 22 | "script": "watch-tests", 23 | "problemMatcher": "$tsc-watch", 24 | "isBackground": true, 25 | "presentation": { 26 | "reveal": "never", 27 | "group": "watchers" 28 | }, 29 | "group": "build" 30 | }, 31 | { 32 | "label": "tasks: watch-tests", 33 | "dependsOn": [ 34 | "npm: watch", 35 | "npm: watch-tests" 36 | ], 37 | "problemMatcher": [] 38 | } 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | out/** 4 | node_modules/** 5 | src/** 6 | .gitignore 7 | .yarnrc 8 | webpack.config.js 9 | vsc-extension-quickstart.md 10 | **/tsconfig.json 11 | **/.eslintrc.json 12 | **/*.map 13 | **/*.ts 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CodeShell VSCode Extension 2 | 3 | [](README_EN.md) 4 | 5 | `codeshell-vscode`项目是基于[CodeShell大模型](https://github.com/WisdomShell/codeshell)开发的支持[Visual Studio Code](https://code.visualstudio.com/Download)的智能编码助手插件,支持python、java、c++/c、javascript、go等多种编程语言,为开发者提供代码补全、代码解释、代码优化、注释生成、对话问答等功能,旨在通过智能化的方式帮助开发者提高编程效率。 6 | 7 | ## 环境要求 8 | 9 | - [node](https://nodejs.org/en)版本v18及以上 10 | - Visual Studio Code版本要求 1.68.1 及以上 11 | - [CodeShell 模型服务](https://github.com/WisdomShell/llama_cpp_for_codeshell)已启动 12 | 13 | ## 编译插件 14 | 15 | 如果要从源码进行打包,需要安装 `node` v18 以上版本,并执行以下命令: 16 | 17 | ```zsh 18 | git clone https://github.com/WisdomShell/codeshell-vscode.git 19 | cd codeshell-vscode 20 | npm install 21 | npm exec vsce package 22 | ``` 23 | 24 | 然后会得到一个名为`codeshell-vscode-${VERSION_NAME}.vsix`的文件。 25 | 26 | ## 模型服务 27 | 28 | [`llama_cpp_for_codeshell`](https://github.com/WisdomShell/llama_cpp_for_codeshell)项目提供[CodeShell大模型](https://github.com/WisdomShell/codeshell) 4bits量化后的模型,模型名称为`codeshell-chat-q4_0.gguf`。以下为部署模型服务步骤: 29 | 30 | ### 编译代码 31 | 32 | + Linux / Mac(Apple Silicon设备) 33 | 34 | ```bash 35 | git clone https://github.com/WisdomShell/llama_cpp_for_codeshell.git 36 | cd llama_cpp_for_codeshell 37 | make 38 | ``` 39 | 40 | 在 macOS 上,默认情况下启用了Metal,启用Metal可以将模型加载到 GPU 上运行,从而显著提升性能。 41 | 42 | + Mac(非Apple Silicon设备) 43 | 44 | ```bash 45 | git clone https://github.com/WisdomShell/llama_cpp_for_codeshell.git 46 | cd llama_cpp_for_codeshell 47 | LLAMA_NO_METAL=1 make 48 | ``` 49 | 50 | 对于非 Apple Silicon 芯片的 Mac 用户,在编译时可以使用 `LLAMA_NO_METAL=1` 或 `LLAMA_METAL=OFF` 的 CMake 选项来禁用Metal构建,从而使模型正常运行。 51 | 52 | + Windows 53 | 54 | 您可以选择在[Windows Subsystem for Linux](https://learn.microsoft.com/en-us/windows/wsl/about)中按照Linux的方法编译代码,也可以选择参考[llama.cpp仓库](https://github.com/ggerganov/llama.cpp#build)中的方法,配置好[w64devkit](https://github.com/skeeto/w64devkit/releases)后再按照Linux的方法编译。 55 | 56 | ### 下载模型 57 | 58 | 在[Hugging Face Hub](https://huggingface.co/WisdomShell)上,我们提供了三种不同的模型,分别是[CodeShell-7B](https://huggingface.co/WisdomShell/CodeShell-7B)、[CodeShell-7B-Chat](https://huggingface.co/WisdomShell/CodeShell-7B-Chat)和[CodeShell-7B-Chat-int4](https://huggingface.co/WisdomShell/CodeShell-7B-Chat-int4)。以下是下载模型的步骤。 59 | 60 | - 使用[CodeShell-7B-Chat-int4](https://huggingface.co/WisdomShell/CodeShell-7B-Chat-int4)模型推理,将模型下载到本地后并放置在以上代码中的 `llama_cpp_for_codeshell/models` 文件夹的路径 61 | 62 | ``` 63 | git clone https://huggingface.co/WisdomShell/CodeShell-7B-Chat-int4/blob/main/codeshell-chat-q4_0.gguf 64 | ``` 65 | 66 | - 使用[CodeShell-7B](https://huggingface.co/WisdomShell/CodeShell-7B)、[CodeShell-7B-Chat](https://huggingface.co/WisdomShell/CodeShell-7B-Chat)推理,将模型放置在本地文件夹后,使用[TGI](https://github.com/WisdomShell/text-generation-inference.git)加载本地模型,启动模型服务 67 | 68 | ```bash 69 | git clone https://huggingface.co/WisdomShell/CodeShell-7B-Chat 70 | git clone https://huggingface.co/WisdomShell/CodeShell-7B 71 | ``` 72 | 73 | ### 加载模型 74 | 75 | - `CodeShell-7B-Chat-int4`模型使用`llama_cpp_for_codeshell`项目中的`server`命令即可提供API服务 76 | 77 | ```bash 78 | ./server -m ./models/codeshell-chat-q4_0.gguf --host 127.0.0.1 --port 8080 79 | ``` 80 | 81 | 注意:对于编译时启用了 Metal 的情况下,若运行时出现异常,您也可以在命令行添加参数 `-ngl 0 `显式地禁用Metal GPU推理,从而使模型正常运行。 82 | 83 | - [CodeShell-7B](https://huggingface.co/WisdomShell/CodeShell-7B)和[CodeShell-7B-Chat](https://huggingface.co/WisdomShell/CodeShell-7B-Chat)模型,使用[TGI](https://github.com/WisdomShell/text-generation-inference.git)加载本地模型,启动模型服务 84 | 85 | ## 模型服务[NVIDIA GPU] 86 | 87 | 对于希望使用NVIDIA GPU进行推理的用户,可以使用[`text-generation-inference`](https://github.com/huggingface/text-generation-inference)项目部署[CodeShell大模型](https://github.com/WisdomShell/codeshell)。以下为部署模型服务步骤: 88 | 89 | ### 下载模型 90 | 91 | 在 [Hugging Face Hub](https://huggingface.co/WisdomShell/CodeShell-7B-Chat)将模型下载到本地后,将模型放置在 `$HOME/models` 文件夹的路径下,即可从本地加载模型。 92 | 93 | ```bash 94 | git clone https://huggingface.co/WisdomShell/CodeShell-7B-Chat 95 | ``` 96 | 97 | ### 部署模型 98 | 99 | 使用以下命令即可用text-generation-inference进行GPU加速推理部署: 100 | 101 | ```bash 102 | docker run --gpus 'all' --shm-size 1g -p 9090:80 -v $HOME/models:/data \ 103 | --env LOG_LEVEL="info,text_generation_router=debug" \ 104 | ghcr.nju.edu.cn/huggingface/text-generation-inference:1.0.3 \ 105 | --model-id /data/CodeShell-7B-Chat --num-shard 1 \ 106 | --max-total-tokens 5000 --max-input-length 4096 \ 107 | --max-stop-sequences 12 --trust-remote-code 108 | ``` 109 | 110 | 更详细的参数说明请参考[text-generation-inference项目文档](https://github.com/huggingface/text-generation-inference)。 111 | 112 | 113 | ## 配置插件 114 | 115 | VSCode中执行`Install from VSIX...`命令,选择`codeshell-vscode-${VERSION_NAME}.vsix`,完成插件安装。 116 | 117 | - 设置CodeShell大模型服务地址 118 | - 配置是否自动触发代码补全建议 119 | - 配置自动触发代码补全建议的时间延迟 120 | - 配置补全的最大tokens数量 121 | - 配置问答的最大tokens数量 122 | - 配置模型运行环境 123 | 124 | 注意:不同的模型运行环境可以在插件中进行配置。对于[CodeShell-7B-Chat-int4](https://huggingface.co/WisdomShell/CodeShell-7B-Chat-int4)模型,您可以在`Code Shell: Run Env For LLMs`选项中选择`CPU with llama.cpp`选项。而对于[CodeShell-7B](https://huggingface.co/WisdomShell/CodeShell-7B)和[CodeShell-7B-Chat](https://huggingface.co/WisdomShell/CodeShell-7B-Chat)模型,应选择`GPU with TGI toolkit`选项。 125 | 126 |  127 | 128 | ## 功能特性 129 | 130 | ### 1. 代码补全 131 | 132 | - 自动触发代码建议 133 | - 热键触发代码建议 134 | 135 | 在编码过程中,当停止输入时,代码补全建议可自动触发(在配置选项`Auto Completion Delay`中可设置为1~3秒),或者您也可以主动触发代码补全建议,使用快捷键`Alt+\`(对于`Windows`电脑)或`option+\`(对于`Mac`电脑)。 136 | 137 | 当插件提供代码建议时,建议内容以灰色显示在编辑器光标位置,您可以按下Tab键来接受该建议,或者继续输入以忽略该建议。 138 | 139 |  140 | 141 | ### 2. 代码辅助 142 | 143 | - 对一段代码进行解释/优化/清理 144 | - 为一段代码生成注释/单元测试 145 | - 检查一段代码是否存在性能/安全性问题 146 | 147 | 在vscode侧边栏中打开插件问答界面,在编辑器中选中一段代码,在鼠标右键CodeShell菜单中选择对应的功能项,插件将在问答界面中给出相应的答复。 148 | 149 |  150 | 151 | ### 3. 智能问答 152 | 153 | - 支持多轮对话 154 | - 支持会话历史 155 | - 基于历史会话(做为上文)进行多轮对话 156 | - 可编辑问题,重新提问 157 | - 对任一问题,可重新获取回答 158 | - 在回答过程中,可以打断 159 | 160 |  161 | 162 | 在问答界面的代码块中,可以点击复制按钮复制该代码块,也可点击插入按钮将该代码块内容插入到编辑器光标处。 163 | 164 | ## 开源协议 165 | 166 | Apache 2.0 167 | 168 | ## Star History 169 | 170 | [](https://star-history.com/#WisdomShell/codeshell-vscode&Date) -------------------------------------------------------------------------------- /README_EN.md: -------------------------------------------------------------------------------- 1 | # CodeShell VSCode Extension 2 | 3 | [](README.md) 4 | 5 | The `codeshell-vscode` project is an open-source plugin developed based on the [CodeShell LLM](https://github.com/WisdomShell/codeshell) that supports [Visual Studio Code](https://code.visualstudio.com/Download). It serves as an intelligent coding assistant, offering support for various programming languages such as Python, Java, C/C++, JavaScript, Go, and more. This plugin provides features like code completion, code interpretation, code optimization, comment generation, and conversational Q&A to help developers enhance their coding efficiency in an intelligent manner. 6 | 7 | ## Requirements 8 | 9 | - [node](https://nodejs.org/en) version v18 and above 10 | - Visual Studio Code version 1.68.1 and above 11 | - The [CodeShell](https://github.com/WisdomShell/llama_cpp_for_codeshell) service is running 12 | 13 | ## Compile the Plugin 14 | 15 | If you want to run the package from source code, you need to execute the following command: 16 | 17 | ```zsh 18 | git clone https://github.com/WisdomShell/codeshell-vscode.git 19 | cd codeshell-vscode 20 | npm install 21 | npm exec vsce package 22 | ``` 23 | 24 | and it will create a visx package file like: `codeshell-vscode-${VERSION_NAME}.vsix`。 25 | 26 | ## Model Service 27 | 28 | The [`llama_cpp_for_codeshell`](https://github.com/WisdomShell/llama_cpp_for_codeshell) project provides the 4-bit quantized model service of the [CodeShell](https://github.com/WisdomShell/codeshell) LLM, named `codeshell-chat-q4_0.gguf`. Here are the steps to deploy the model service: 29 | 30 | ### Compile the code 31 | 32 | + Linux / Mac(Apple Silicon Devices) 33 | 34 | ```bash 35 | git clone https://github.com/WisdomShell/llama_cpp_for_codeshell.git 36 | cd llama_cpp_for_codeshell 37 | make 38 | ``` 39 | 40 | On macOS, Metal is enabled by default, which allows loading the model onto the GPU for significant performance improvements. 41 | 42 | + Mac(Non Apple Silicon Devices) 43 | 44 | ```bash 45 | git clone https://github.com/WisdomShell/llama_cpp_for_codeshell.git 46 | cd llama_cpp_for_codeshell 47 | LLAMA_NO_METAL=1 make 48 | ``` 49 | 50 | For Mac users with non-Apple Silicon chips, you can disable Metal builds during compilation using the CMake options `LLAMA_NO_METAL=1` or `LLAMA_METAL=OFF` to ensure the model runs properly. 51 | 52 | + Windows 53 | 54 | You have the option to compile the code using the Linux approach within the [Windows Subsystem for Linux](https://learn.microsoft.com/en-us/windows/wsl/about) or you can follow the instructions provided in the [llama.cpp repository](https://github.com/ggerganov/llama.cpp#build). Another option is to configure [w64devkit](https://github.com/skeeto/w64devkit/releases) and then proceed with the Linux compilation method. 55 | 56 | 57 | ### Download the model 58 | 59 | On the [Hugging Face Hub](https://huggingface.co/WisdomShell), we provide three different models: [CodeShell-7B](https://huggingface.co/WisdomShell/CodeShell-7B), [CodeShell-7B-Chat](https://huggingface.co/WisdomShell/CodeShell-7B-Chat), and [CodeShell-7B-Chat-int4](https://huggingface.co/WisdomShell/CodeShell-7B-Chat-int4). Below are the steps to download these models. 60 | 61 | - To perform inference using the [CodeShell-7B-Chat-int4](https://huggingface.co/WisdomShell/CodeShell-7B-Chat-int4) model, download the model to your local machine and place it in the path of the `llama_cpp_for_codeshell/models` folder as indicated in the code above. 62 | 63 | ``` 64 | git clone https://huggingface.co/WisdomShell/CodeShell-7B-Chat-int4/blob/main/codeshell-chat-q4_0.gguf 65 | ``` 66 | 67 | - For performing inference using [CodeShell-7B](https://huggingface.co/WisdomShell/CodeShell-7B) and [CodeShell-7B-Chat](https://huggingface.co/WisdomShell/CodeShell-7B-Chat) models, after placing the models in a local folder, you can utilize [TGI (Text Generation Inference)](https://github.com/WisdomShell/text-generation-inference.git) to load these local models and initiate the model service. 68 | 69 | ### Load the model 70 | 71 | - The `CodeShell-7B-Chat-int4` model can be served as an API using the `server` command within the `llama_cpp_for_codeshell` project. 72 | 73 | ```bash 74 | ./server -m ./models/codeshell-chat-q4_0.gguf --host 127.0.0.1 --port 8080 75 | ``` 76 | 77 | Note: In cases where Metal is enabled during compilation, if you encounter runtime exceptions, you can explicitly disable Metal GPU inference by adding the `-ngl 0` parameter in the command line to ensure the proper functioning of the model. 78 | 79 | - [CodeShell-7B](https://huggingface.co/WisdomShell/CodeShell-7B) and [CodeShell-7B-Chat](https://huggingface.co/WisdomShell/CodeShell-7B-Chat) models, loading local models with [TGI](https://github.com/WisdomShell/text-generation-inference.git) and starting the model service. 80 | 81 | ## Model Service [NVIDIA GPU] 82 | 83 | For users wishing to use NVIDIA GPUs for inference, the [`text-generation-inference`](https://github.com/huggingface/text-generation-inference) project can be used to deploy the [CodeShell Large Model](https://github.com/WisdomShell/codeshell). Below are the steps to deploy the model service: 84 | 85 | ### Download the Model 86 | 87 | After downloading the model from the [Hugging Face Hub](https://huggingface.co/WisdomShell/CodeShell-7B-Chat) to your local machine, place the model under the path of the `$HOME/models` folder, and you can load the model locally. 88 | 89 | ```bash 90 | git clone https://huggingface.co/WisdomShell/CodeShell-7B-Chat 91 | ``` 92 | 93 | ### Deploy the Model 94 | 95 | The following command can be used for GPU-accelerated inference deployment with text-generation-inference: 96 | 97 | ```bash 98 | docker run --gpus 'all' --shm-size 1g -p 9090:80 -v $HOME/models:/data \ 99 | --env LOG_LEVEL="info,text_generation_router=debug" \ 100 | ghcr.nju.edu.cn/huggingface/text-generation-inference:1.0.3 \ 101 | --model-id /data/CodeShell-7B-Chat --num-shard 1 \ 102 | --max-total-tokens 5000 --max-input-length 4096 \ 103 | --max-stop-sequences 12 --trust-remote-code 104 | ``` 105 | 106 | For a more detailed explanation of the parameters, please refer to the [text-generation-inference project documentation](https://github.com/huggingface/text-generation-inference). 107 | 108 | 109 | ## Configure the Plugin 110 | 111 | - Set the address for the CodeShell service 112 | - Configure whether to enable automatic code completion suggestions 113 | - Set the time delay for triggering automatic code completion suggestions 114 | - Specify the maximum number of tokens for code completion 115 | - Specify the maximum number of tokens for Q&A 116 | - Configure the model runtime environment 117 | 118 | Note: Different model runtime environments can be configured within the plugin. For the [CodeShell-7B-Chat-int4](https://huggingface.co/WisdomShell/CodeShell-7B-Chat-int4) model, you can choose the `CPU with llama.cpp"`option in the `Code Shell: Run Env For LLMs` menu. However, for the [CodeShell-7B](https://huggingface.co/WisdomShell/CodeShell-7B) and [CodeShell-7B-Chat](https://huggingface.co/WisdomShell/CodeShell-7B-Chat) models, you should select the `GPU with TGI toolkit` option. 119 | 120 |  121 | 122 | ## Features 123 | 124 | ### 1. Code Completion 125 | 126 | - Automatic Code Suggestions 127 | - Keyboard Shortcut for Code Suggestions 128 | 129 | During the coding process, code completion suggestions can automatically trigger when you pause input (configurable with the `Auto Completion Delay` option, set to 1-3 seconds). Alternatively, you can manually trigger code completion suggestions using the shortcut key `Alt+\` (for Windows) or `Option+\` (for Mac). 130 | 131 | When the plugin provides code suggestions, the suggested content appears in gray at the editor's cursor position. You can press the Tab key to accept the suggestion or continue typing to ignore it. 132 | 133 |  134 | 135 | ### 2. Code Assistance 136 | 137 | - Explain/Optimize/Cleanse a Code Segment 138 | - Generate Comments/Unit Tests for Code 139 | - Check Code for Performance/Security Issues 140 | 141 | In the VSCode sidebar, open the plugin's Q&A interface. Select a portion of code in the editor, right-click to access the CodeShell menu, and choose the corresponding function. The plugin will provide relevant responses in the Q&A interface. 142 | 143 |  144 | 145 | ### 3. Code Q&A 146 | 147 | - Support for Multi-turn Conversations 148 | - Maintain Conversation History 149 | - Engage in Multi-turn Dialogues Based on Previous Conversations 150 | - Edit Questions and Rephrase Inquiries 151 | - Request Fresh Responses for Any Question 152 | - Interrupt During the Answering Process 153 | 154 |  155 | 156 | Within the Q&A interface's code block, you can click the copy button to copy the code block or use the insert button to insert the code block's content at the editor's cursor location. 157 | 158 | ## License 159 | 160 | Apache 2.0 161 | 162 | ## Star History 163 | 164 | [](https://star-history.com/#WisdomShell/codeshell-vscode&Date) -------------------------------------------------------------------------------- /assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WisdomShell/codeshell-vscode/00c045b1c08fea8df7adcfa354b443ecdc1fa429/assets/logo.png -------------------------------------------------------------------------------- /assets/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /assets/readme/docs_assistants.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WisdomShell/codeshell-vscode/00c045b1c08fea8df7adcfa354b443ecdc1fa429/assets/readme/docs_assistants.png -------------------------------------------------------------------------------- /assets/readme/docs_chat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WisdomShell/codeshell-vscode/00c045b1c08fea8df7adcfa354b443ecdc1fa429/assets/readme/docs_chat.png -------------------------------------------------------------------------------- /assets/readme/docs_completion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WisdomShell/codeshell-vscode/00c045b1c08fea8df7adcfa354b443ecdc1fa429/assets/readme/docs_completion.png -------------------------------------------------------------------------------- /assets/readme/docs_settings_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WisdomShell/codeshell-vscode/00c045b1c08fea8df7adcfa354b443ecdc1fa429/assets/readme/docs_settings_new.png -------------------------------------------------------------------------------- /l10n/bundle.l10n.zh-cn.json: -------------------------------------------------------------------------------- 1 | { 2 | "Enable Auto Completion": "启用 自动触发补全", 3 | "Disable Auto Completion": "停用 自动触发补全", 4 | "Explain Selected Codes": "解释 这段代码", 5 | "Please explain the following {0} code": "请解释以下{0}代码", 6 | "Optimize Selected Codes": "优化 这段代码", 7 | "Please optimize and rewrite the following {0} code": "请优化并重写以下{0}代码", 8 | "Clean Selected Codes": "清理 这段代码", 9 | "Please clean and rewrite the following {0} code": "请清理并重写以下{0}代码", 10 | "Generate Comment": "生成 注释", 11 | "Please generate comments for the following {0} code": "请为以下{0}代码生成注释", 12 | "Generate Unit Test": "生成 单元测试", 13 | "Please generate unit tests for the following {0} code": "请为以下{0}代码生成单元测试", 14 | "Check Performance": "检查 性能问题", 15 | "Check the following {0} code for any performance issues, and please provide optimization suggestions": "检查以下{0}代码,是否存在性能问题,请给出优化建议", 16 | "Check Security": "检查 安全性问题", 17 | "Check the following {0} code for any security issues, and please provide optimization suggestions": "检查以下{0}代码, 是否存在安全性问题,请给出优化建议", 18 | "select coding task": "选择快捷指令:", 19 | "Ask CodeShell": "向CodeShell提问", 20 | "Please enter your question description": "请输入您的问题描述", 21 | "question description": "问题描述", 22 | "Start a new session": "开启新会话", 23 | "Stop Gen": "停止生成", 24 | "History": "历史", 25 | "Send": "发送", 26 | "Disable auto code completion (can be triggered by shortcut keys)": "禁用 自动触发代码补全(可由快捷键触发)", 27 | "Enable automatically code completion (triggered when input stops)": "启用 自动触发代码补全(输入停止时触发)", 28 | "Enable": "启用", 29 | "Answer :": "回答 :", 30 | "Answer output completed": "回答输出完毕!", 31 | "Ask here, press Enter key to send": "在这里提问, Enter发送", 32 | "Line break": "换行", 33 | "Unknown Language type": "无法确定语言类型!", 34 | "Disable": "禁用", 35 | "Request timeout, please try again later": "请求超时,请稍后重试。", 36 | "Please select a section of code": "请选中一段代码", 37 | "Back": "返回", 38 | "How about this answer?": "这个回答怎么样?", 39 | "Question :": "问题 :", 40 | "Homepage": "首页" 41 | } -------------------------------------------------------------------------------- /media/main.js: -------------------------------------------------------------------------------- 1 | // @ts-ignore 2 | /* eslint-disable */ 3 | 4 | // This script will be run within the webview itself 5 | // It cannot access the main VS Code APIs directly. 6 | (function () { 7 | const vscode = acquireVsCodeApi(); 8 | 9 | const showdownConverter = new showdown.Converter({ 10 | omitExtraWLInCodeBlocks: true, 11 | simplifiedAutoLink: true, 12 | excludeTrailingPunctuationFromURLs: true, 13 | literalMidWordUnderscores: true, 14 | simpleLineBreaks: true 15 | }); 16 | 17 | // Handle messages sent from the extension to the webview 18 | window.addEventListener("message", (event) => { 19 | const message = event.data; 20 | switch (message.type) { 21 | case "addQuestionAnswerDiv": { 22 | addQuestionAnswerDiv(message.value); 23 | break; 24 | } 25 | case "addStreamResponse": { 26 | addStreamResponse(message.value); 27 | break; 28 | } 29 | case "responseStreamDone": { 30 | responseStreamDone(message.value); 31 | break; 32 | } 33 | case "historySessionDone": { 34 | historySessionDone(message.value); 35 | break; 36 | } 37 | case "historyQuestionAnswerDone": { 38 | historyQuestionAnswerDone(message.value); 39 | break; 40 | } 41 | } 42 | }); 43 | 44 | function addQuestionAnswerDiv(eventData) { 45 | let chatContainer = document.getElementById("chatContainerQuestionListId"); 46 | 47 | div = document.createElement("div") 48 | div.innerHTML = eventData.divContent 49 | chatContainer.appendChild(div); 50 | 51 | let questionDiv = document.getElementById(`questionDiv${eventData.contentIndex}`); 52 | html = showdownConverter.makeHtml(eventData.question); 53 | questionDiv.innerHTML = html; 54 | hljs.highlightAll(); 55 | 56 | chatContainer.scrollTop = chatContainer.scrollHeight; 57 | questionEditBtn(eventData.contentIndex, eventData.question); 58 | showChat_hideHistory(); 59 | } 60 | 61 | function addStreamResponse(eventData) { 62 | const contentIndex = eventData.contentIndex; 63 | const responseText = fixCodeBlocks(eventData.responseText); 64 | 65 | const html = showdownConverter.makeHtml(responseText); 66 | const outputDiv = document.getElementById(`outputDiv${contentIndex}`); 67 | outputDiv.innerHTML = null; 68 | outputDiv.innerHTML = html; 69 | addCodeBlockButtons(contentIndex); 70 | hljs.highlightAll(); 71 | 72 | const chatContainer = document.getElementById("chatContainerQuestionListId"); 73 | const testNextDiv = document.getElementById(`qa_section_div_${contentIndex + 1}`); 74 | if (!testNextDiv) { 75 | chatContainer.scrollTop = chatContainer.scrollHeight; 76 | } 77 | 78 | document.getElementById("btn-stop-streaming").style.display = "block"; 79 | } 80 | 81 | function responseStreamDone(eventData) { 82 | const contentIndex = eventData.contentIndex; 83 | const responseText = eventData.responseText; 84 | 85 | // const aiMsgId = eventData.aiMsgId; 86 | // span = document.createElement("span"); 87 | // span.innerText = `ai message id = ${aiMsgId}`; 88 | // const outputDiv = document.getElementById(`outputDiv${contentIndex}`); 89 | // outputDiv.append(span); 90 | 91 | answerCopyBtn(contentIndex, responseText); 92 | answerRefreshBtn(contentIndex); 93 | codeBlockButtonEvent(contentIndex); 94 | handleFeedbackBtns(eventData); 95 | 96 | hljs.highlightAll(); 97 | document.getElementById("btn-stop-streaming").style.display = "none"; 98 | } 99 | 100 | function handleFeedbackBtns(eventData) { 101 | const contentIndex = eventData.contentIndex; 102 | if (eventData.aiMsgId && eventData.aiMsgId !== "0") { 103 | const feedbackDiv = document.getElementById(`feedbackDiv${contentIndex}`); 104 | feedbackDiv.style.display = "flex"; 105 | 106 | const feedbackGoodBtn = document.getElementById(`feedbackGoodBtn${contentIndex}`); 107 | const feedbackCheckBtn = document.getElementById(`feedbackCheckBtn${contentIndex}`); 108 | const feedbackBadBtn = document.getElementById(`feedbackBadBtn${contentIndex}`); 109 | 110 | if (feedbackGoodBtn.clickHandler) { 111 | feedbackGoodBtn.removeEventListener("click", feedbackGoodBtn.clickHandler) 112 | } 113 | feedbackGoodBtn.clickHandler = (e) => { 114 | vscode.postMessage({ type: "answerFeedbackGood", value: eventData.aiMsgId }); 115 | feedbackGoodBtn.style.display = "none"; 116 | feedbackCheckBtn.style.display = "flex"; 117 | setTimeout(() => { 118 | feedbackGoodBtn.style.display = "flex"; 119 | feedbackCheckBtn.style.display = "none"; 120 | }, 500); 121 | } 122 | feedbackGoodBtn.addEventListener("click", feedbackGoodBtn.clickHandler); 123 | 124 | if (feedbackBadBtn.clickHandler) { 125 | feedbackBadBtn.removeEventListener("click", feedbackBadBtn.clickHandler) 126 | } 127 | feedbackBadBtn.clickHandler = (e) => { 128 | vscode.postMessage({ type: "answerFeedbackBad", value: eventData.aiMsgId }); 129 | feedbackBadBtn.style.display = "none"; 130 | feedbackCheckBtn.style.display = "flex"; 131 | setTimeout(() => { 132 | feedbackBadBtn.style.display = "flex"; 133 | feedbackCheckBtn.style.display = "none"; 134 | }, 500); 135 | } 136 | feedbackBadBtn.addEventListener("click", feedbackBadBtn.clickHandler); 137 | } 138 | } 139 | 140 | function addCodeBlockButtons(outputIndex) { 141 | const outputDiv = document.getElementById(`outputDiv${outputIndex}`); 142 | const preBlocks = outputDiv.querySelectorAll("pre"); 143 | for (let i = 0; i < preBlocks.length; i++) { 144 | const preBlock = preBlocks[i]; 145 | const blockIndex = `${outputIndex}_${i}`; 146 | preBlock.id = `output_pre_${blockIndex}` 147 | 148 | div = document.createElement("div") 149 | div.classList.add("p0", "operations") 150 | div.innerHTML = `
` 167 | preBlock.prepend(div); 168 | } 169 | } 170 | 171 | function codeBlockButtonEvent(outputIndex) { 172 | const outputDiv = document.getElementById(`outputDiv${outputIndex}`); 173 | const preBlocks = outputDiv.querySelectorAll("pre"); 174 | for (let i = 0; i < preBlocks.length; i++) { 175 | let preBlock = preBlocks[i]; 176 | let blockIndex = `${outputIndex}_${i}`; 177 | 178 | let codeCopyBtn = document.getElementById(`codeCopyBtn_${blockIndex}`); 179 | codeCopyBtn.addEventListener("click", (e) => { 180 | navigator.clipboard.writeText(preBlock.innerText); 181 | let copyCheck = document.getElementById(`codeCopyCheck_${blockIndex}`); 182 | copyCheck.style.display = "flex"; 183 | codeCopyBtn.style.display = "none"; 184 | setTimeout(() => { 185 | copyCheck.style.display = "none"; 186 | codeCopyBtn.style.display = "flex"; 187 | }, 2000); 188 | }); 189 | 190 | let insertBtn = document.getElementById(`codeInsertBtn_${blockIndex}`); 191 | insertBtn.addEventListener("click", (e) => { 192 | navigator.clipboard.writeText(preBlock.innerText); 193 | vscode.postMessage({ type: "codeBlockInsert", value: preBlock.innerText }); 194 | let copyCheck = document.getElementById(`codeCopyCheck_${blockIndex}`); 195 | copyCheck.style.display = "flex"; 196 | insertBtn.style.display = "none"; 197 | setTimeout(() => { 198 | copyCheck.style.display = "none"; 199 | insertBtn.style.display = "flex"; 200 | }, 2000); 201 | }); 202 | } 203 | } 204 | 205 | function historySessionDone(eventData) { 206 | let div = document.getElementById("history_session_div"); 207 | div.innerHTML = eventData; 208 | 209 | let sessionDivs = document.querySelectorAll("div.session"); 210 | for (let sessionDiv of sessionDivs) { 211 | let itemDiv = sessionDiv.querySelector("div.session-item"); 212 | itemDiv.addEventListener("click", e => { 213 | vscode.postMessage({ type: "sessionItemClicked", value: sessionDiv.id }); 214 | }); 215 | let deleteDiv = sessionDiv.querySelector("div.session-options"); 216 | deleteDiv.addEventListener("click", e => { 217 | vscode.postMessage({ type: "sessionItemDelete", value: sessionDiv.id }); 218 | }); 219 | } 220 | } 221 | 222 | function historyQuestionAnswerDone(eventData) { 223 | showChat_hideHistory(); 224 | 225 | div = document.createElement("div") 226 | div.innerHTML = eventData.divContent; 227 | let chatContainer = document.getElementById("chatContainerQuestionListId"); 228 | chatContainer.innerHTML = null; 229 | chatContainer.appendChild(div); 230 | 231 | for (let i = 0; i < eventData.chatList.length; i++) { 232 | let question = eventData.chatList[i].humanMessage.content; 233 | let answer = eventData.chatList[i].aiMessage.content; 234 | qHtml = showdownConverter.makeHtml(question); 235 | document.getElementById(`questionDiv${i}`).innerHTML = qHtml; 236 | aHtml = showdownConverter.makeHtml(answer); 237 | document.getElementById(`outputDiv${i}`).innerHTML = aHtml; 238 | 239 | questionEditBtn(i, question); 240 | answerCopyBtn(i, answer); 241 | answerRefreshBtn(i); 242 | addCodeBlockButtons(i); 243 | codeBlockButtonEvent(i); 244 | } 245 | hljs.highlightAll(); 246 | 247 | const textarea = document.getElementById("questioninput"); 248 | textarea.value = ""; 249 | textarea.style.height = `35px`; 250 | chatContainer.scrollTop = chatContainer.scrollHeight; 251 | } 252 | 253 | function questionEditBtn(index, question) { 254 | let editBtn = document.getElementById(`editBtn${index}`); 255 | if (editBtn.clickHandler) { 256 | editBtn.removeEventListener("click", editBtn.clickHandler) 257 | } 258 | editBtn.clickHandler = (e) => { 259 | const textarea = document.getElementById("questioninput"); 260 | textarea.value = question; 261 | textarea.style.height = `${textarea.scrollHeight}px`; 262 | } 263 | editBtn.addEventListener("click", editBtn.clickHandler); 264 | } 265 | 266 | function answerCopyBtn(index, answer) { 267 | let copyBtn = document.getElementById(`copyBtn${index}`); 268 | if (copyBtn.clickHandler) { 269 | copyBtn.removeEventListener("click", copyBtn.clickHandler); 270 | } 271 | copyBtn.clickHandler = (e) => { 272 | navigator.clipboard.writeText(answer); 273 | let copyCheck = document.getElementById(`copyCheck${index}`); 274 | copyCheck.style.display = "block"; 275 | copyBtn.style.display = "none"; 276 | setTimeout(() => { 277 | copyCheck.style.display = "none"; 278 | copyBtn.style.display = "block"; 279 | }, 2000) 280 | } 281 | copyBtn.addEventListener("click", copyBtn.clickHandler); 282 | } 283 | 284 | function answerRefreshBtn(index) { 285 | let refreshBtn = document.getElementById(`refreshBtn${index}`); 286 | refreshBtn.style.display = "block"; 287 | if (refreshBtn.clickHandler) { 288 | refreshBtn.removeEventListener("click", refreshBtn.clickHandler); 289 | } 290 | refreshBtn.clickHandler = (e) => { 291 | refreshBtn.style.display = "none"; 292 | // loading 293 | document.getElementById(`outputDiv${index}`).innerHTML = ``; 294 | vscode.postMessage({ type: "regenerateThisAnswer", value: index }); 295 | } 296 | refreshBtn.addEventListener("click", refreshBtn.clickHandler); 297 | } 298 | 299 | function showChat_hideHistory() { 300 | let chatDiv = document.getElementById("main-div-aichat"); 301 | chatDiv.style.display = "block"; 302 | 303 | let hisDiv = document.getElementById("aichat_history_div"); 304 | hisDiv.style.display = "none"; 305 | } 306 | 307 | function hideChat_showHistory() { 308 | let chatDiv = document.getElementById("main-div-aichat"); 309 | chatDiv.style.display = "none"; 310 | 311 | let hisDiv = document.getElementById("aichat_history_div"); 312 | hisDiv.style.display = "block"; 313 | } 314 | 315 | document.getElementById("questioninput").addEventListener("keydown", event => { 316 | const textarea = event.target; 317 | console.debug("event.key =", event.key, ", event.keyCode = ", event.keyCode); 318 | console.debug(navigator.userAgent); 319 | let isMac = /macintosh|mac os x/i.test(navigator.userAgent); 320 | let isWin = /windows|win32|win64/i.test(navigator.userAgent); 321 | let isLinux = /linux/i.test(navigator.userAgent); 322 | console.debug(`isMac=${isMac}, isWin=${isWin}, isLinux=${isLinux}`); 323 | 324 | if (event.shiftKey && event.key === "Enter") { 325 | textarea.style.height = `${textarea.scrollHeight + 5}px`; 326 | } else if (((isWin || isLinux) && event.key === "Enter") || (isMac && event.keyCode === 13)) { 327 | event.preventDefault(); 328 | if (textarea.value && textarea.value.trim().length > 0) { 329 | vscode.postMessage({ type: "startQuestion", value: textarea.value.trim() }); 330 | textarea.value = ""; 331 | textarea.style.height = `35px`; 332 | } 333 | } 334 | }); 335 | 336 | document.getElementById("questioninput").addEventListener("keyup", event => { 337 | const textarea = event.target; 338 | if (textarea.value && textarea.value.trim().length === 0) { 339 | textarea.style.height = `35px`; 340 | } 341 | }); 342 | 343 | document.getElementById("send-button-img").addEventListener("click", event => { 344 | const textarea = document.getElementById("questioninput"); 345 | if (textarea.value && textarea.value.trim().length > 0) { 346 | vscode.postMessage({ type: "startQuestion", value: textarea.value.trim() }); 347 | textarea.value = ""; 348 | textarea.style.height = `35px`; 349 | } 350 | }); 351 | 352 | document.getElementById("add_session_btn").addEventListener("click", event => { 353 | vscode.postMessage({ type: "startNewSession" }); 354 | let element = document.getElementById("chatContainerQuestionListId"); 355 | element.innerHTML = null; 356 | }); 357 | 358 | document.getElementById("historyButton").addEventListener("click", event => { 359 | vscode.postMessage({ type: "showSessionHistory" }); 360 | hideChat_showHistory(); 361 | }); 362 | 363 | document.getElementById("historyBackButton").addEventListener("click", event => { 364 | showChat_hideHistory(); 365 | }); 366 | 367 | document.getElementById("btn-stop-streaming").addEventListener("click", event => { 368 | vscode.postMessage({ type: "stopGenerationStream" }); 369 | }); 370 | 371 | document.addEventListener("contextmenu", event => { 372 | event.preventDefault(); 373 | }); 374 | 375 | 376 | function fixCodeBlocks(textContent) { 377 | const REGEX_CODEBLOCK = new RegExp("\`\`\`", "g"); 378 | const matches = textContent.match(REGEX_CODEBLOCK); 379 | 380 | const count = matches ? matches.length : 0; 381 | if (count % 2 === 0) { 382 | return textContent; 383 | } else { 384 | return textContent.concat("\n\`\`\`"); 385 | } 386 | } 387 | 388 | 389 | })(); 390 | -------------------------------------------------------------------------------- /media/styles/styles.c100.css: -------------------------------------------------------------------------------- 1 | [_ngcontent-uim-c100]:root { 2 | --font13: 13px; 3 | --font10: calc(var(--font13) - 3px); 4 | --font11: calc(var(--font13) - 2px); 5 | --font12: calc(var(--font13) - 1px); 6 | --font14: calc(var(--font13) + 1px); 7 | --font15: calc(var(--font13) + 2px); 8 | --font16: calc(var(--font13) + 3px); 9 | --font17: calc(var(--font13) + 4px); 10 | --font18: calc(var(--font13) + 5px); 11 | --font19: calc(var(--font13) + 6px); 12 | --font20: calc(var(--font13) + 7px); 13 | --minHeightAI: 40px 14 | } 15 | 16 | .sharebutton[_ngcontent-uim-c100] { 17 | padding: 3px 8px 18 | } 19 | 20 | .sharebutton[_ngcontent-uim-c100]:hover { 21 | background: rgba(208, 214, 217, .05); 22 | border-radius: 3px 23 | } 24 | 25 | .ant-dropdown-menu { 26 | background-color: #44484a; 27 | box-shadow: 0 0 20px #00000026; 28 | padding: 0 29 | } 30 | 31 | li.ant-dropdown-menu-item[_ngcontent-uim-c100] { 32 | color: #c4c9cc; 33 | padding: 8px; 34 | font-size: var(--font15); 35 | min-height: 32px !important 36 | } 37 | 38 | li.ant-dropdown-menu-item[_ngcontent-uim-c100]:hover { 39 | background-color: #d0d6d90d 40 | } 41 | 42 | .shareIcons[_ngcontent-uim-c100] { 43 | width: 17.64px; 44 | height: 14.54px; 45 | margin-right: 5px 46 | } 47 | 48 | .optionContainer[_ngcontent-uim-c100] { 49 | width: 131px 50 | } 51 | -------------------------------------------------------------------------------- /media/styles/styles.c101.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --font13: 13px; 3 | --font10: calc(var(--font13) - 3px); 4 | --font11: calc(var(--font13) - 2px); 5 | --font12: calc(var(--font13) - 1px); 6 | --font14: calc(var(--font13) + 1px); 7 | --font15: calc(var(--font13) + 2px); 8 | --font16: calc(var(--font13) + 3px); 9 | --font17: calc(var(--font13) + 4px); 10 | --font18: calc(var(--font13) + 5px); 11 | --font19: calc(var(--font13) + 6px); 12 | --font20: calc(var(--font13) + 7px); 13 | --minHeightAI: 40px 14 | } 15 | 16 | body.body-y-scroll { 17 | overflow-y: scroll !important 18 | } 19 | 20 | .aiChat-title { 21 | color: #fff; 22 | width: 98%; 23 | background: transparent; 24 | outline: none; 25 | border: none; 26 | font-family: Public Sans; 27 | font-style: normal; 28 | font-weight: 600; 29 | font-size: var(--font15); 30 | line-height: 150%; 31 | margin: 5px 0 0 32 | } 33 | 34 | .question-title, 35 | .answer-title { 36 | background: transparent; 37 | outline: none; 38 | border: none; 39 | font-weight: 600; 40 | font-size: var(--font13); 41 | line-height: 150%; 42 | color: #7a8084; 43 | padding: 5px 0 44 | } 45 | 46 | .answerDiv { 47 | color: #fff; 48 | font-size: var(--font13); 49 | margin: 10px 0; 50 | white-space: break-spaces; 51 | width: -moz-fit-content; 52 | width: fit-content 53 | } 54 | 55 | .primary { 56 | background: #007ACC; 57 | font-weight: 300; 58 | color: #fff; 59 | cursor: pointer 60 | } 61 | 62 | .secondary { 63 | border: 1px solid #585858; 64 | color: #fff; 65 | cursor: pointer 66 | } 67 | 68 | .secondary:disabled { 69 | cursor: none 70 | } 71 | 72 | .primary:disabled { 73 | cursor: none 74 | } 75 | 76 | .submit:hover { 77 | color: #92a1b1 78 | } 79 | 80 | .history-btn-section { 81 | height: 50px 82 | } 83 | 84 | .history-buttons-container { 85 | padding: 10px; 86 | display: flex; 87 | justify-content: space-between 88 | } 89 | 90 | .history-buttons { 91 | color: #7a8084; 92 | cursor: pointer; 93 | font-weight: 600; 94 | font-size: var(--font13); 95 | line-height: 150% 96 | } 97 | 98 | .history-btn { 99 | padding: 6px 12px; 100 | vertical-align: middle; 101 | display: flex; 102 | align-items: center; 103 | cursor: pointer 104 | } 105 | 106 | .history-btn:hover { 107 | background: rgba(208, 214, 217, .05); 108 | border-radius: 3px 109 | } 110 | 111 | .history-btn:hover .history-buttons, 112 | .history-buttons:hover { 113 | color: #fff 114 | } 115 | 116 | .empty-placeholder { 117 | text-align: center; 118 | color: #7a8084; 119 | padding: 20px 0; 120 | overflow-y: scroll; 121 | height: calc(100vh - 230px) 122 | } 123 | 124 | .placeholder-title { 125 | font-weight: 600; 126 | font-size: var(--font13); 127 | margin-top: 10px; 128 | padding-bottom: 8px 129 | } 130 | 131 | .placeholder-subtitle { 132 | font-weight: 400; 133 | font-size: var(--font13); 134 | padding: 1px 34px; 135 | text-align: justify 136 | } 137 | 138 | .ps { 139 | padding: 12px 10px 140 | } 141 | 142 | ul { 143 | padding: 0; 144 | margin: 0; 145 | list-style-type: none 146 | } 147 | 148 | .placeholder-example { 149 | font-size: var(--font12) 150 | } 151 | 152 | .chat-container { 153 | width: 100%; 154 | height: calc(100vh - 218px); 155 | overflow-y: auto; 156 | overflow-x: hidden; 157 | padding: 0 7px 158 | } 159 | 160 | .chat-container .qa-section-div-main { 161 | border-bottom: .5px solid #7A8084 162 | } 163 | 164 | .chat-container .qa-section-div-main:last-of-type { 165 | border-bottom: none 166 | } 167 | 168 | .chat-container .qa-section-div-main:after { 169 | clear: both; 170 | content: ""; 171 | display: table; 172 | height: 15.5px 173 | } 174 | 175 | .footerContent { 176 | width: 99%; 177 | position: absolute; 178 | bottom: 0; 179 | left: 0; 180 | max-width: 100%; 181 | margin-bottom: 8px 182 | } 183 | 184 | .reduce-chat-height-40 { 185 | height: 64vh !important 186 | } 187 | 188 | .reduce-chat-height-60 { 189 | height: 69vh !important 190 | } 191 | 192 | .reduce-chat-height-80 { 193 | height: 66vh !important 194 | } 195 | 196 | .questionDiv, 197 | .question-title { 198 | display: flex 199 | } 200 | 201 | .questionDiv { 202 | background: #007ACC; 203 | border-radius: 12px 12px 4px 4px; 204 | padding: 4px; 205 | color: #fff; 206 | font-weight: 400; 207 | font-size: var(--font13); 208 | float: right; 209 | overflow-wrap: anywhere; 210 | white-space: break-spaces 211 | } 212 | 213 | .questionDiv .questionText span { 214 | padding-bottom: 5px 215 | } 216 | 217 | .questionDiv .CodeSection { 218 | background-color: #171818; 219 | border-radius: 5px 220 | } 221 | 222 | .questionDiv .CodeSection .file-Header { 223 | justify-content: space-between; 224 | padding: 8px 12px; 225 | font-size: var(--font13); 226 | line-height: 13px 227 | } 228 | 229 | .questionDiv .CodeSection .file-Header .file-info .file-name { 230 | color: #c4c9cc; 231 | max-width: 35vw 232 | } 233 | 234 | .questionDiv .CodeSection .file-Header .file-info .file-line-number { 235 | color: #7a8084 236 | } 237 | 238 | .questionDiv .CodeSection .code-view-toggle { 239 | color: #2baaff 240 | } 241 | 242 | .questionDiv .CodeSection .code-view-toggle:hover { 243 | cursor: pointer 244 | } 245 | 246 | .questionDiv .CodeSection .code-view-toggle .btn-toggle-code:after { 247 | content: "View" 248 | } 249 | 250 | .questionDiv .CodeSection .code-view-toggle .btn-toggle-code.state-show:after { 251 | content: "Hide" 252 | } 253 | 254 | .questionDiv .CodeSection .code-block { 255 | background-color: #212224; 256 | border-radius: 5px 257 | } 258 | 259 | .questionDiv .CodeSection .code-block pre, 260 | .questionDiv .CodeSection .code-block code { 261 | margin-top: 0 !important; 262 | margin-bottom: -3px !important 263 | } 264 | 265 | .questionDiv .CodeSection .code-block code.hljs { 266 | display: inline-block; 267 | background: inherit; 268 | color: #839496; 269 | -webkit-text-size-adjust: none; 270 | width: 100% 271 | } 272 | 273 | .answerDiv { 274 | background: #44484A; 275 | border-radius: 12px 12px 12px 4px; 276 | padding: 4px; 277 | margin: 0; 278 | overflow-wrap: anywhere; 279 | white-space: break-spaces; 280 | font-size: var(--font13); 281 | font-weight: 400; 282 | width: 100% 283 | } 284 | 285 | .question-container { 286 | padding: 0; 287 | float: right 288 | } 289 | 290 | .answer-container { 291 | padding: 0; 292 | float: left; 293 | width: 100% 294 | } 295 | 296 | .chat-input { 297 | font-size: var(--font13) 298 | } 299 | 300 | .textarea-container { 301 | bottom: 0; 302 | width: 100%; 303 | left: 0; 304 | padding: 10px 305 | } 306 | 307 | .back-btn { 308 | display: flex; 309 | cursor: pointer; 310 | align-items: center; 311 | font-size: var(--font14); 312 | font-weight: 600; 313 | color: #fff 314 | } 315 | 316 | .history-question, 317 | .history-answer { 318 | padding: 8px 12px 12px 319 | } 320 | 321 | .history-question { 322 | background: #44484A 323 | } 324 | 325 | .history-text { 326 | color: #fff; 327 | padding-top: 12px; 328 | overflow-wrap: anywhere; 329 | white-space: break-spaces 330 | } 331 | 332 | .divider { 333 | height: 2px; 334 | background: #7A8084 335 | } 336 | 337 | .history-title { 338 | padding-top: 4px; 339 | font-size: var(--font13); 340 | font-weight: 600; 341 | color: #7a8084 342 | } 343 | 344 | .history-created { 345 | font-size: var(--font13); 346 | font-weight: 400; 347 | color: #7a8084; 348 | padding-top: 4px 349 | } 350 | 351 | .copy-btn-text { 352 | font-size: var(--font13); 353 | font-weight: 600 354 | } 355 | 356 | .copy-btn { 357 | padding: 4px 4px 4px 8px; 358 | vertical-align: middle; 359 | display: flex; 360 | align-items: center; 361 | color: #7a8084; 362 | cursor: pointer 363 | } 364 | 365 | .copy-btn:hover { 366 | background: rgba(208, 214, 217, .05); 367 | border-radius: 3px 368 | } 369 | 370 | .copy-btn:hover .copy-btn-text, 371 | .copy-btn-text:hover { 372 | color: #fff 373 | } 374 | 375 | .loading1-spinner { 376 | background-color: #00000085; 377 | position: absolute; 378 | width: 100%; 379 | top: 70px; 380 | left: 0; 381 | height: 100vh; 382 | align-items: center; 383 | justify-content: center; 384 | display: grid; 385 | z-index: 3002; 386 | opacity: 9999; 387 | min-width: 250px 388 | } 389 | 390 | .spinner1-border { 391 | display: inline-block; 392 | width: 1.5rem; 393 | height: 1.5rem; 394 | vertical-align: text-bottom; 395 | border: 1.75px solid #fff; 396 | border-right-color: transparent; 397 | border-radius: 50%; 398 | animation: spinner-border .75s linear infinite; 399 | margin-top: -250px 400 | } 401 | 402 | .loader-text { 403 | color: #fff; 404 | font-size: var(--font20); 405 | position: fixed; 406 | top: 50%; 407 | z-index: 3003; 408 | margin: auto; 409 | width: 100%; 410 | text-align: center 411 | } 412 | 413 | .insert-btn-txt { 414 | float: right; 415 | padding: 4px 4px 4px 8px; 416 | vertical-align: middle; 417 | display: flex; 418 | align-items: center; 419 | color: #7a8084; 420 | cursor: pointer; 421 | right: 50%; 422 | font-size: var(--font13); 423 | font-weight: 600 424 | } 425 | 426 | .insert-btn-txt:hover { 427 | background: rgba(208, 214, 217, .05); 428 | border-radius: 3px; 429 | color: #fff 430 | } 431 | 432 | pre code.hljs { 433 | display: block; 434 | overflow-x: hidden; 435 | background: #212224; 436 | border-radius: 0 0 4px 4px; 437 | padding: 12px; 438 | margin: 0; 439 | font-size: var(--font13) 440 | } 441 | 442 | pre code.hljs:hover { 443 | overflow-x: overlay 444 | } 445 | 446 | pre { 447 | margin-top: 0 !important; 448 | margin-bottom: 0rem !important 449 | } 450 | 451 | .outputDivPreblock { 452 | overflow-x: hidden 453 | } 454 | 455 | .operations { 456 | align-items: center; 457 | display: flex; 458 | justify-content: flex-end; 459 | background: #171818; 460 | height: 32px; 461 | border-radius: 4px 4px 0 0 462 | } 463 | 464 | #main-div-aichat { 465 | margin: 0 466 | } 467 | 468 | #questioninput { 469 | overflow: hidden 470 | } 471 | 472 | @media (max-width: 250px) { 473 | .footerContent { 474 | width: 99%; 475 | position: absolute; 476 | bottom: 0; 477 | left: 0; 478 | max-width: 100%; 479 | margin-bottom: 8px 480 | } 481 | 482 | #questioninput { 483 | overflow: auto !important 484 | } 485 | } 486 | 487 | .preCodeBlockText { 488 | font-size: var(--font13); 489 | line-height: 22.5px; 490 | color: #fff; 491 | margin-bottom: 8px; 492 | padding-left: 6px 493 | } 494 | 495 | .outputDivPreblock { 496 | overflow-x: hidden; 497 | white-space: normal; 498 | margin: 0 !important 499 | } 500 | 501 | .ant-tooltip { 502 | font-size: var(--font13) !important 503 | } 504 | 505 | .ai-parent-div, 506 | .footerContent { 507 | min-width: 250px 508 | } 509 | 510 | .add-session-icon .add-session-btn { 511 | height: 32px; 512 | width: 32px; 513 | background: #007ACC; 514 | border-radius: 3px; 515 | display: flex; 516 | justify-content: center; 517 | align-items: center 518 | } 519 | 520 | .add-session-icon .add-session-btn .plus-icon { 521 | font-size: 32px; 522 | color: #fff 523 | } 524 | 525 | .add-session-icon .add-session-btn:hover { 526 | cursor: pointer 527 | } 528 | 529 | .back-btn .back-icon .fas { 530 | height: 14.98px; 531 | width: 14.99px; 532 | margin-right: 16px; 533 | color: gray 534 | } 535 | 536 | .back-btn .back-label { 537 | font-size: var(--font15); 538 | color: #7a8084 539 | } 540 | 541 | .session { 542 | display: flex; 543 | justify-content: space-between; 544 | padding: 12px; 545 | min-height: 66px; 546 | border-bottom: 1px solid #44484A; 547 | border-radius: 0 2px 2px 0 548 | } 549 | 550 | .session .session-item { 551 | width: 92% 552 | } 553 | 554 | .session .session-item .session-title { 555 | font-weight: 600; 556 | font-size: var(--font13); 557 | line-height: 150%; 558 | color: #fff; 559 | min-height: 20px; 560 | text-overflow: ellipsis; 561 | white-space: nowrap; 562 | overflow: hidden 563 | } 564 | 565 | .session .session-item .session-date-time { 566 | font-weight: 400; 567 | font-size: var(--font13); 568 | line-height: 150%; 569 | color: #7a8084; 570 | min-height: 20px 571 | } 572 | 573 | .session .session-options { 574 | min-width: 24px; 575 | height: 40px; 576 | display: flex; 577 | justify-content: center; 578 | align-items: center; 579 | border-radius: 4px 580 | } 581 | 582 | .session .session-options:hover, 583 | .session:hover { 584 | background-color: #d0d6d90d; 585 | cursor: pointer 586 | } 587 | 588 | .history-panel { 589 | height: calc(100vh - 95px); 590 | overflow: auto 591 | } 592 | 593 | .sharebutton { 594 | padding: 3px 8px 595 | } 596 | 597 | .sharebutton:hover { 598 | background: rgba(208, 214, 217, .05); 599 | border-radius: 3px 600 | } 601 | 602 | .ant-dropdown-menu { 603 | background-color: #44484a; 604 | box-shadow: 0 0 20px #00000026; 605 | padding: 0 606 | } 607 | 608 | li.ant-dropdown-menu-item { 609 | color: #c4c9cc; 610 | padding: 8px; 611 | font-size: var(--font15); 612 | min-height: 32px !important 613 | } 614 | 615 | li.ant-dropdown-menu-item:hover { 616 | background-color: #d0d6d90d 617 | } 618 | 619 | .ant-dropdown-menu-submenu-title { 620 | color: #c4c9cc; 621 | padding: 8px; 622 | font-size: var(--font15); 623 | min-height: 32px !important 624 | } 625 | 626 | .ant-dropdown-menu-submenu-title:hover { 627 | background-color: #d0d6d90d !important 628 | } 629 | 630 | .ant-dropdown-menu-submenu-expand-icon { 631 | display: none !important 632 | } 633 | 634 | .option-container { 635 | width: 131px; 636 | border-radius: 2px 637 | } 638 | 639 | i.anticon.anticon-share-alt { 640 | margin-right: 5px !important; 641 | font-size: 19px !important; 642 | vertical-align: 0px !important; 643 | padding-right: 2px !important; 644 | color: #7a8084 !important 645 | } 646 | 647 | .option-container .share-icon { 648 | width: 16px; 649 | height: 17.78px 650 | } 651 | 652 | .option-container .delete-icon { 653 | width: 17.5px; 654 | height: 16.5px 655 | } 656 | 657 | .option-container p { 658 | font-size: var(--font15); 659 | color: #c4c9cc; 660 | margin-left: 8px; 661 | font-weight: 400 662 | } 663 | -------------------------------------------------------------------------------- /media/styles/styles.c110.css: -------------------------------------------------------------------------------- 1 | [_ngcontent-uim-c110]:root { 2 | --font13: 13px; 3 | --font10: calc(var(--font13) - 3px); 4 | --font11: calc(var(--font13) - 2px); 5 | --font12: calc(var(--font13) - 1px); 6 | --font14: calc(var(--font13) + 1px); 7 | --font15: calc(var(--font13) + 2px); 8 | --font16: calc(var(--font13) + 3px); 9 | --font17: calc(var(--font13) + 4px); 10 | --font18: calc(var(--font13) + 5px); 11 | --font19: calc(var(--font13) + 6px); 12 | --font20: calc(var(--font13) + 7px); 13 | --minHeightAI: 40px 14 | } 15 | 16 | .ant-collapse { 17 | box-sizing: border-box; 18 | margin: 0; 19 | padding: 0; 20 | color: #000000d9; 21 | font-size: var(--font14); 22 | font-variant: tabular-nums; 23 | line-height: 1.5715; 24 | list-style: none; 25 | font-feature-settings: "tnum", "tnum"; 26 | background-color: #2f3133 !important; 27 | border: none; 28 | border-bottom: 0; 29 | border-radius: 2px; 30 | color: #7a8084 !important 31 | } 32 | 33 | .ant-collapse .ant-collapse-content { 34 | --min-height: 40px; 35 | color: #7a8084 !important; 36 | background-color: #2f3133 !important; 37 | border-top: none !important; 38 | min-height: var(--minHeightAI) !important 39 | } 40 | 41 | .ant-collapse .ant-collapse-header { 42 | border-radius: 0 0 2px 2px !important; 43 | color: #7a8084 !important; 44 | text-align: center !important; 45 | font-size: var(--font13) !important; 46 | font-weight: 500 !important; 47 | padding: 4px 0 !important; 48 | border-top: 1px solid #44484A; 49 | height: 28px !important 50 | } 51 | 52 | .ant-collapse .ant-collapse-item { 53 | border-bottom: none !important 54 | } 55 | 56 | .ant-collapse .ant-collapse-arrow { 57 | color: #2baaff !important; 58 | position: absolute !important; 59 | top: 60% !important; 60 | right: auto !important; 61 | margin-left: 46px !important; 62 | left: unset !important; 63 | transform: translateY(-50%) !important 64 | } 65 | 66 | .ant-collapse .ant-collapse-extra { 67 | float: left !important; 68 | top: 27%; 69 | left: 32%; 70 | position: absolute 71 | } 72 | 73 | .ant-collapse .ant-tooltip { 74 | max-width: calc(80vw - 20px) !important; 75 | font-size: var(--font12) !important 76 | } 77 | 78 | .ant-collapse .ant-tooltip-inner { 79 | color: #ff0 !important; 80 | background-color: green !important; 81 | width: 200px !important 82 | } 83 | 84 | .ant-collapse .ant-collapse-content-box { 85 | padding: 0 16px !important 86 | } 87 | 88 | .shortcuts-grid[_ngcontent-uim-c110] .shortcuts[_ngcontent-uim-c110] { 89 | text-align: center; 90 | padding: 0; 91 | color: #c4c9cc 92 | } 93 | 94 | .shortcuts-grid[_ngcontent-uim-c110] .shortcuts[_ngcontent-uim-c110] .shortcut-title[_ngcontent-uim-c110] { 95 | font-size: var(--font11) 96 | } 97 | 98 | .shortcuts-grid[_ngcontent-uim-c110] .shortcuts-wrapper[_ngcontent-uim-c110] { 99 | display: inline-block 100 | } 101 | 102 | .shortcuts-grid[_ngcontent-uim-c110] .shortcuts-content[_ngcontent-uim-c110]:hover, 103 | .shortcuts-grid[_ngcontent-uim-c110] .shortcuts-content.hovered[_ngcontent-uim-c110], 104 | .shortcuts-grid[_ngcontent-uim-c110] .shortcuts-wrapper[_ngcontent-uim-c110]:hover, 105 | .shortcuts-grid[_ngcontent-uim-c110] .shortcuts-wrapper.hovered[_ngcontent-uim-c110] { 106 | color: #fff; 107 | cursor: pointer 108 | } 109 | 110 | @media (max-width: 265px) { 111 | .shortcut-title[_ngcontent-uim-c110] { 112 | display: none 113 | } 114 | 115 | .shortcuts[_ngcontent-uim-c110] { 116 | padding-bottom: 5px; 117 | padding-top: 5px 118 | } 119 | 120 | .ant-collapse .ant-collapse-content { 121 | min-height: 24px !important 122 | } 123 | } 124 | 125 | @media (max-width: 313px) { 126 | .shortcut-title[_ngcontent-uim-c110] { 127 | max-width: 90%; 128 | overflow: hidden; 129 | text-overflow: ellipsis; 130 | white-space: nowrap 131 | } 132 | } 133 | 134 | .ant-collapse[_ngcontent-uim-c110] .ant-collapse-arrow.showAnimation[_ngcontent-uim-c110] { 135 | animation: bouncingBallAnimation 1s; 136 | animation-direction: alternate; 137 | animation-timing-function: cubic-bezier(.4, .06, 1, .6); 138 | animation-iteration-count: infinite 139 | } 140 | 141 | @keyframes bouncingBallAnimation { 142 | 0% { 143 | transform: translateY(0) 144 | } 145 | 146 | to { 147 | transform: translateY(-10px) 148 | } 149 | } 150 | 151 | .custom-shortcut-menu[_ngcontent-uim-c110] { 152 | vertical-align: top; 153 | float: right; 154 | padding: 5px; 155 | position: absolute; 156 | margin-left: calc(50% - 30px); 157 | cursor: pointer 158 | } 159 | 160 | .custom-shortcut-menu[_ngcontent-uim-c110]:hover { 161 | background: rgba(208, 214, 217, .05) 162 | } 163 | 164 | .ant-dropdown-menu { 165 | background-color: #44484a; 166 | box-shadow: 0 0 20px #00000026; 167 | padding: 0 168 | } 169 | 170 | li.ant-dropdown-menu-item[_ngcontent-uim-c110] { 171 | color: #c4c9cc; 172 | padding: 8px; 173 | font-size: var(--font15); 174 | min-height: 32px !important 175 | } 176 | 177 | li.ant-dropdown-menu-item[_ngcontent-uim-c110]:hover { 178 | background-color: #d0d6d90d 179 | } 180 | 181 | .ant-dropdown-menu-submenu-title { 182 | color: #c4c9cc; 183 | padding: 8px; 184 | font-size: var(--font15); 185 | min-height: 32px !important 186 | } 187 | 188 | .ant-dropdown-menu-submenu-title:hover { 189 | background-color: #d0d6d90d !important 190 | } 191 | 192 | .ant-dropdown-menu-submenu-expand-icon { 193 | display: none !important 194 | } 195 | 196 | .option-container[_ngcontent-uim-c110] { 197 | width: 131px; 198 | border-radius: 2px 199 | } 200 | 201 | .option-container[_ngcontent-uim-c110] .delete-icon[_ngcontent-uim-c110] { 202 | width: 17.5px; 203 | height: 16.5px 204 | } 205 | 206 | .option-container[_ngcontent-uim-c110] p[_ngcontent-uim-c110] { 207 | font-size: 15px; 208 | color: #c4c9cc; 209 | margin-left: 8px; 210 | font-weight: 400 211 | } 212 | 213 | -------------------------------------------------------------------------------- /media/styles/styles.c111.css: -------------------------------------------------------------------------------- 1 | :root { 2 | --font13: 13px; 3 | --font10: calc(var(--font13) - 3px); 4 | --font11: calc(var(--font13) - 2px); 5 | --font12: calc(var(--font13) - 1px); 6 | --font14: calc(var(--font13) + 1px); 7 | --font15: calc(var(--font13) + 2px); 8 | --font16: calc(var(--font13) + 3px); 9 | --font17: calc(var(--font13) + 4px); 10 | --font18: calc(var(--font13) + 5px); 11 | --font19: calc(var(--font13) + 6px); 12 | --font20: calc(var(--font13) + 7px); 13 | --minHeightAI: 40px 14 | } 15 | 16 | body.body-y-scroll { 17 | overflow-y: scroll !important 18 | } 19 | 20 | .aiChat-title { 21 | color: #fff; 22 | width: 98%; 23 | background: transparent; 24 | outline: none; 25 | border: none; 26 | font-family: Public Sans; 27 | font-style: normal; 28 | font-weight: 600; 29 | font-size: 15px; 30 | line-height: 150%; 31 | margin: 5px 0 0 32 | } 33 | 34 | .question-title, 35 | .answer-title { 36 | background: transparent; 37 | outline: none; 38 | border: none; 39 | font-weight: 600; 40 | font-size: var(--font13); 41 | line-height: 150%; 42 | color: #7a8084; 43 | padding: 5px 0 44 | } 45 | 46 | .answerDiv { 47 | color: #fff; 48 | font-size: var(--font13); 49 | margin: 10px 0; 50 | white-space: break-spaces; 51 | width: -moz-fit-content; 52 | width: fit-content 53 | } 54 | 55 | .primary { 56 | background: #007ACC; 57 | font-weight: 300; 58 | color: #fff; 59 | cursor: pointer 60 | } 61 | 62 | .secondary { 63 | border: 1px solid #585858; 64 | color: #fff; 65 | cursor: pointer 66 | } 67 | 68 | .secondary:disabled { 69 | cursor: none 70 | } 71 | 72 | .primary:disabled { 73 | cursor: none 74 | } 75 | 76 | .submit:hover { 77 | color: #92a1b1 78 | } 79 | 80 | .history-btn-section { 81 | display: flex; 82 | padding: 5px 5px 12px 83 | } 84 | 85 | .history-buttons-container { 86 | height: 30px; 87 | display: flex 88 | } 89 | 90 | .history-buttons { 91 | color: #7a8084; 92 | cursor: pointer; 93 | font-weight: 600; 94 | font-size: var(--font13); 95 | line-height: 150% 96 | } 97 | 98 | .history-btn { 99 | padding: 6px 12px; 100 | vertical-align: middle; 101 | display: flex; 102 | align-items: center; 103 | cursor: pointer 104 | } 105 | 106 | .history-btn:hover { 107 | background: rgba(208, 214, 217, .05); 108 | border-radius: 3px 109 | } 110 | 111 | .history-btn:hover .history-buttons, 112 | .history-buttons:hover { 113 | color: #fff 114 | } 115 | 116 | .empty-placeholder { 117 | color: #7a8084; 118 | padding: 20px; 119 | overflow-y: scroll; 120 | height: calc(100vh - 230px) 121 | } 122 | 123 | .placeholder-title { 124 | font-weight: 600; 125 | font-size: var(--font13); 126 | margin-top: 10px; 127 | padding-bottom: 8px 128 | } 129 | 130 | .empty-placeholder .help-icon { 131 | height: 40px; 132 | width: 40px; 133 | margin: 0 12px 0 0 134 | } 135 | 136 | .empty-placeholder .try-it-out-icon-wrapper .try-it-out-icon { 137 | width: 152.48px; 138 | height: 104.88px; 139 | margin: 0; 140 | position: relative; 141 | left: -15px 142 | } 143 | 144 | .empty-placeholder .placeholder-title { 145 | font-weight: 600; 146 | font-size: 18px; 147 | margin-top: 10px; 148 | padding-bottom: 8px; 149 | line-height: 27px; 150 | color: #7a8084 151 | } 152 | 153 | .empty-placeholder .sample-question-container .placeholder-subtitle { 154 | font-weight: 400; 155 | font-size: var(--font13); 156 | text-align: center; 157 | padding: 4px; 158 | border-radius: 4px; 159 | border: 1px solid #44484A; 160 | gap: 2px; 161 | margin-bottom: 6px 162 | } 163 | 164 | .empty-placeholder .sample-question-container .placeholder-subtitle:hover { 165 | cursor: pointer; 166 | background-color: #d0d6d90d 167 | } 168 | 169 | .ps { 170 | padding: 12px 10px 171 | } 172 | 173 | ul { 174 | padding: 0; 175 | margin: 0; 176 | list-style-type: disc 177 | } 178 | 179 | .placeholder-example { 180 | font-size: var(--font12) 181 | } 182 | 183 | .chat-container { 184 | width: 100%; 185 | height: calc(98vh - 218px); 186 | overflow-y: auto; 187 | overflow-x: hidden 188 | } 189 | 190 | .chat-container .qa-section-div-main { 191 | padding: 0 7px; 192 | border-bottom: .5px solid #7A8084 193 | } 194 | 195 | .chat-container .qa-section-div-main:last-of-type { 196 | border-bottom: none 197 | } 198 | 199 | .chat-container .qa-section-div-main:after { 200 | clear: both; 201 | content: ""; 202 | display: table; 203 | height: 5px 204 | } 205 | 206 | .footerContent { 207 | width: 100%; 208 | position: absolute; 209 | bottom: 0; 210 | left: 0; 211 | max-width: 100%; 212 | margin-bottom: 8px 213 | } 214 | 215 | .reduce-chat-height-40 { 216 | height: 64vh !important 217 | } 218 | 219 | .reduce-chat-height-60 { 220 | height: 69vh !important 221 | } 222 | 223 | .reduce-chat-height-80 { 224 | height: 66vh !important 225 | } 226 | 227 | .questionDiv, 228 | .question-title { 229 | display: flex 230 | } 231 | 232 | .questionDiv { 233 | background: #007ACC; 234 | border-radius: 12px 12px 4px 4px; 235 | padding: 4px; 236 | color: #fff; 237 | font-weight: 400; 238 | font-size: var(--font13); 239 | float: right; 240 | overflow-wrap: anywhere; 241 | white-space: break-spaces 242 | } 243 | 244 | .questionDiv .questionText span { 245 | padding-bottom: 5px 246 | } 247 | 248 | .questionDiv .CodeSection { 249 | background-color: #171818; 250 | border-radius: 5px 251 | } 252 | 253 | .questionDiv .CodeSection .file-Header { 254 | justify-content: space-between; 255 | padding: 8px 12px; 256 | font-size: var(--font13); 257 | line-height: 13px 258 | } 259 | 260 | .questionDiv .CodeSection .file-Header .file-info .file-name { 261 | color: #c4c9cc; 262 | max-width: 35vw 263 | } 264 | 265 | .questionDiv .CodeSection .file-Header .file-info .file-line-number { 266 | color: #7a8084 267 | } 268 | 269 | .questionDiv .CodeSection .code-view-toggle { 270 | color: #2baaff 271 | } 272 | 273 | .questionDiv .CodeSection .code-view-toggle:hover { 274 | cursor: pointer 275 | } 276 | 277 | .questionDiv .CodeSection .code-view-toggle .btn-toggle-code:after { 278 | content: "View" 279 | } 280 | 281 | .questionDiv .CodeSection .code-view-toggle .btn-toggle-code.state-show:after { 282 | content: "Hide" 283 | } 284 | 285 | .questionDiv .CodeSection .code-block { 286 | background-color: #212224; 287 | border-radius: 5px 288 | } 289 | 290 | .questionDiv .CodeSection .code-block pre, 291 | .questionDiv .CodeSection .code-block code { 292 | margin-top: 0 !important; 293 | margin-bottom: -3px !important 294 | } 295 | 296 | .questionDiv .CodeSection .code-block code.hljs { 297 | display: inline-block; 298 | background: inherit; 299 | color: #839496; 300 | -webkit-text-size-adjust: none; 301 | width: 100% 302 | } 303 | 304 | .answerDiv { 305 | background: #44484A; 306 | border-radius: 12px 12px 12px 4px; 307 | padding: 4px; 308 | margin: 0; 309 | overflow-wrap: anywhere; 310 | white-space: break-spaces; 311 | font-size: var(--font13); 312 | font-weight: 400; 313 | width: 100% 314 | } 315 | 316 | .question-container { 317 | padding: 0; 318 | float: right 319 | } 320 | 321 | .answer-container { 322 | padding: 0; 323 | width: 100% 324 | } 325 | 326 | .chat-input { 327 | font-size: var(--font13); 328 | padding: 10px; 329 | border-top-right-radius: 3px; 330 | border-top-left-radius: 3px 331 | } 332 | 333 | .textarea-container { 334 | bottom: 0; 335 | width: 100%; 336 | left: 0; 337 | padding: 10px 338 | } 339 | 340 | a.send { 341 | border-radius: 2px; 342 | width: 26px; 343 | height: 26px; 344 | background-color: #007acc; 345 | margin: 3px; 346 | padding: 3px 5px 347 | } 348 | 349 | a.send-disabled { 350 | background: none; 351 | cursor: default 352 | } 353 | 354 | .send-icon-disabled { 355 | opacity: 50% 356 | } 357 | 358 | .chat-input:focus+#reply-buttons2 { 359 | border-left: 1px solid #1f98e9; 360 | border-bottom: 1px solid #1f98e9; 361 | border-right: 1px solid #1f98e9 362 | } 363 | 364 | .shift-enter-text { 365 | padding-right: 4px; 366 | color: #7a8084; 367 | font-size: 11px 368 | } 369 | 370 | .back-btn { 371 | display: flex; 372 | cursor: pointer; 373 | align-items: center; 374 | font-size: var(--font14); 375 | font-weight: 600; 376 | color: #fff 377 | } 378 | 379 | .history-question, 380 | .history-answer { 381 | padding: 8px 12px 12px 382 | } 383 | 384 | .history-question { 385 | background: #44484A 386 | } 387 | 388 | .history-text { 389 | color: #fff; 390 | padding-top: 12px; 391 | overflow-wrap: anywhere; 392 | white-space: break-spaces 393 | } 394 | 395 | .divider { 396 | height: 2px; 397 | background: #7A8084 398 | } 399 | 400 | .history-title { 401 | padding-top: 4px; 402 | font-size: var(--font13); 403 | font-weight: 600; 404 | color: #7a8084 405 | } 406 | 407 | .history-created { 408 | font-size: var(--font13); 409 | font-weight: 400; 410 | color: #7a8084; 411 | padding-top: 4px 412 | } 413 | 414 | .copy-btn-text { 415 | font-size: var(--font13); 416 | font-weight: 600 417 | } 418 | 419 | .copy-btn { 420 | padding: 4px 4px 4px 8px; 421 | vertical-align: middle; 422 | display: flex; 423 | align-items: center; 424 | color: #7a8084; 425 | cursor: pointer 426 | } 427 | 428 | .copy-btn:hover { 429 | background: rgba(208, 214, 217, .05); 430 | border-radius: 3px 431 | } 432 | 433 | .copy-btn:hover .copy-btn-text, 434 | .copy-btn-text:hover { 435 | color: #fff 436 | } 437 | 438 | .loading1-spinner { 439 | background-color: #00000085; 440 | position: absolute; 441 | width: 100%; 442 | top: 70px; 443 | left: 0; 444 | height: 100vh; 445 | align-items: center; 446 | justify-content: center; 447 | display: grid; 448 | z-index: 3002; 449 | opacity: 9999; 450 | min-width: 250px 451 | } 452 | 453 | .spinner1-border { 454 | display: inline-block; 455 | width: 1.5rem; 456 | height: 1.5rem; 457 | vertical-align: text-bottom; 458 | border: 1.75px solid #fff; 459 | border-right-color: transparent; 460 | border-radius: 50%; 461 | animation: spinner-border .75s linear infinite; 462 | margin-top: -250px 463 | } 464 | 465 | .loader-text { 466 | color: #fff; 467 | font-size: var(--font20); 468 | position: fixed; 469 | top: 50%; 470 | z-index: 3003; 471 | margin: auto; 472 | width: 100%; 473 | text-align: center 474 | } 475 | 476 | .insert-btn-txt { 477 | float: right; 478 | padding: 4px 4px 4px 8px; 479 | vertical-align: middle; 480 | display: flex; 481 | align-items: center; 482 | color: #7a8084; 483 | cursor: pointer; 484 | right: 50%; 485 | font-size: var(--font13); 486 | font-weight: 600 487 | } 488 | 489 | .insert-btn-txt:hover { 490 | background: rgba(208, 214, 217, .05); 491 | border-radius: 3px; 492 | color: #fff 493 | } 494 | 495 | pre code.hljs { 496 | display: block; 497 | overflow-x: hidden; 498 | background: #212224; 499 | border-radius: 0 0 4px 4px; 500 | padding: 12px; 501 | margin: 0; 502 | font-size: var(--font13) 503 | } 504 | 505 | pre code.hljs:hover { 506 | overflow-x: overlay 507 | } 508 | 509 | pre { 510 | margin-top: 0 !important; 511 | margin-bottom: 0rem !important 512 | } 513 | 514 | .outputDivPreblock { 515 | overflow-x: hidden 516 | } 517 | 518 | .operations { 519 | align-items: center; 520 | display: flex; 521 | justify-content: flex-end; 522 | background: #171818; 523 | height: 32px; 524 | border-radius: 4px 4px 0 0 525 | } 526 | 527 | #main-div-aichat { 528 | margin: 0; 529 | padding: 5px 530 | } 531 | 532 | #questioninput { 533 | overflow: hidden; 534 | border-bottom: none !important 535 | } 536 | 537 | @media (max-width: 250px) { 538 | .footerContent { 539 | width: 99%; 540 | position: absolute; 541 | bottom: 0; 542 | left: 0; 543 | max-width: 100%; 544 | margin-bottom: 8px 545 | } 546 | 547 | #questioninput { 548 | overflow: auto !important 549 | } 550 | } 551 | 552 | .preCodeBlockText { 553 | font-size: var(--font13); 554 | line-height: 22.5px; 555 | color: #fff; 556 | margin-bottom: 8px; 557 | padding-left: 6px 558 | } 559 | 560 | .outputDivPreblock { 561 | overflow-x: hidden; 562 | white-space: normal; 563 | margin: 0 !important 564 | } 565 | 566 | .ant-tooltip { 567 | font-size: var(--font13) !important 568 | } 569 | 570 | .ai-parent-div:focus { 571 | border: 1px solid blue 572 | } 573 | 574 | .active { 575 | border: 1px solid #007acc; 576 | border-bottom: .5px solid #007acc !important 577 | } 578 | 579 | .diffBtns:hover { 580 | background-color: transparent !important 581 | } 582 | 583 | .rejectDiffBtn { 584 | border-color: #f14c4c; 585 | color: #f14c4c; 586 | margin-right: 6px; 587 | font-family: Public Sans 588 | } 589 | 590 | .acceptDiffBtn { 591 | border-color: #69bf13; 592 | color: #69bf13; 593 | margin-right: 6px; 594 | font-family: Public Sans 595 | } 596 | 597 | .diffBtn { 598 | margin-right: 5px; 599 | padding: 4px; 600 | vertical-align: middle; 601 | display: flex; 602 | align-items: center; 603 | color: #7a8084; 604 | cursor: pointer; 605 | right: 50%; 606 | font-size: var(--font13); 607 | font-weight: 600; 608 | float: right 609 | } 610 | 611 | .edit-btn { 612 | float: right; 613 | padding: 2px 4px 4px 8px; 614 | margin-right: 0px; 615 | cursor: pointer 616 | } 617 | 618 | .edit-btn:hover { 619 | background: rgba(208, 214, 217, .05); 620 | border-radius: 3px 621 | } 622 | 623 | a.redo { 624 | float: left; 625 | position: relative; 626 | line-height: 18px; 627 | text-align: center; 628 | width: 31px; 629 | height: 31px; 630 | border-bottom-right-radius: 2px; 631 | cursor: pointer 632 | } 633 | 634 | .redoBtn { 635 | width: -moz-fit-content; 636 | width: fit-content; 637 | padding: 0 10px; 638 | display: flex; 639 | align-items: center; 640 | justify-content: center; 641 | height: 100% 642 | } 643 | 644 | .redoBtn:hover { 645 | cursor: pointer; 646 | background-color: #d0d6d90d 647 | } 648 | 649 | .ai-parent-div, 650 | .footerContent { 651 | min-width: 250px 652 | } 653 | 654 | .questionDiv .linki { 655 | color: #fff !important; 656 | text-decoration: underline !important 657 | } 658 | 659 | .like-btn { 660 | padding: 4px 4px 4px 8px; 661 | vertical-align: middle; 662 | display: flex; 663 | align-items: center; 664 | color: #7a8084; 665 | cursor: pointer 666 | } 667 | 668 | .like-btn:hover path { 669 | border-radius: 3px; 670 | background: #7A8084 671 | } 672 | 673 | .dislike-btn { 674 | padding: 4px 4px 4px 8px; 675 | vertical-align: middle; 676 | display: flex; 677 | align-items: center; 678 | color: #7a8084; 679 | cursor: pointer 680 | } 681 | 682 | .dislike-btn:hover path { 683 | border-radius: 3px; 684 | fill: #7a8084 685 | } 686 | 687 | .feedBackControl { 688 | height: 24px 689 | } 690 | 691 | @media (max-width: 270px) { 692 | .feedBackControl { 693 | height: auto 694 | } 695 | } 696 | 697 | .tzs-stop-streaming-button-section { 698 | position: fixed; 699 | left: 50%; 700 | transform: translate(-50%); 701 | border-radius: 2px; 702 | z-index: 10; 703 | margin-top: -30px 704 | } 705 | 706 | .tzs-stop-streaming-button-section .btn-black-streaming { 707 | background: #595D60; 708 | border: 1px solid #7A8084; 709 | color: #fff; 710 | padding: 8px 16px; 711 | font-size: 12px; 712 | line-height: 18px; 713 | text-align: center; 714 | font-weight: 400; 715 | width: 120px; 716 | } 717 | 718 | @media (max-width: 250px) { 719 | .tzs-stop-streaming-button-section { 720 | margin-top: -45px 721 | } 722 | } 723 | 724 | .session-buttons { 725 | display: flex; 726 | justify-content: center; 727 | align-items: center 728 | } 729 | 730 | .session-buttons .icon-container { 731 | padding: 4px; 732 | margin-left: 10px 733 | } 734 | 735 | .ai-chat-header-share .sharebutton img { 736 | width: 16px !important; 737 | height: 17.78px !important 738 | } 739 | 740 | .session-buttons .icon-container .delete-icon { 741 | width: 17.5px; 742 | height: 16.5px 743 | } 744 | 745 | .session-buttons .icon-container .share-icon { 746 | width: 16px; 747 | height: 17.78px 748 | } 749 | 750 | .session-buttons .icon-container:hover, 751 | .session-buttons .icon-container:hover { 752 | cursor: pointer; 753 | background-color: #d0d6d90d 754 | } 755 | 756 | .add-session-icon .add-session-btn { 757 | height: 32px; 758 | width: 32px; 759 | background: #007ACC; 760 | border-radius: 3px; 761 | display: flex; 762 | justify-content: center; 763 | align-items: center 764 | } 765 | 766 | .add-session-icon .add-session-btn .plus-icon { 767 | font-size: 32px; 768 | color: #fff 769 | } 770 | 771 | .add-session-icon .add-session-btn:hover { 772 | cursor: pointer 773 | } 774 | -------------------------------------------------------------------------------- /media/styles/styles.c116.css: -------------------------------------------------------------------------------- 1 | [_ngcontent-uim-c116]:root { 2 | --font13: 13px; 3 | --font10: calc(var(--font13) - 3px); 4 | --font11: calc(var(--font13) - 2px); 5 | --font12: calc(var(--font13) - 1px); 6 | --font14: calc(var(--font13) + 1px); 7 | --font15: calc(var(--font13) + 2px); 8 | --font16: calc(var(--font13) + 3px); 9 | --font17: calc(var(--font13) + 4px); 10 | --font18: calc(var(--font13) + 5px); 11 | --font19: calc(var(--font13) + 6px); 12 | --font20: calc(var(--font13) + 7px); 13 | --minHeightAI: 40px 14 | } 15 | 16 | .links[_ngcontent-uim-c116]:hover { 17 | background-color: #2c4880; 18 | color: #fff !important 19 | } 20 | 21 | a[_ngcontent-uim-c116]:active { 22 | background: #2f3133; 23 | color: #fff !important 24 | } 25 | 26 | .contactUs[_ngcontent-uim-c116] { 27 | color: #53a9f8 !important; 28 | font-size: var(--font14) !important; 29 | text-decoration: underline !important 30 | } 31 | 32 | .contactUs[_ngcontent-uim-c116]:hover { 33 | color: #fff 34 | } 35 | 36 | .active[_ngcontent-uim-c116] { 37 | background: #2f3133; 38 | color: #fff !important 39 | } 40 | 41 | .user-mention[_ngcontent-uim-c116] { 42 | width: 50%; 43 | max-width: 50%; 44 | height: auto; 45 | max-height: 400px; 46 | border: none; 47 | border-radius: 4px; 48 | background: #44484a; 49 | overflow: auto; 50 | color: #c4c9cc; 51 | top: 25px; 52 | position: absolute; 53 | right: 10px 54 | } 55 | 56 | .user-mention[_ngcontent-uim-c116] .listing[_ngcontent-uim-c116] { 57 | word-break: break-all; 58 | padding: 3%; 59 | font-size: var(--font13); 60 | font-weight: 400; 61 | border-bottom: 1px solid #565656 62 | } 63 | 64 | .user-mention[_ngcontent-uim-c116] .listing[_ngcontent-uim-c116]:hover { 65 | background: #007bff; 66 | color: #fff; 67 | cursor: pointer 68 | } 69 | 70 | .user-mention[_ngcontent-uim-c116] .listing[_ngcontent-uim-c116]:hover a[_ngcontent-uim-c116] { 71 | color: #fff; 72 | text-decoration: underline 73 | } 74 | 75 | .user-mention[_ngcontent-uim-c116] .listing[_ngcontent-uim-c116]:hover .contactUs[_ngcontent-uim-c116] { 76 | color: #fff !important; 77 | text-decoration: underline 78 | } 79 | 80 | .links[_ngcontent-uim-c116] { 81 | padding: .5rem !important; 82 | position: relative !important; 83 | height: 100% 84 | } 85 | 86 | .namesBox[_ngcontent-uim-c116] { 87 | width: 32px; 88 | height: 32px; 89 | position: static; 90 | float: left; 91 | color: #fff; 92 | border-radius: 2px; 93 | display: flex; 94 | align-items: center; 95 | justify-content: center; 96 | margin-right: 4px; 97 | margin-left: 3px; 98 | font-size: var(--font13); 99 | border: 3px solid #80808073 100 | } 101 | 102 | .feed[_ngcontent-uim-c116] { 103 | padding: .5rem !important; 104 | position: relative !important 105 | } 106 | 107 | .feed[_ngcontent-uim-c116]:hover { 108 | background-color: #2f3133; 109 | color: #fff !important; 110 | text-decoration: none !important 111 | } 112 | 113 | .feed[_ngcontent-uim-c116] { 114 | color: #fff; 115 | display: flex; 116 | flex-direction: row; 117 | justify-content: start; 118 | align-items: center; 119 | padding: 4px 8px; 120 | width: 100%; 121 | height: 40px 122 | } 123 | 124 | @media (max-width: 250px) { 125 | .feed[_ngcontent-uim-c116] span.hd-low-res[_ngcontent-uim-c116] { 126 | display: none 127 | } 128 | } 129 | 130 | .tooltipforWorkSpaceName[_ngcontent-uim-c116] { 131 | display: flex; 132 | align-items: center; 133 | visibility: hidden; 134 | background-color: #000; 135 | color: #fff; 136 | text-align: center; 137 | border-radius: 3px; 138 | position: absolute; 139 | z-index: 5; 140 | height: 30px; 141 | opacity: 0; 142 | margin-left: 42px; 143 | padding: 10px; 144 | transition: opacity .3s; 145 | top: 5px; 146 | font-size: var(--font12) 147 | } 148 | 149 | .home[_ngcontent-uim-c116]:hover .tooltipforWorkSpaceName[_ngcontent-uim-c116] { 150 | visibility: visible; 151 | opacity: 1; 152 | display: block 153 | } 154 | 155 | .modal-dialog[_ngcontent-uim-c116] { 156 | position: absolute; 157 | width: auto; 158 | margin: 0 !important; 159 | pointer-events: none; 160 | bottom: 40px; 161 | width: 100%; 162 | border-radius: 0 163 | } 164 | 165 | .modal-dialog[_ngcontent-uim-c116] { 166 | max-width: 100%; 167 | margin: 1.75rem auto 168 | } 169 | 170 | .modal-content[_ngcontent-uim-c116] { 171 | position: relative; 172 | display: flex; 173 | flex-direction: column; 174 | width: 100%; 175 | pointer-events: auto; 176 | background-clip: padding-box; 177 | border: 1px solid rgba(0, 0, 0, .2); 178 | border-radius: 0; 179 | outline: 0; 180 | color: #fff; 181 | background-color: #2f3133 182 | } 183 | 184 | .modal-header[_ngcontent-uim-c116] { 185 | padding: 1rem .8rem !important 186 | } 187 | 188 | .modal-body[_ngcontent-uim-c116] { 189 | padding: 0rem .8rem 190 | } 191 | 192 | .modal-title[_ngcontent-uim-c116] { 193 | font-family: Public Sans; 194 | font-style: normal; 195 | font-weight: 600; 196 | font-size: var(--font18); 197 | line-height: 150% 198 | } 199 | 200 | .modal-Parent[_ngcontent-uim-c116] { 201 | width: 100%; 202 | position: fixed; 203 | bottom: 0; 204 | z-index: 1041; 205 | left: 0 206 | } 207 | 208 | @media only screen and (min-width: 450px) { 209 | .usr-profile.user-mention[_ngcontent-uim-c116] { 210 | width: 250px; 211 | max-width: 250px 212 | } 213 | } 214 | 215 | @media only screen and (max-width: 276px) { 216 | app-loggedin-header[_ngcontent-uim-c116] .user-mention[_ngcontent-uim-c116] { 217 | width: 75%; 218 | max-width: 75% 219 | } 220 | } 221 | 222 | .listing[_ngcontent-uim-c116] img[_ngcontent-uim-c116] { 223 | margin-right: 5px 224 | } 225 | 226 | .open-file-sect[_ngcontent-uim-c116] { 227 | white-space: nowrap; 228 | text-overflow: ellipsis; 229 | overflow: hidden; 230 | width: calc(95vw - 170px) 231 | } 232 | 233 | .options-container[_ngcontent-uim-c116], 234 | #settings-option[_ngcontent-uim-c116] { 235 | height: 100% 236 | } -------------------------------------------------------------------------------- /media/styles/styles.c117.css: -------------------------------------------------------------------------------- 1 | [_ngcontent-uim-c117]:root { 2 | --font13: 13px; 3 | --font10: calc(var(--font13) - 3px); 4 | --font11: calc(var(--font13) - 2px); 5 | --font12: calc(var(--font13) - 1px); 6 | --font14: calc(var(--font13) + 1px); 7 | --font15: calc(var(--font13) + 2px); 8 | --font16: calc(var(--font13) + 3px); 9 | --font17: calc(var(--font13) + 4px); 10 | --font18: calc(var(--font13) + 5px); 11 | --font19: calc(var(--font13) + 6px); 12 | --font20: calc(var(--font13) + 7px); 13 | --minHeightAI: 40px 14 | } 15 | 16 | .loading-spinner[_ngcontent-uim-c117] { 17 | background-color: #aaa6a61f; 18 | position: absolute; 19 | width: 100%; 20 | top: 0; 21 | left: 0; 22 | height: 100vh; 23 | align-items: center; 24 | justify-content: center; 25 | display: grid; 26 | z-index: 3002; 27 | opacity: 9999 28 | } 29 | 30 | .force-loadin-ide-spinner[_ngcontent-uim-c117] .loading-spinner[_ngcontent-uim-c117] { 31 | z-index: 3005; 32 | background-color: #000 33 | } 34 | 35 | .force-loadin-ide-spinner[_ngcontent-uim-c117] .loader-text[_ngcontent-uim-c117] { 36 | color: #fff; 37 | font-size: var(--font20); 38 | position: fixed; 39 | top: 55%; 40 | z-index: 3003; 41 | margin: auto; 42 | width: 100%; 43 | text-align: center 44 | } 45 | 46 | -------------------------------------------------------------------------------- /media/styles/styles.c48.css: -------------------------------------------------------------------------------- 1 | [_ngcontent-uim-c48]:root { 2 | --font13: 13px; 3 | --font10: calc(var(--font13) - 3px); 4 | --font11: calc(var(--font13) - 2px); 5 | --font12: calc(var(--font13) - 1px); 6 | --font14: calc(var(--font13) + 1px); 7 | --font15: calc(var(--font13) + 2px); 8 | --font16: calc(var(--font13) + 3px); 9 | --font17: calc(var(--font13) + 4px); 10 | --font18: calc(var(--font13) + 5px); 11 | --font19: calc(var(--font13) + 6px); 12 | --font20: calc(var(--font13) + 7px); 13 | --minHeightAI: 40px 14 | } 15 | 16 | .header[_ngcontent-uim-c48] { 17 | width: 100%; 18 | height: 48px; 19 | line-height: 48px; 20 | border-bottom: 1px solid #44484A; 21 | font-family: Public Sans, sans-serif !important; 22 | font-size: var(--font15); 23 | font-style: normal; 24 | font-weight: 600; 25 | letter-spacing: 0em; 26 | text-align: left; 27 | color: #7a8084; 28 | left: 15px; 29 | top: 0; 30 | background-color: #2f3133; 31 | z-index: 1500 32 | } 33 | 34 | .signInBtn[_ngcontent-uim-c48] { 35 | background-color: #1f98e9 !important; 36 | color: #fff !important 37 | } 38 | 39 | .signInBtn[_ngcontent-uim-c48] a[_ngcontent-uim-c48] { 40 | color: #fff !important 41 | } 42 | 43 | .welcome-wrapper[_ngcontent-uim-c48] { 44 | height: 100vh; 45 | overflow: auto; 46 | padding-bottom: 15px; 47 | padding-top: 15vh; 48 | width: 100vw; 49 | max-width: 100vw 50 | } 51 | 52 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "codeshell-vscode", 3 | "displayName": "CodeShell VSCode Extension", 4 | "description": "Coding with CodeShell LLM", 5 | "publisher": "WisdomShell", 6 | "version": "0.1.1", 7 | "icon": "assets/logo.png", 8 | "keywords": [ 9 | "code-suggestion", 10 | "code-completion", 11 | "code-inference" 12 | ], 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/WisdomShell/codeshell-vscode.git" 16 | }, 17 | "engines": { 18 | "vscode": "^1.68.1" 19 | }, 20 | "categories": [ 21 | "Programming Languages", 22 | "Machine Learning" 23 | ], 24 | "activationEvents": [ 25 | "onStartupFinished" 26 | ], 27 | "main": "./dist/extension.js", 28 | "l10n": "./l10n", 29 | "contributes": { 30 | "configuration": { 31 | "title": "CodeShell", 32 | "properties": { 33 | "CodeShell.ServerAddress": { 34 | "description": "The address of the CodeShell server to connect to.", 35 | "default": "http://127.0.0.1:8080", 36 | "type": "string", 37 | "order": 1 38 | }, 39 | "CodeShell.RunEnvForLLMs": { 40 | "description": "The environment that should be used for running LLMs.", 41 | "default": "CPU with llama.cpp", 42 | "enum": [ 43 | "CPU with llama.cpp", 44 | "GPU with TGI toolkit" 45 | ], 46 | "type": "string", 47 | "order": 2 48 | }, 49 | "CodeShell.AutoTriggerCompletion": { 50 | "description": "Whether or not to automatically trigger completion when typing.", 51 | "default": true, 52 | "type": "boolean", 53 | "order": 6 54 | }, 55 | "CodeShell.AutoCompletionDelay": { 56 | "description": "The delay in seconds before automatic code completion triggers.", 57 | "type": "number", 58 | "enum": [ 59 | 1, 60 | 2, 61 | 3 62 | ], 63 | "default": 1, 64 | "order": 7 65 | }, 66 | "CodeShell.CompletionMaxTokens": { 67 | "description": "Maximum number of tokens for which suggestions will be displayed", 68 | "type": "number", 69 | "enum": [ 70 | 64, 71 | 128, 72 | 256, 73 | 512, 74 | 1024 75 | ], 76 | "default": 64, 77 | "order": 8 78 | }, 79 | "CodeShell.ChatMaxTokens": { 80 | "description": "Maximum number of tokens for which chat messages will be displayed", 81 | "type": "number", 82 | "enum": [ 83 | 1024, 84 | 2048, 85 | 4096, 86 | 8192 87 | ], 88 | "default": 2048, 89 | "order": 9 90 | } 91 | } 92 | }, 93 | "keybindings": [ 94 | { 95 | "key": "alt+\\", 96 | "mac": "alt+\\", 97 | "command": "editor.action.inlineSuggest.trigger", 98 | "when": "editorTextFocus" 99 | } 100 | ], 101 | "commands": [ 102 | { 103 | "command": "codeshell.auto_completion_enable", 104 | "title": "%codeshell.auto_completion_enable.title%", 105 | "category": "codeshell" 106 | }, 107 | { 108 | "command": "codeshell.auto_completion_disable", 109 | "title": "%codeshell.auto_completion_disable.title%", 110 | "category": "codeshell" 111 | }, 112 | { 113 | "command": "codeshell.explain_this_code", 114 | "title": "%codeshell.explain_this_code.title%", 115 | "category": "codeshell" 116 | }, 117 | { 118 | "command": "codeshell.improve_this_code", 119 | "title": "%codeshell.improve_this_code.title%", 120 | "category": "codeshell" 121 | }, 122 | { 123 | "command": "codeshell.clean_this_code", 124 | "title": "%codeshell.clean_this_code.title%", 125 | "category": "codeshell" 126 | }, 127 | { 128 | "command": "codeshell.generate_comment", 129 | "title": "%codeshell.generate_comment.title%", 130 | "category": "codeshell" 131 | }, 132 | { 133 | "command": "codeshell.generate_unit_test", 134 | "title": "%codeshell.generate_unit_test.title%", 135 | "category": "codeshell" 136 | }, 137 | { 138 | "command": "codeshell.check_performance", 139 | "title": "%codeshell.check_performance.title%", 140 | "category": "codeshell" 141 | }, 142 | { 143 | "command": "codeshell.check_security", 144 | "title": "%codeshell.check_security.title%", 145 | "category": "codeshell" 146 | } 147 | ], 148 | "submenus": [ 149 | { 150 | "id": "codeshell_context_submenu", 151 | "label": "CodeShell" 152 | } 153 | ], 154 | "menus": { 155 | "editor/context": [ 156 | { 157 | "submenu": "codeshell_context_submenu", 158 | "group": "navigation" 159 | } 160 | ], 161 | "codeshell_context_submenu": [ 162 | { 163 | "command": "codeshell.auto_completion_enable", 164 | "group": "group1@1", 165 | "when": "!config.CodeShell.AutoTriggerCompletion" 166 | }, 167 | { 168 | "command": "codeshell.auto_completion_disable", 169 | "group": "group1@2", 170 | "when": "config.CodeShell.AutoTriggerCompletion" 171 | }, 172 | { 173 | "command": "codeshell.explain_this_code", 174 | "group": "group2@1", 175 | "when": "editorHasSelection" 176 | }, 177 | { 178 | "command": "codeshell.improve_this_code", 179 | "group": "group2@2", 180 | "when": "editorHasSelection" 181 | }, 182 | { 183 | "command": "codeshell.clean_this_code", 184 | "group": "group2@3", 185 | "when": "editorHasSelection" 186 | }, 187 | { 188 | "command": "codeshell.generate_comment", 189 | "group": "group3@1", 190 | "when": "editorHasSelection" 191 | }, 192 | { 193 | "command": "codeshell.generate_unit_test", 194 | "group": "group3@2", 195 | "when": "editorHasSelection" 196 | }, 197 | { 198 | "command": "codeshell.check_performance", 199 | "group": "group4@1", 200 | "when": "editorHasSelection" 201 | }, 202 | { 203 | "command": "codeshell.check_security", 204 | "group": "group4@2", 205 | "when": "editorHasSelection" 206 | } 207 | ] 208 | }, 209 | "viewsContainers": { 210 | "activitybar": [ 211 | { 212 | "id": "codeshell_sidebar", 213 | "title": "CodeShell", 214 | "icon": "assets/logo.svg" 215 | } 216 | ] 217 | }, 218 | "views": { 219 | "codeshell_sidebar": [ 220 | { 221 | "id": "codeshell.chatView", 222 | "name": "CodeShell", 223 | "type": "webview" 224 | } 225 | ] 226 | } 227 | }, 228 | "scripts": { 229 | "vscode:prepublish": "npm run package", 230 | "compile": "webpack", 231 | "watch": "webpack --watch", 232 | "package": "webpack --mode production --devtool hidden-source-map", 233 | "compile-tests": "tsc -p . --outDir out", 234 | "watch-tests": "tsc -p . -w --outDir out", 235 | "pretest": "npm run compile-tests && npm run compile && npm run lint", 236 | "lint": "eslint src --ext ts", 237 | "test": "node ./out/test/runTest.js" 238 | }, 239 | "devDependencies": { 240 | "@types/glob": "^8.1.0", 241 | "@types/mocha": "^10.0.1", 242 | "@types/node": "^18.18.5", 243 | "@types/vscode": "^1.68.1", 244 | "@typescript-eslint/eslint-plugin": "^5.59.8", 245 | "@typescript-eslint/parser": "^5.59.8", 246 | "@vscode/l10n-dev": "^0.0.18", 247 | "@vscode/test-electron": "^2.3.2", 248 | "@vscode/vsce": "^2.26.0", 249 | "eslint": "^8.41.0", 250 | "glob": "^8.1.0", 251 | "mocha": "^10.2.0", 252 | "ts-loader": "^9.4.3", 253 | "typescript": "^5.1.3", 254 | "webpack": "^5.85.0", 255 | "webpack-cli": "^5.1.1" 256 | }, 257 | "dependencies": { 258 | "@vscode/l10n": "^0.0.10", 259 | "eventsource-parser": "^1.1.1", 260 | "node-fetch": "^3.3.2", 261 | "openai": "^3.1.0" 262 | } 263 | } 264 | -------------------------------------------------------------------------------- /package.nls.json: -------------------------------------------------------------------------------- 1 | { 2 | "codeshell.auto_completion_enable.title": "Enable Auto Completion", 3 | "codeshell.auto_completion_disable.title": "Disable Auto Completion", 4 | "codeshell.explain_this_code.title": "Explain Selected Codes", 5 | "codeshell.improve_this_code.title": "Optimize Selected Codes", 6 | "codeshell.clean_this_code.title": "Clean Selected Codes", 7 | "codeshell.generate_comment.title": "Generate Comment", 8 | "codeshell.generate_unit_test.title": "Generate Unit Test", 9 | "codeshell.check_performance.title": "Check Performance", 10 | "codeshell.check_security.title": "Check Security" 11 | } -------------------------------------------------------------------------------- /package.nls.zh-cn.json: -------------------------------------------------------------------------------- 1 | { 2 | "codeshell.auto_completion_enable.title": "启用 自动触发补全", 3 | "codeshell.auto_completion_disable.title": "停用 自动触发补全", 4 | "codeshell.explain_this_code.title": "解释 这段代码", 5 | "codeshell.improve_this_code.title": "优化 这段代码", 6 | "codeshell.clean_this_code.title": "清理 这段代码", 7 | "codeshell.generate_comment.title": "生成 注释", 8 | "codeshell.generate_unit_test.title": "生成 单元测试", 9 | "codeshell.check_performance.title": "检查 性能问题", 10 | "codeshell.check_security.title": "检查 安全性问题" 11 | } -------------------------------------------------------------------------------- /src/ChatMemory.ts: -------------------------------------------------------------------------------- 1 | import { ExtensionContext } from "vscode"; 2 | 3 | export class ChatMessage { 4 | prefix?: string; 5 | content: string; 6 | 7 | constructor(content: string) { 8 | this.content = content; 9 | } 10 | 11 | toString(): string { 12 | return `${this.prefix}${this.content}`; 13 | } 14 | } 15 | 16 | export class HumanMessage extends ChatMessage { 17 | prefix = "## human:"; 18 | } 19 | 20 | export class AIMessage extends ChatMessage { 21 | prefix = "## assistant:"; 22 | 23 | append(text: string) { 24 | this.content += text; 25 | this.content = this.content.replace("|end|", ""); 26 | this.content = this.content.replace("|${sessionItem.title}
229 |${sessionTime}
230 |