AWS Public Sector Blog

SoftwareOne boosts developer efficiency and streamlines code reviews using Amazon Bedrock

AWS branded background design with text overlay that says "SoftwareOne boosts developer efficiency and streamlines code reviews using Amazon Bedrock"

Efficient code review processes are vital across all customer segments, both commercial and public sector, where strict regulations, data security, and service excellence are paramount. Streamlined code reviews maintain software quality, mitigate security risks, and enhance operational efficiency. SoftwareOne, an Amazon Web Services (AWS) Premier Tier Services Partner and a global provider of end-to-end software and cloud technology solutions, addresses these challenges with its automated solution, SummarAIze, powered by the generative artificial intelligence (generative AI) capabilities of Amazon Bedrock. SoftwareOne’s expertise in providing custom cloud-based solutions has helped its customers worldwide embrace cloud-based infrastructure and benefit from true cloud-native software written for and running on AWS.

SoftwareOne developed SummarAIze, which is software for automatic generation of GitHub pull request descriptions that is driven by AI. SummarAIze accelerates code reviews, reduces development cycles, and optimizes resource allocation. By automating pull request summaries in GitHub repositories, SummarAIze empowers developers with comprehensive overviews of code changes and enables organizations to effectively streamline code review workflows, enhance collaboration among development teams, and accelerate the delivery of high-quality software solutions to the market. This post provides an overview of SoftwareOne’s approach to building SummarAIze and its impact on the software development process.

The challenge

Software engineering teams face significant challenges in the creation and review of pull requests. Despite the importance of these requests in identifying and rectifying software defects during the product development phase, engineers spend considerable time on their creation and review processes. This time-consuming task often detracts from other critical tasks, hindering productivity and project delivery timelines. Additionally, as teams expand to meet customer demands and maintain high software quality standards, the volume of pull requests escalates, further complicating the development process. This increased complexity not only consumes valuable time and resources but also poses a risk to overall project efficiency.

Wouldn’t it be beneficial for software engineering teams to streamline their pull request workflows, enabling engineers to focus on core high-value tasks such as designing and coding, thereby accelerating project delivery and maintaining software quality?

Getting to know Amazon Bedrock

Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies through a single API, along with a broad set of capabilities needed to build generative AI applications with security, privacy, and responsible AI. With the comprehensive capabilities of Amazon Bedrock, you can easily experiment with a variety of top FMs, privately customize them with your data using techniques such as fine-tuning and Retrieval-Augmented Generation (RAG), and create managed agents that execute complex business tasks without writing any code.

SoftwareOne’s SummarAIze was developed using the Anthropic Claude model, with the following model specifications, inference parameters, and prompt syntax:

  • Provider: Anthropic
  • Model: Claude V2
  • Inference parameters:
    • Temperature: 0.2
    • Max tokens to sample: 300
    • Top K: 250
    • Top P: 0.999
  • Prompt:Human: Given the git patch file:
    ==========
    {diff}
    ==========
    summarize in 3-4 sentences the logical changes which the pull request will apply in the project. Write the response in a style which will be used for a pull request comment. Do not use the words “diff” or “patch” in the response, instead use “PR”. Use simple, clear and concise sentences which can be understood even by not so tech-savvy people. Extract information not only from the patch description, but also from the actual changes in the pull request. I am aware that you do not have access to the whole source code, so do not mention it. Refrain from using bullets and listing each added, deleted or modified class or method. Avoid describing method parameters. Focus on what the new methods do from business perspective, not on their parameters and names – e.g. “a user deletion method was added, as well as a new method for validating user input”. Avoid looking in external dependencies. If the change includes code formatting, do not categorize it as a new functionality. Start your response directly with the summary. If you have to make assumptions, make them.
    Assistant:

Given the utilization of the Claude model, it’s essential to adhere to the following prompt format:

“\n\nHuman: {{Query Content}}\n\nAssistant:“

