Skip to content

Commit 46eef91

Browse files
committedAug 23, 2023
reset history
0 parents  commit 46eef91

24 files changed

+6957
-0
lines changed
 

‎.eslintrc.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
}

‎.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
out
2+
dist
3+
node_modules
4+
.vscode-test/
5+
*.vsix

‎.vscode/extensions.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
"dbaeumer.vscode-eslint"
6+
]
7+
}

‎.vscode/launch.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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}/out/**/*.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/test/**/*.js"
30+
],
31+
"preLaunchTask": "${defaultBuildTask}"
32+
}
33+
]
34+
}

‎.vscode/settings.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
},
6+
"search.exclude": {
7+
"out": true // set this to false to include "out" folder in search results
8+
},
9+
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
10+
"typescript.tsc.autoDetect": "off"
11+
}

‎.vscode/tasks.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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": "$tsc-watch",
10+
"isBackground": true,
11+
"presentation": {
12+
"reveal": "never"
13+
},
14+
"group": {
15+
"kind": "build",
16+
"isDefault": true
17+
}
18+
}
19+
]
20+
}

‎.vscodeignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.vscode/**
2+
.vscode-test/**
3+
src/**
4+
.gitignore
5+
.yarnrc
6+
vsc-extension-quickstart.md
7+
**/tsconfig.json
8+
**/.eslintrc.json
9+
**/*.map
10+
**/*.ts

‎CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Change Log
2+
3+
All notable changes to the "azsdkchatbot" extension will be documented in this file.
4+
5+
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
6+
7+
## [Unreleased]
8+
9+
- Initial release

‎README.md

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Azure SDK Copilot Extension for VS Code (Proof-of-Concept)
2+
3+
This project provides a Visual Studio Code extension for interacting with an Azure OpenAI GPT model in a chat-style interface. It consists of a TypeScript UI and a Python backend that communicate with each other via a socket.
4+
5+
The [Python backend](https://github.com/mario-guerra/azsdkchatbot/tree/main/python#readme) implements a chat connection with Azure OpenAI models using connectors from the [Semantic Kernel SDK](https://github.com/microsoft/semantic-kernel). It's currently designed to answer questions by querying a Qdrant vector database embedded with READMEs scraped from Azure SDK GitHub repos.
6+
7+
The [TypeScript front end](https://github.com/mario-guerra/azsdkchatbot/blob/main/src/README.md) implements a VS Code webpanel with a chat interface UI that can be used to interact with the chat backend.
8+
9+
This is strictly a proof-of-concept demonstrating the use of retrieval-augmented generation (RAG) for surfacing content from our GitHub repos.
10+
11+
## Dependencies
12+
13+
### Python Backend
14+
15+
The following dependencies are required to run the Python backend:
16+
17+
1. Python 3.6 or higher
18+
2. `semantic-kernel==0.2.7.dev0`
19+
3. `qdrant-client`
20+
4. `socket`
21+
5. `re`
22+
6. `asyncio`
23+
24+
### TypeScript UI
25+
26+
The following dependencies are required to run the TypeScript UI:
27+
28+
1. Visual Studio Code
29+
2. TypeScript
30+
3. vscode
31+
4. path
32+
5. net
33+
6. child_process
34+
7. markdown-it
35+
36+
## Installation
37+
38+
### Python Backend
39+
40+
To install the dependencies for the Python backend, run the following commands:
41+
42+
```bash
43+
pip install semantic-kernel==0.2.7.dev0
44+
pip install qdrant-client
45+
```
46+
47+
### TypeScript UI
48+
49+
1. Install [Visual Studio Code](https://code.visualstudio.com/).
50+
2. Install [TypeScript](https://www.typescriptlang.org/download) globally using npm:
51+
52+
```bash
53+
npm install -g typescript
54+
```
55+
56+
3. Install the required npm packages:
57+
58+
```bash
59+
npm install vscode path net child_process markdown-it
60+
```
61+
62+
## Running the Extension
63+
64+
To run the TypeScript UI, open the extension project in Visual Studio Code and press `F5`. In the new window that loads, press `Ctrl-Shift-P` to bring up the command window. Select 'Start SDK Copilot' from the options, and the chat panel UI will be displayed, allowing you to interact with the chatbot.
65+
66+
## Overview of Functions
67+
68+
### Python Backend
69+
70+
- `create_socket()`: This function initializes a socket object, binds it to a specified address and port, and sets it to listen for incoming connections.
71+
72+
- `create_embedding(data)`: This asynchronous function generates embeddings for the given data. It includes retry logic to account for rate limit errors.
73+
74+
- `ask_chatbot(input)`: This asynchronous function generates a response to the user's question from relevant README content using the ChatGPT API.
75+
76+
- `query_qdrant(user_input, collection_name, language)`: This asynchronous function queries the Qdrant storage with the user input, collection name, and language to find relevant READMEs.
77+
78+
- `chat(user_input: str, previous_input)`: This asynchronous function processes the user input, checks for language matches, and calls the `query_qdrant()` function. It handles cases where the user input does not match any language and provides the chatbot answer at the end of each iteration.
79+
80+
- `main()`: This asynchronous function sets up the socket server, listens for incoming connections and user inputs, and calls the `chat()` function to generate responses. It sends the responses back to the VS Code extension through the socket connection.
81+
82+
### TypeScript UI
83+
84+
- `activate(context: vscode.ExtensionContext)`: This function is called when the extension is activated, and it sets up the extension's functionality.
85+
86+
- `connectToPythonScript(callback: (panel: vscode.WebviewPanel) => void, panel: vscode.WebviewPanel)`: This function connects the TypeScript UI to the Python script via a socket connection.
87+
88+
- `runPythonCode(userInput: string, panel: vscode.WebviewPanel)`: This function sends the user input to the Python script and waits for the response.
89+
90+
- `createChatPanel()`: This function creates the chat panel UI for the extension.
91+
92+
- `deactivate()`: This function is called when the extension is deactivated.
93+
94+
- `startPythonScript()`: This function starts the Python script as a child process.
95+
96+
## Usage
97+
98+
Once you have installed the dependencies and set up the extension, you can start using the ChatGPT extension for Visual Studio Code. Follow these steps to interact with the chatbot:
99+
100+
1. Open the extension project in Visual Studio Code and press `F5`. A new window will load with the extension activated.
101+
2. Press `Ctrl-Shift-P` to bring up the command window.
102+
3. Select 'Start SDK Copilot' from the options. The chat panel UI will be displayed.
103+
4. Type your questions or messages in the input field and press 'Enter' or click the 'Send' button to send them to the chatbot.
104+
5. Use '/\<language\>' triggers in your question to trigger a query into the backing Qdrant db memory store. Supported languages are: [`/rust`, `/net`, `/javascript`, `/java`]
105+
Example query: "/rust sdk for service bus"
106+
6. The chatbot will respond with relevant answers, and you can continue the conversation by asking follow-up questions or entering new queries.
107+
108+
The ChatGPT extension is designed to provide information about Azure SDKs and can answer questions based on the context provided in the prompts. It prioritizes content from the prompts and falls back on its own knowledge only when there is no relevant information in the prompt. The chatbot provides concise and clear answers, formatted using markdown syntax for better readability.

0 commit comments

Comments
 (0)
Please sign in to comment.