SOLFIND
Web Lens
Portal home

Code Suggestions | GitLab Docs

https://docs.gitlab.com/user/duo_agent_platform/code_suggestions/ • 41 KB fetched
Open original page


Code Suggestions | GitLab Docs Skip to main content Go to GitLab Docs homepage What's new? What's new? Get free trial Toggle menu * Use GitLab * GitLab Duo * GitLab Orbit * Extend * Install * Administer * Subscribe * Contribute * Solutions GitLab Duo Agent Platform Getting started Tutorials Availability Agentic Chat AI Catalog Agents Flows Sessions Customization Code Suggestions Models Contextual awareness Composite identity Authentication Security threats Model Context Protocol Semantic code search Troubleshooting GitLab Duo Non-Agentic Data usage * GitLab Docs / * GitLab Duo / * GitLab Duo Agent Platfor… / * Code Suggestions Help us learn about your current experience with the documentation. Take the survey . Code Suggestions * Tier : Free , Premium, Ultimate * Offering : GitLab.com, GitLab Self-Managed, GitLab Dedicated Model information * Default LLM * LLM for Amazon Q: Amazon Q Developer * Available on GitLab Duo with self-hosted models History * Introduced support for Gemini Enterprise Agent Platform Codey APIs in GitLab 16.1. * Removed support for GitLab native model in GitLab 16.2. * Introduced support for code generation in GitLab 16.3. * Generally available in GitLab 16.7. * Changed to require the GitLab Duo Pro add-on on February 15, 2024. Previously, this feature was included with Premium and Ultimate subscriptions. * Changed to require the GitLab Duo Pro or GitLab Duo Enterprise add-on for all supported GitLab versions starting October 17, 2024. * Introduced support for Fireworks AI-hosted Qwen2.5 code completion model in GitLab 17.6, with a flag named fireworks_qwen_code_completion . * Removed support for Qwen2.5 code completion model in GitLab 17.11. * Enabled Fireworks hosted Codestral by default via the feature flag use_fireworks_codestral_code_completion in GitLab 17.11. * Changed to include GitLab Duo Core in GitLab 18.0. * Enabled Fireworks hosted Codestral as the default model in GitLab 18.1. * Changed the default model for code generation to Claude Sonnet 4 in GitLab 18.2. * Removed feature flag code_suggestions_context in GitLab 18.6. * Available on the Free tier on GitLab.com with GitLab Credits in GitLab 18.10. * Changed GitLab Duo Core user access to Code Suggestions. Now available as part of the GitLab Duo Agent Platform starting in GitLab 19.0. Code Suggestions is available for: * GitLab Duo Agent Platform. Billing is usage-based . * GitLab Duo Pro or Enterprise, GitLab Duo with Amazon Q. Billing is based on your add-on. Use GitLab Duo Code Suggestions to write code more efficiently by using generative AI to suggest code while you re developing. * View a click-through demo . * Watch an overview Prerequisites * If you have GitLab Duo Core, IDE features are on . * Code Suggestions is set up in your IDE. * You have a default GitLab Duo namespace set, or have a project open that has GitLab Duo access. GitLab Duo requires GitLab 17.2 or later. For GitLab Duo Core access, and for the best user experience and results, upgrade to GitLab 18.0 or later . Earlier versions might continue to work, however the experience might be degraded. Use Code Suggestions To use Code Suggestions: * Open a project in your IDE. * Author your code. As you type, suggestions are displayed. Code Suggestions provides code snippets or completes the current line, depending on the cursor position. * Describe the requirements in natural language. Code Suggestions generates functions and code snippets based on the context provided. * When you receive a suggestion, you can do any of the following: * To accept a suggestion, press Tab . * To accept a partial suggestion, press either Control + Right arrow or Command + Right arrow . * To reject a suggestion, press Esc . In Neovim, press Control + E to exit the menu. * To ignore a suggestion, keep typing as you usually would. View multiple code suggestions History * Introduced in GitLab 17.1. For a code completion suggestion in VS Code, multiple suggestion options might be available. To view all available suggestions: * Hover over the code completion suggestion. * Scroll through the alternatives. Either: * Use keyboard shortcuts: * On a Mac, press Option + [ to view the previous suggestion, and press Option + ] to view the next suggestion. * On Linux and Windows, press Alt + [ to view the previous suggestion, and press Alt + ] to view the next suggestion. * On the dialog that s displayed, select the right or left arrow to see next or previous options. * Press Tab to apply the suggestion you prefer. Code completion and generation Code Suggestions uses code completion and code generation: Code completion Code generation Purpose Provides suggestions for completing the current line of code. Generates new code based on a natural language comment. Trigger Triggers when typing, usually with a short delay. Triggers when pressing Enter after writing a comment that includes specific keywords. Scope Limited to the current line or small block of code. Can generate entire methods, functions, or even classes based on the context. Accuracy More accurate for small tasks and short blocks of code. Is more accurate for complex tasks and large blocks of code because a bigger large language model (LLM) is used, additional context is sent in the request (for example, the libraries used by the project), and your instructions are passed to the LLM. How to use Code completion automatically suggests completions to the line you are typing. You write a comment and press Enter , or you enter an empty function or method. When to use Use code completion to quickly complete one or a few lines of code. Use code generation for more complex tasks, larger codebases, when you want to write new code from scratch based on a natural language description, or when the file you re editing has fewer than five lines of code. Code Suggestions always uses both of these features. You cannot use only code generation or only code completion. View a code completion vs. code generation comparison demo . Best practices for code generation To get the best results from code generation: * Be as specific as possible while remaining concise. * State the outcome you want to generate (for example, a function) and provide details on what you want to achieve. * Add additional information, like the framework or library you want to use. * Add a space or new line after each comment. This space tells the code generator that you have completed your instructions. * Review and adjust the context available to Code Suggestions . For example, to create a Python web service with some specific requirements, you might write something like: # Create a web service using Tornado that allows a user to sign in, run a security scan, and review the scan results. # Each action (sign in, run a scan, and review results) should be its own resource in the web service ... AI is non-deterministic, so you may not get the same suggestion every time with the same input. To generate quality code, write clear, descriptive, specific tasks. For use cases and best practices, follow the GitLab Duo examples documentation . Available language models Different language models can be the source for Code Suggestions. * On GitLab.com: GitLab hosts the models and connects to them through the cloud-based AI Gateway. * On GitLab Self-Managed, two options exist: * GitLab can host the models and connect to them through the cloud-based AI Gateway . * Your organization can use self-hosted models , which means you host the AI Gateway and language models. You can use GitLab-managed models, other supported language models, or bring your own compatible model. Accuracy of results We are continuing to work on the accuracy of overall generated content. However, Code Suggestions might generate suggestions that are: * Irrelevant. * Incomplete. * Likely to result in failed pipelines. * Potentially insecure. * Offensive or insensitive. When using Code Suggestions, code review best practices still apply. Related topics * Supported extensions and languages * Code Suggestions limitations * Prompt caching * Direct and indirect connections * Code Suggestions contextual awareness * Troubleshooting Code Suggestions * Repository X-Ray * Prerequisites * Use Code Suggestions * View multiple code suggestions * Code completion and generation * Best practices for code generation * Available language models * Accuracy of results * Related topics * Facebook * LinkedIn * Twitter * YouTube Company * About GitLab * View pricing * Try GitLab for free Feedback * View page source * Edit in Web IDE * Contribute to GitLab * Suggest updates Help & Community * Get certified * Get support * Post on the GitLab forum Resources * Terms * Privacy statement * Use of generative AI * Acceptable use of user licenses *

