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.
The Python backend implements a chat connection with Azure OpenAI models using connectors from the Semantic Kernel SDK. It's currently designed to answer questions by querying a Qdrant vector database embedded with READMEs scraped from Azure SDK GitHub repos.
The TypeScript front end implements a VS Code webpanel with a chat interface UI that can be used to interact with the chat backend.
This is strictly a proof-of-concept demonstrating the use of retrieval-augmented generation (RAG) for surfacing content from our GitHub repos.
The following dependencies are required to run the Python backend:
- Python 3.6 or higher
semantic-kernel==0.2.7.dev0
qdrant-client
socket
re
asyncio
The following dependencies are required to run the TypeScript UI:
- Visual Studio Code
- TypeScript
- vscode
- path
- net
- child_process
- markdown-it
To install the dependencies for the Python backend, run the following commands:
pip install semantic-kernel==0.2.7.dev0
pip install qdrant-client
- Install Visual Studio Code.
- Install TypeScript globally using npm:
npm install -g typescript
- Install the required npm packages:
npm install vscode path net child_process markdown-it
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.
-
create_socket()
: This function initializes a socket object, binds it to a specified address and port, and sets it to listen for incoming connections. -
create_embedding(data)
: This asynchronous function generates embeddings for the given data. It includes retry logic to account for rate limit errors. -
ask_chatbot(input)
: This asynchronous function generates a response to the user's question from relevant README content using the ChatGPT API. -
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. -
chat(user_input: str, previous_input)
: This asynchronous function processes the user input, checks for language matches, and calls thequery_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. -
main()
: This asynchronous function sets up the socket server, listens for incoming connections and user inputs, and calls thechat()
function to generate responses. It sends the responses back to the VS Code extension through the socket connection.
-
activate(context: vscode.ExtensionContext)
: This function is called when the extension is activated, and it sets up the extension's functionality. -
connectToPythonScript(callback: (panel: vscode.WebviewPanel) => void, panel: vscode.WebviewPanel)
: This function connects the TypeScript UI to the Python script via a socket connection. -
runPythonCode(userInput: string, panel: vscode.WebviewPanel)
: This function sends the user input to the Python script and waits for the response. -
createChatPanel()
: This function creates the chat panel UI for the extension. -
deactivate()
: This function is called when the extension is deactivated. -
startPythonScript()
: This function starts the Python script as a child process.
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:
- Open the extension project in Visual Studio Code and press
F5
. A new window will load with the extension activated. - Press
Ctrl-Shift-P
to bring up the command window. - Select 'Start SDK Copilot' from the options. The chat panel UI will be displayed.
- Type your questions or messages in the input field and press 'Enter' or click the 'Send' button to send them to the chatbot.
- Use '/<language>' triggers in your question to trigger a query into the backing Qdrant db memory store. Supported languages are: [
/rust
,/net
,/javascript
,/java
] Example query: "/rust sdk for service bus" - The chatbot will respond with relevant answers, and you can continue the conversation by asking follow-up questions or entering new queries.
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.