Ensuring the desired size of the summary is specified is crucial to prevent large responses of lesser value.

SoftwareOne’s SummarAIze: The flow

When a software engineer creates a pull request in a GitHub repository, GitHub triggers a webhook configured with the URL of our application. The application uses the GitHub API to retrieve the diff of the pull request and includes it in the agreed-upon prompt. This prompt is then sent to Amazon Bedrock for analysis. The returned response is set as a description of the pull request through the GitHub API.

Figure 1. SoftwareOne’s SummarAIze workflow using Amazon Bedrock. The major components include Amazon Bedrock using the Anthropic Claude model, a NodeJS application, and a GitHub repository.

The application

SummarAIze is a fully serverless solution designed to expedite the automation of pull request summaries within GitHub repositories. Developed as a NodeJS AWS Lambda function, the application’s source code is scripted in TypeScript. Customers can configure the GitHub workflow, which is then set up to compile the code, bundle the resulting JavaScript into a .zip file, and deploy it within your AWS environment upon each pull request merge.

The Lambda function initiates the Amazon Bedrock client, parses the input event, and initializes the GitHub octokit client. It proceeds to retrieve the pull request diff through the octokit client, eliminate all unchanged source code lines from the diff, and integrate the reduced content into the Amazon Bedrock prompt. Following this, a request is dispatched to Amazon Bedrock. Subsequently, the pull request description is generated from the resulting response and published within the pull request through the octokit client.

The Lambda function performs the following steps:

  1. Initializes the Amazon Bedrock client.
<p>const bedrockClient = new BedrockRuntimeClient({</p><p>region: process.env.REGION,</p><p>} as any);</p>
  1. Parses the input event.
const body = JSON.parse(event.body);
  1. Initializes the GitHub octokit client.
<p>if (!octokitClient) {</p><p>octokitClient = await createOctoClient();</p><p>}</p>
  1. Uses the octokit client to get the pull request diff.
<p>const resp = await octokitClient.rest.pulls.get({</p><p>owner: process.env.ORG_NAME!,</p><p>repo: body.repository.name,</p><p>pull_number: body.pull_request.number,</p><p>mediaType: {</p><p>format: 'diff',</p><p>},</p><p>});</p>
  1. Removes all unchanged source code lines from the diff.
<p>const lines = diffContent.split('\n');</p><p>const sanitizedLines = lines.reduce((acc: string[], line: string) =&gt; {</p><p>if (line.startsWith('@@') ||</p><p>line.startsWith('+') ||</p><p>line.startsWith('-')) {</p><p>return acc.concat(line);</p><p>}</p><p>return acc;</p><p>}, []);</p><p>return sanitizedLines.join('\n');</p>
  1. Incorporates the reduced diff content in the Amazon Bedrock prompt and sends a request to Amazon Bedrock.
<p>const command = new InvokeModelCommand({</p><p>body: JSON.stringify({</p><p>prompt: prompt.replace('{diff}', diff),</p><p>max_tokens_to_sample: +process.env.MAX_TOKENS_TO_SAMPLE,</p><p>temperature: +process.env.TEMPERATURE,</p><p>top_k: +process.env.TOP_K,</p><p>top_p: +process.env.TOP_P,</p><p>}),</p><p>contentType: 'application/json',</p><p>accept: '*/*',</p><p>modelId: 'anthropic.claude-v2',</p><p>});</p><p>const bedrockResp = (await bedrockClient.send(command)) as { body: string };</p>
  1. Generates the pull request description from the returned response and publishes it in the pull request through the octokit client.
<p>const parsedResponse = JSON.parse(</p><p>Buffer.from(bedrockResp.body).toString('utf8'),</p><p>) as { completion: string };</p><p>let updatedBody = body.pull_request.body || '';</p><p>if (updatedBody) {</p><p>updatedBody = updatedBody + '\n\n';</p><p>}</p><p>updatedBody += `**[SummarAIzation]:** ${parsedResponse.completion}`;</p><p>await octokitClient.rest.pulls.update({</p><p>owner: process.env.ORG_NAME!,</p><p>repo: body.repository.name,</p><p>pull_number: body.pull_request.number,</p><p>body: updatedBody,</p><p>});</p>

