Smart CodeInsight

From RAD Studio
Jump to: navigation, search

Smart CodeInsight is an open architecture that allows you to work with your favorite AI engines. RAD Studio also offers you customizable UI integration besides the following implemented features:

Warning: RAD Studio does not provide access to any of those engines. Using these AI services requires you to agree to the terms of the specific vendor, receive an API key to enter into the RAD Studio configuration, and pay the AI company the due fees. The only exception to this rule is Ollama, which can be used offline without incurring a service fee and installed locally or on a server of your choice.

Configuration Options

RAD Studio gives you extended configuration and full privacy control in multiple ways, allowing you to:

  • Turn off the entire AI feature with a single global setting.
  • Enable or disable each of the four engines.
  • Pick the default engine of the UI elements (chat and editor menu).

You can configure all these features in the IDE Options. Please review the Smart CodeInsight Configuration page for more information about this topic.

  • We have also implemented the following actions to ensure security in our system.
  • We store the API keys in an encrypted format.
  • We include the option to use a local, offline engine.

Editor Menu Commands

The editor menu offers some preset operations on the code selected in the editor itself. The goal is to analyze and optimize a portion of your application's source code.

As an outcome, the LLM engine returns the result in the editor window as a comment after the analyzed code. (add a screenshot)

Available Commands

Check out the available commands for Smart CodeInsight:

Smart CodeInsight-Display.png

  • AI Chat: Open the chat view.
  • Find Bugs: Try to find potential bugs in the selected code.
  • Explain Code: Explain the selected code.
  • Add Comment: Add comments to the selected code.
  • Complete the code: Complete the selected code.
  • Optimize code: Optimize the selected code.
  • Add unit test: Add unit test for the selected code.
  • Convert to Assembly: Convert the selected code to Assembly code.
  • Convert to Delphi: Convert the selected code to Delphi code (from C++ or Assembly).
  • Convert to C++ Builder: Convert the selected code to C++ builder code.
  • Find Header (AI) (in C++) or Find Unit (in Delphi): Add the missing unit to the uses statements for a selected code class or data type.
  • Display results in the editor: Send the output to the editor. 
  • Display results in the Chat window: Send the output to the AI chat window in Markdown format. 

AI Chat Window

The AI chat window is an IDE dockable form, which works like any LLM chat window. You can type a request, pick an engine (unless you want to use the default one), and wait for the answer. Here is a quick example:

Smat CodeInsight - ChatWindow Markdown.png

This chat window has a question memo that can act like a simple command line. These are the available commands:

  • chatgpt> + Enter: switch the active AI engine to ChatGpt (if enabled).
  • gemini> + Enter: switch the active AI engine to Gemini (if enabled).
  • claude> + Enter: switch the active AI engine to Claude (if enabled).
  • ollama> + Enter: switch the active AI engine to Ollama (if enabled).
  • clear> + Enter: clears the answer memo.
  • stop> + Enter: stops generating answer, the same as when clicking the stop button.
  • Ctrl + Enter: starts generating the answer, the same as when clicking the start button.

In addition to performing standard queries, you can select a specific code snippet from the code window and ask a new question or request an explanation about it using one of the following commands:

Smart CodeInsight-ExaplainCodeVariable.png

  • $COL: Expands to the column number where the cursor is located in the active code editor window.
  • $ROW: Expands to the row number where the cursor is located in the active code editor window.
  • $CURTOKEN: Expands to the word where the cursor is located in the active code editor window. This is useful when referring to the variable, method, or identifier at the cursor location.
  • $EDNAME: Expands to the full file name of the active code editor window. This is helpful if you need the current path file's name (with path).
  • $SELECTION: Explains the selected code text in the active editor.
  • $UNIT: Explains the code in the whole content of the Unit.

Please review the Transfer Macros page for more information and examples.

See Also