Blog AI/ML GitLab uses Anthropic for smart, safe AI-assisted code generation
Published on: January 16, 2024
3 min read

GitLab uses Anthropic for smart, safe AI-assisted code generation

Anthropic’s Claude AI model supports the delivery of helpful, trusted code in GitLab Duo Code Suggestions.

gitlabduo.png

GitLab recently launched GitLab Duo Code Suggestions into general availability. Code Suggestions includes the ability to generate algorithms or code blocks directly within the developer's IDE, a capability that uses Anthropic's generative AI model, Claude. Integrated into the GitLab Duo portfolio of AI-assisted features, Claude is compatible with GitLab’s principles of transparency and privacy by design and provides a high-integrity foundation for code generation.

In this post, you'll learn the advantages of code generation and how GitLab, together with Anthropic, is leveraging AI to responsibly boost developer productivity.

How AI-assisted code generation works

Code Suggestions is incredibly useful as a coding companion that shows the suggestions as a developer types. It helps save developer time and keystrokes, reducing the effort for rote tasks and giving developers time back in their day. But what if a developer wants to do even more with generative AI?

Enter code generation.

Imagine needing to write a new complex function based on an unfamiliar algorithm, or write a large amount of boilerplate code. Instead of struggling through these tasks with gritted teeth, code generation allows developers to simply define what they want to do in comments or multi-line comment blocks, and then Code Suggestions generates the code from there.

Here is an example of Code Suggestions generating a JavaScript function that calculates the Levenshtein distance, a string metric useful for comparing the difference between two sequences:

Code Suggestions generating JavaScript function

Here is another example showing a multi-line comment in Python. We want Code Suggestions to generate a Tornado Web Server that does three things: log in, run a scan, and review the results. By providing the specific instructions, including details such as the framework and the components to use,, Code Suggestions was able to generate a Tornado App, despite this author being unfamiliar with Tornado.

Code Suggestions generating Tornado app

Safety through focus and trustworthiness Developers expect AI coding assistants to not only be helpful, but also accurate and safe. The system should generate precisely what is asked for while limiting deviation and hallucination. Customers want assurances that AI-generated code can be trusted.

Throughout GitLab's evaluation of certain code generation models, Claude stood out for its ability to mitigate distracting, unsafe, or deceptive behaviors. Claude also demonstrated consistent and accurate code generation throughout our testing.

GitLab's use of Anthropic's Claude enables Code Suggestions to balance automation with trust. Code Suggestions helps users become more efficient without sacrificing reliability — a win for augmented development.

What’s next

Ready to experience the future of code generation? Start your free trial of GitLab Duo today and unlock the power of AI-assisted development!

We want to hear from you

Enjoyed reading this blog post or have questions or feedback? Share your thoughts by creating a new topic in the GitLab community forum. Share your feedback

Ready to get started?

See what your team could do with a unified DevSecOps Platform.

Get free trial

Find out which plan works best for your team

Learn about pricing

Learn about what GitLab can do for your team

Talk to an expert