Links found on this page

  1. Skip to main content [direct]
  2. Go to GitLab Docs homepage [direct]
  3. What's new? [direct]
  4. Get free trial [direct]
  5. Use GitLab [direct]
  6. GitLab Duo [direct]
  7. GitLab Orbit [direct]
  8. Extend [direct]
  9. Install [direct]
  10. Administer [direct]
  11. Subscribe [direct]
  12. Contribute [direct]
  13. Solutions [direct]
  14. GitLab Duo Agent Platform [direct]
  15. Getting started [direct]
  16. Tutorials [direct]
  17. Availability [direct]
  18. Agentic Chat [direct]
  19. AI Catalog [direct]
  20. Agents [direct]
  21. Flows [direct]
  22. Sessions [direct]
  23. Customization [direct]
  24. Models [direct]
  25. Contextual awareness [direct]
  26. Composite identity [direct]
  27. Authentication [direct]
  28. Security threats [direct]
  29. Model Context Protocol [direct]
  30. Semantic code search [direct]
  31. Troubleshooting [direct]
  32. GitLab Duo Non-Agentic [direct]
  33. Data usage [direct]
  34. Take the survey [direct]
  35. Free [direct]
  36. Default LLM [direct]
  37. GitLab Duo with self-hosted models [direct]
  38. Introduced support for Gemini Enterprise Agent Platform Codey APIs [direct]
  39. Removed support for GitLab native model [direct]
  40. Introduced support for code generation [direct]
  41. Generally available [direct]
  42. Changed [direct]
  43. Introduced support for Fireworks AI-hosted Qwen2.5 code completion model [direct]
  44. Removed [direct]
  45. Changed [direct]
  46. Removed [direct]
  47. View a click-through demo [direct]
  48. Watch an overview [direct]
  49. Code Suggestions is set up [direct]
  50. default GitLab Duo namespace [direct]
  51. upgrade to GitLab 18.0 or later [direct]
  52. Introduced [direct]
  53. View a code completion vs. code generation comparison demo [direct]
  54. context available to Code Suggestions [direct]
  55. GitLab Duo examples documentation [direct]
  56. Supported extensions and languages [direct]
  57. Code Suggestions limitations [direct]
  58. Troubleshooting Code Suggestions [direct]
  59. Repository X-Ray [direct]
  60. Facebook [direct]
  61. LinkedIn [direct]
  62. Twitter [direct]
  63. YouTube [direct]
  64. About GitLab [direct]
  65. View pricing [direct]
  66. Try GitLab for free [direct]
  67. View page source [direct]
  68. Edit in Web IDE [direct]
  69. Contribute to GitLab [direct]
  70. Suggest updates [direct]
  71. Get certified [direct]
  72. Get support [direct]
  73. Post on the GitLab forum [direct]
  74. Terms [direct]
  75. Privacy statement [direct]
  76. Use of generative AI [direct]
  77. Acceptable use of user licenses [direct]