CodeInsight
Go Up to IBConsole
Smart CodeInsight is a new AI assistance tool built into IBConsole starting with InterBase 15 Update 1. Smart CodeInsight helps you interact with your database entities and SQL code using an AI engine. Smart CodeInsight provides assistance through a specialized command prompt, a macro system, and context-sensitive options within IBConsole windows.
Smart CodeInsight is available only when connected to InterBase 15 servers or higher.
Enabling Smart CodeInsight
To enable Smart CodeInsight, follow these steps:
- On the Main IBConsole window, click Options
- Click on Smart CodeInsight on the left panel.
- Select Enable Smart CodeInsight
- The first time you enable Smart CodeInsight, the terms agreement is displayed.
Setting up an AI engine and model
Currently, there are 4 engines you can use with IBCosole: ChatGpt, Ollama, Gemini, and Claude. To enable one or more engines, follow these steps:
- Click on the tab of the engine you want to enable.
- Select Enable.
- Fill all the required fields.
- To verify your settings, click Test Connection.
- Once you connect successfully to an engine, Select a default engine from the Default AI dropdown list.
- Click Save.
You must select a default engine, when a Smart CodeInsight window is created, the window will use the default engine. If you later change this setting, existing Smart CodeInsight windows will keep using the engine set on creation.
Setting Max Token value
The default value for the Max Token setting is 4096. If you get unexpected responses, you can try increasing this value. The Max Token value that produces results could be different for each Agent and model you are using
Using CodeInsight
Currently, you can use Smart CodeInsight in three places, from the CI <database> tab, from the context menu of an item, and from the Interactive SQL window. The options available depend on where Smart CodeInsight runs.
Some built in Smart CodeInsight prompts are available for items listed on the MultiPurpose section. To access these prompts:
- Right click on an item.
- Go to Smart CodeInsight.
- Select one of the available prompts.
- Note:
The available prompts can change depending on the type of item.
- Describe Entity
- This prompt returns a description of the selected entity. It returns information like table structure, constraints, indices, and domains used.
- Only available for tables, views, stored procedures, triggers, subscriptions, and tablespaces.
- Suggest metadata improvements
- This prompt returns the same metadata as Describe Entity but it also provides help to improve the structure, like fields that might be normalized into their own table.
- Only available for tables.
- Evaluate and recommend indices
- This prompt sends all the indices on the entity including the selectivity. A few tuning recommendations are included like look for selectivity in a multi column index where the highly selective columns are at the tail end.
- Available for tables and indices.
- Document using ALTER Description
- This prompt returns an “ALTER DESCRIPTION FOR COLUMN …” script, which can be used on any entity that supports the Alter Description syntax.
- Available for all entities except for Users (EUA only item) and User Permissions.
CI <database> tab
Here you can type any prompt related to InterBase or tables in the active database. For more details refer to the CodeInsight Main Window documentation.
Interactive SQL window
You can also use Smart CodeInsight in the Interactive SQL Window, Smart CodeInsight has a different set of functionalities on this window. For more details refer to the CodeInsight in the Interactive SQL window documentation.
Macros
Macros allow you to easily get metadata and include it in your prompts when you send them. For example, in the following prompt:
join $table EMPLOYEE to $table DEPARTMENT where the DEPARTMENT.BUDGET > 50000
When you click Start Generating, the metadata for the employee and department tables is added to the question before sending it to the engine. This way, the engine can "understand" the relationships between them.
Available Macros
The following macros are available:
- $Domain <Domain name>
- $Table <Table name>
- $Index <Index name>
- $View <View name>
- $Procedure <Procedure name>
- $Trigger <Trigger name>
- $Function <Function (UDF) name>
- $Generator <Generator name>
- $Exception <Exception name>
- $Blobfilter <Blob Filter name>
- $Subscription <Subscription name>
- $Tablespace <Tablespace name>
- $Encryption <Encryption name>
- $Selection Selected text in the active editor (only available when there is an editor)
- $Editor- All the contents of the current editor (only available when there is an editor)
Macros are case insensitive