Turning the Lambda into an API

With the Lambda function provisioned, customers also have the ability to configure a new REST API in Amazon API Gateway with a webhook POST API endpoint, as shown in Figure 2. You can then add Lambda proxy integration of this endpoint with the Lambda function set up previously. Additionally, you can assign a custom subdomain name in your company’s top-level domain (TLD) to the REST API, making it easier to point to it from webhooks.

Figure 2. REST API with a webhook POST API endpoint. The major components include Amazon API Gateway and a REST API.

Integrating with GitHub

As next steps, in each GitHub repository where you want to enable SummarAIze, configure a webhook with the URL of the webhook API endpoint in API Gateway, as shown in Figure 3. Additionally, to alleviate the tediousness for GitHub repository administrators and owners when configuring webhooks in each repository, we recommend tracking this process using an internal project catalog management system. This system enables users to enable and disable the SummarAIze webhook for any of their GitHub repositories with a single checkbox.

Figure 3. Webhook configured with the URL of API endpoint in Amazon API Gateway. The major component includes a GitHub webhook.

To ensure smooth integration, it’s essential to configure the GitHub webhook properly. The following figure shows how to enable the GitHub webhook for pull request events.

Figure 4. Enable the GitHub webhook for pull request events. The major component includes a GitHub webhook.

The final architecture of the deployed solution is illustrated in Figure 5.

Figure 5. Final architecture of the automated SummarAIze solution. The major components include Amazon Bedrock using the Anthropic Claude model, a NodeJS application deployed through AWS Lambda, Amazon API Gateway, and a GitHub repository.

The code base, including the AWS CloudFormation script to set up all the required AWS resources for deploying SummarAIze, can be found in the public GitHub repository.

The following video shows a quick demo of the SummarAIze solution by creating a pull request in GitHub. With SoftwareOne’s SummarAIze deployed, pull requests in these repositories will now be processed faster and more smoothly, giving your engineers more time per pull request.

Conclusion

The paperwork around pull requests can consume a significant amount of software engineers’ time, reducing productivity and motivation. Conversely, automating these processes increases efficiency and allows engineers to focus on value-added tasks. This reduces context switching, improves team collaboration, and boosts overall productivity.

AWS, using Amazon Bedrock, helped SoftwareOne leverage generative AI to achieve real productivity gains and drive developer efficiency. As an organization, SoftwareOne is keen on using the latest technologies and automating undifferentiated activities. The SummarAIze solution embodies both passions. By combining cutting-edge AI services from AWS with lightweight serverless technologies, it streamlines code reviews and enhances developer productivity and efficiency. This results in shorter project delivery times, higher product quality, increased customer trust, and a better net promoter score.

If you’re ready to start building your own foundation model innovation with Amazon Bedrock, check out this link to set up Amazon Bedrock. Dive deeper into the possibilities of Bedrock and elevate your generative AI journey today.

Mohan CV

Mohan CV

Mohan is a principal solutions architect at Amazon Web Services (AWS) and is based in Northern Virginia. He specializes in data and artificial intelligence (AI) with a strong background in large-scale enterprise migrations and modernization. Mohan is passionate about leveraging new technologies to assist customers in the public sector and beyond, tailoring innovations to meet unique business needs.

Martin Marinov

Martin Marinov

Martin Marinov is a technical lead and architect at SoftwareOne based in Sofia, Bulgaria. He is an expert in designing and leading the implementation of cloud-based software solutions on Amazon Web Services (AWS). Martin has a strong background in serverless architectures and is passionate about helping customers maximize the benefits of the cloud, leveraging his skills to tailor solutions that meet unique business needs.