Nowadays, there are a lot of Gen AI tools that promise to accelerate your software development. But, most of them offer generic and often unreliable code suggestions. That’s why we are thrilled to introduce you to StackSpot AI tutorial, our context-aware Code Assistant.
This blog post aims to introduce you to the fundamental concepts of StackSpot AI so that you can fully leverage our solution and boost your productivity, considering your working context.
The problem: Lack of context in Code Assistants regarding the company
Every time we work at a company, we need to respect the company’s code preferences. In this context, there are guidelines that developers must follow when writing code for a feature. Will generic code assistants think and use this? What if there’s a documentation standard, will a generic code assistant consider that?
Another common situation within increasingly complex software is that it becomes challenging to know what’s already implemented and ready for reuse. The biggest challenge in reuse isn’t necessarily from the perspective of the developer reusing something they’ve previously written but instead reusing what someone else within the company has already done. Does a Domain Service already exist that provides certain logic? Is there already an endpoint in a microservice that performs a specific operation? How can we find out?
Facilitating access to existing information is essential to reduce the chance of rework, accelerate the implementation of requirements that can be built on what already exists, speed up onboarding, and more.
An excellent documentation tends to be the key
The standard approach to making existing knowledge within software accessible to the widest possible audience is to believe in excellent documentation. This is already widely used by successful open-source projects because, after all, new teams start using them every day around the world. When your team decides to use an open-source library or framework, where do they go? To the documentation!
Companies try to follow the same path by creating internal wikis using various tools. When they exist and are well-maintained, you can find code guidelines, a history of solutions to problems that occurred, links to API descriptions, and more.
Excellent documentation is very helpful, but we still face the challenge of developers switching contexts to access information. Moreover, finding what you’re looking for when you need it takes a lot of work. The context-switching and the problems in finding information often make users think the data doesn’t exist. As we discussed earlier, this decreases the possibility of knowledge reuse.
What if all this contextualized knowledge were accessible from your IDE? Let’s go further. What if it were accessible directly from your IDE but with your team’s specific technology stack?
StackSpot AI: Your Ultra-Contextualized Code Assistant
StackSpot AI is our solution to ensure your company’s software-related knowledge becomes accessible to the developers. In an open chat within the IDE, any developer can “talk” with the knowledge relevant to their context, already connected to the specific technology stack in use.
Now, we’ll see a step-by-step tutorial on how to start using StackSpot AI and examples of how our solution can help you and your team.
Accessing StackSpot AI and Understanding the Fundamental Concepts
Accessing our website and register
The first step is to navigate to our website (this is the access link) and complete your registration. You can register using your GitHub account.
On the page, you will find the login button, which is currently located in the upper right corner.
Installing our plugin in your Visual Studio Code
Right after you log in, you will see our welcome screen. There, you will find several links, but please focus on the link to install our plugin in your IDE. Currently, we support Visual Studio Code and plan to roll out support for other IDEs soon.
When you click on the Visual Studio Code icon, the installation file for our plugin will be downloaded. It has the .vsix extension. To install the plugin, please follow these steps:
- Go to the Visual Studio Code extensions menu, located on the screen’s left side.
- Inside the extensions screen, you will see a menu at the top. Look for the three dots.
- When you click on this menu, you will find the option to install via VSIX.
Find more details on the official StackSpot AI documentation.
Understanding the Concept of Knowledge Source
We’ve discussed the challenge of developers needing to switch contexts to check existing documentation for the necessary information to implement a particular feature or module. The goal here is to bring all this knowledge into the developer’s IDE so that it’s easily searchable through our chat interface. This is where the concept of Knowledge Source in StackSpot AI comes in.
As the name suggests, we can create sources of knowledge within StackSpot AI. Currently, we support two types of knowledge sources:
- JSON files with API descriptions following the OpenAPI specification.
- A set of code snippets referred to as a Snippets Group.
Over time, we should support various types of sources. For example, mining your company’s code repositories and extracting code snippets that exhibit best practices. We’ll also support scanning your wiki to bring in documented knowledge and their respective use cases, making it accessible within the StackSpot AI chat.
Now, let’s go through a file registration process following the OpenAPI specification
Imagine you want to streamline the development of a system on top of the OpenAI API. When accessing the OpenAI documentation, you want to ask about it directly through our code assistant. The first step is to download the file describing the API. You can download it from the OpenAI GitHub repository.
Now, we need to register this API as a Knowledge Source. To do this, let’s follow a step-by-step process:
The first step is to click on “Code Buddy” within our platform. You can find it on the left side.
You’ll see the option to register Knowledge Sources on the left side. Now, just click on the plus (+) icon.
Now choose the API option. Once selected, the following screen should be displayed:
Choose a name for your Knowledge Source, for example, “OpenAI API.” It’s also important to provide a description explaining the purpose of this Knowledge Source. When you click “Next,” the screen to upload your OpenAPI file will appear.
Once the upload is completed, you will have access to the items that were registered based on the API description.
When you request to expand one of them, you’ll notice that StackSpot AI has processed them during registration to make the information more suitable for the content indexing process.
There you go! At this point, you’ve registered your first Knowledge Source. Feel free to register as many as you need. You can also register OpenAPI files that your company may have!
Now, let’s go through a workflow for registering a Snippet Group type of Knowledge Source.
This format is more suitable for sharing code guidelines, algorithms, and similar information. The initial workflow is exactly the same. However, instead of creating an API, you’ll click to create a Snippet Group. The first screen that appears will also be the same.
Give your Snippet Group a name and provide a description explaining its purpose. After that click “Next,” the following screen should appear:
Now, you can add as many snippets as you need. When you click “Add Snippet,” you can choose a programming language associated with the snippet, add the code snippet itself, and provide a use case for it. Everything here is indexed for searchability through our chat. So, we suggest following best practices and being very specific.
Now, let’s take a look at our snippet example:
Here, we have a snippet that should help the developer follow the company’s guidelines regarding returning null values in Java code.
Now, let’s get to know the Stack AI concept
To make Knowledge Sources truly powerful, we need to connect them with the technology stack used by a specific team. For example, imagine you want to access the audio transcription functionality of OpenAI. You want a code example tailored to your preferred language and library.
We’ll be able to connect these two elements while creating a Workspace, but before that, we need to add the stack concept. This is why the concept of Studios and Stack AIs exists.
In StackSpot AI, a Studio gathers various definitions of stacks that are related to each other, for example, Stacks based on Spring. The level of granularity is up to you, and organizing by framework seems like an interesting approach.
To create a new Studio, you’ll use the “create” button in the platform’s upper right corner.
After clicking, you will see the screen to create a new Studio. Add a name and a description.
You can access any Studio you create from the “Studios” menu on the left side of the screen.
Now, within the Studio, let’s add our first Stack AI. Stack AI is necessary to provide context about the technologies that should be prioritized when the StackSpot AI chat suggests code for you.
When you click on the button to add a new Stack AI, the following screen appears:
The first step is to define a name and a use case. The use case needs to have a specific description of scenarios where the technologies suggested by Stack AI would be more suitable.
Next, you need to define the characteristics of your Stack AI. See an example:
We have defined the programming language, base framework, testing framework, pattern suggestions, and dependencies. Here, you are creating a work context possibility.
Now, let’s move on to the step where we provide context on the preferred cloud option within this Stack.
In the example, we’ve chosen AWS as the cloud provider. We added some modules necessary to use within the Stack AI context. This step is entirely optional. The next step is to review, and if everything is correct, we can create our first Stack AI.
Workspaces: Connecting Knowledge Sources with Stack AI
Your company can have multiple Knowledge Sources and many Studios with Stack AIs. However, not every project will need access to all combinations at the same time. This is where the concept of Workspaces comes in.
A Workspace within StackSpot AI is where you connect Knowledge Sources with Stack AIs. This way, code suggestions based on Knowledge Sources consider the characteristics of the Stack AI. For instance, if you’re working on a project using Java as the language, Spring as the main framework, and Feign as the library for making HTTP requests, the expectation is that API consumption suggestions would be tailored to these choices.
To create a new Workspace, access the “Create” menu and click on the “Workspace” option.
The first step is to add a name and a description. Now, we can add the necessary Stack AIs and Knowledge Sources. See an example:
Now, we are ready to explore the StackSpot AI chat considering the context you need.
Get Contextualized Suggestions through StackSpot AI Chat
The first step is to access the StackSpot AI menu in your Visual Studio Code and log in via GitHub.
After selecting the Workspace, it’s time to choose the Stack AI you want to work with.
Now, let’s begin by requesting assistance within the chat. Your first message will be “I need to transcript an audio file”. Let’s see the response:
Here, a code snippet built on top of Feign is presented, which was one of the dependencies we defined in Stack AI. Notice also that the OpenAI endpoint address is provided to perform the operation. Here, we can clearly see the intelligence of StackSpot AI, as it cross-references information and leverages the Large Language Model’s capabilities to generate an appropriate response.
A controller suggestion was also provided to implement the audio reception that needs to be transcribed using Spring, which was the framework defined in Stack AI. The parameter representing the audio could be a file itself, but this slight imprecision always carries some risk when working with Large Language Models. It’s important here to prioritize transparency and avoid making false promises.
We also have a code suggestion here to make remote calls more resilient, which was one of the defined patterns in the Stack AI we selected.
To wrap it up, we also have a reference to the Knowledge Source that was used to enrich the response. Here, there could have been more than one Knowledge Source found.
Indeed, this is precisely what we aimed for. Instead of leaving their IDE to search for information, the developer requested what they needed, and our chat was able to provide a response while considering the necessary context.
We made the prompt quite open-ended. We could have been more specific and asked for an example of how to consume the transcription service. Regarding prompt engineering, it’s always important to follow best practices, which involve providing specific instructions or requests.
In conclusion, the use of StackSpot AI, with its context-aware code assistance capabilities and integration of predefined patterns from Stack AI, has streamlined the development process. The developers can now seamlessly access relevant information and receive code suggestions without leaving their development environment.
We hope this text has helped you understand how StackSpot AI works and how it can be valuable within your company’s work context. Our goal is to enhance the efficiency of developers’ daily routines, minimizing any tasks that do not directly contribute to delivering business value through software development.
Meet the Enterprise Coding Assistant – StackSpot AI
Do you struggle to follow your organization’s coding guidelines and best practices? Say hello to StackSpot AI, the enterprise-focused coding assistant.
StackSpot AI taps into your company’s context – from style guides to custom logic – to generate compliant code automatically. Just describe what you want to build in plain English, and it will suggest secure, reliable code that aligns with standards.
With StackSpot AI, you get all the productivity benefits of AI-generated coding tailored to your business needs. No more discovering code debt during reviews!
Ready to code faster while adhering to enterprise policies? Sign up now for early access to Context-Aware from StackSpot AI. Step into the future of compliant coding with your new AI pair programmer. Enter the waitlist for StackSpot AI!