Inspired by GitHub Copilot, Delphi AI Developer is a plugin that adds Artificial intelligence (AI) interaction capabilities to the Delphi IDE, using both the OpenAI API, Gemini API and Groq API, as well as offering offline AI support.
With Delphi AI Developer, you will have assistance in generating and refactoring code, facilitating and accelerating development.
Receive suggestions for creating and improving code directly in the IDE and take advantage of the possibility of creating predefined questions to speed up your searches.
1 - Download Delphi AI Developer. You can download the .zip file or clone the project on your PC.
2 - In your Delphi, access the menu File > Open and select the file: Package\DelphiAIDeveloper.dpk
3 - Right-click on the project name and select "Install"
4- The "AI Developer" item will be added to the IDE's MainMenu
Access the menu “AI Developer” > “Settings” > Tab “Preferences”
- Language used in questions: Indicate in which language you will ask questions in chats, so that the prompts generated by the Plugin are generated in the same language.
- AI default (Chat and Databases Chat): Default AI when starting the IDE.
- Color to highlight Delphi/Pascal code: Color to highlight Delphi/Pascal/SQL code in responses displayed on chat screens
- Default Prompts: Prompts added in this field will be sent to the AIs along with the requests. This can significantly improve the quality of the responses. (Example prompt: Always return SQL commands in lowercase letters)
You can choose between 3 APIs, Gemini (Google), ChatGPT (OpenAI) and Groq. Gemini and Groq APIs are free.
Access the menu “AI Developer” > “Settings” > Tab “AI on-line”
- Inform the desired model.
- Click on the "Generate API Key" link to generate your key.
- In this field you must enter the API access key.
To configure, access the menu “AI Developer” > “Settings” > Tab “Code Completion”
- Enables/disables use of Code Completion
- AI default: Default AI that will be used by Code Completion
- Suggestion Code Color: Color code suggested by plugin before being accepted
- Shortcut to invoke Code Completion usage (requires restart of Delphi IDE)
- Default Prompts: Prompts added in this field will be sent to the AIs along with the requests. This can significantly improve the quality of the responses. (Example prompt: Always return SQL commands in lowercase letters)
- To use it, simply use the configured shortcut keys (default Alt+Enter)
- To accept the suggestion, simply use the Tab key.
Access the menu “AI Developer” > “Chat” or Ctrl+Shift+Alt+A
- Select the desired AI to be used in the chat
- Field where the question/prompt should be added
- Field where the AI response will be displayed
- Access the menu with pre-registered questions (to register, access the menu: “AI Developer” > “Defaults Questions”)
- By checking this option, the AI will only return codes, without inserting comments or explanations.
- By checking the "Use current unit code in query" option, the source code of the current unit will be used as a reference for the prompt sent to the AIs. Note: If the current unit has any code selected, only the selected code snippet will be used as a reference, otherwise the entire unit code will be used.
- Button that makes the request to the AIs
- Insert Selected Text at Cursor: Inserts the selected text into the response, field in the IDE code editor (if there is no selection, use the entire response)
- Create new unit with selected code (if there is no selection, use the entire response)
- Copy Selected Text (if there is no selection, use the entire response)
- Clean all and start a new chat
- Opens a menu with additional options
-
To register Databases, access the menu “AI Developer” > “Databases Registers”
-
Generate reference with database
-
Note: This process must always be performed whenever a new field or table is added to the database.
-
Optional Step: Link Default Database to Project or Project Group
-
Chat for database
- Select the desired database
- Quick access to the reference generation screen for the selected database
- Select the desired AI to be used in the chat
- Field where the question/prompt should be added
- Button that makes the request to the AIs
- Field where the AI response will be displayed
- Button to execute the SQL command of the field with the response (field 6)
- Grid with the response from the execution of the SQl command
- Options for copying or exporting Grid data
- Access the menu with pre-registered questions (to register, access the menu: “AI Developer” > “Defaults Questions”)
- By checking this option, the AI will only return SQL commands, without inserting comments or explanations.
- By checking the "Use current unit code in query" option, the source code of the current unit will be used as a reference for the prompt sent to the AIs. Note: If the current unit has any code selected, only the selected code snippet will be used as a reference, otherwise the entire unit code will be used.
- Insert Selected Text at Cursor: Inserts the selected text into the response, field in the IDE code editor (if there is no selection, use the entire response)
- Create new unit with selected code (if there is no selection, use the entire response)
- Copy Selected Text (if there is no selection, use the entire response)
- Clean all and start a new chat
- Opens a menu with additional options
To use AI offline, follow these steps:
- Install Ollama, which can be found at the following link: https://ollama.com/download
- Choose the desired model. This can be done at the following link: https://ollama.com/library
- Open command prompt or terminal and run the command “ollama run <name_model>” and wait for the installation to finish
- To configure, access the menu “AI Developer” > “Settings” > Tab “AI off-Line“
For more details about the plugin, watch our talk, voted one of the best of Embarcadero Conference 2024. The video is in Portuguese (pt-BR), but we are providing subtitles and possibly an English version.
Any suggestions or help are welcome. Send us a pull request or open an issue.
Delphi AI Developer
is free and open-source wizard licensed under the MIT License.