GithubHelp home page GithubHelp logo

alidehbansiahkarbon / chatgptwizard Goto Github PK

View Code? Open in Web Editor NEW
226.0 26.0 54.0 1.29 MB

A ChatGPT, WriteSonic, YouChat, and Ollama(offline) plug-in for Embarcadero RAD Studio IDE 10.1 and later versions. https://getitnow.embarcadero.com/chatgptwizard

Home Page: https://alidehbansiahkarbon.github.io/ChatGPTWizard/

License: MIT License

Pascal 100.00%
chatgpt chatgpt-api delphi embarcadero expert openai openai-api plugin radstudio delphinuspackage

chatgptwizard's Introduction

ChatGPTWizard


Delphi   Buy Me A Coffee
license forks stars watchers issues
pulls last-commit Downloads

An AI plug-in for Embarcadero RAD Studio IDE.

First Plugin Ever to support Online(ChatGPT, Writesonic, and YouChat) and Offline(Ollama) AI servers!

PLEASE NOTE THAT You will need an API key (just in Online mode) to use this plugin. see the API section to Generate an API key

Some API Keys are Limited to a certain usage, after that, you will need to purchase credits to keep using them.

Key Features:

  • Free text question form.
  • Dockable question form.
  • Inline questions(in the editor).
  • Context menu options to help you to find bugs, write tests, optimize code, add comments, etc...
  • Class view(Code conversion, code optimizing, test units, and other options per class).
  • Predefined Questions for class view.
  • History to save your tokens on OpenAI!
  • Fuzzy string match searches in the history.
  • Animated letters(Like the website).
  • AI Code Translator
  • Proxy server options.
  • Supports OpenAI ChatGPT as the main AI service.
  • Supports Writesonic AI as the second AI service.
  • Supports YouChat AI as the third AI service.
  • Supports Ollama(Offline)

Disclaimer

As a user of the API key, it is important to understand that you are solely responsible for all content generated through the prompt. Please note that there is no text moderation with this plugin, and your prompt will be sent directly to the AI Server through the API. While mistakes can happen while using browsers, mobile apps, or this plugin, it remains the responsibility of the user to ensure the accuracy and appropriateness of the content generated(prompts).

The plugin serves as a bridge between the user's IDE and the AI Server, enabling faster and smarter development. Please note that the plugin is intended for programming purposes only, and users should use it accordingly. For more information, please refer to the Terms of Use defined by OpenAI: Terms of use


🟢🟢🟢 How to use it in Offline mode 🟢🟢🟢

🟢 Set up an Offline AI server 👈👈👈

In order to use this plug-in with a local host follow these steps:

1- Download and Install Ollama : here

2- Check if the server is running by opening it in your browser: http://localhost:11434

You should see something like this screenshot:

Screenshot 2024-04-02 094238

3- Then you need at least one trained model to be attached to your new AI server, there are a lot of models here, so choose one (codellama is a good one, I suggest that for now) and install it with this command in command-line:

ollama run codellama

Screenshot 2024-04-02 094133

After pulling the model is finished you can ask some questions in CMD right away.

4- Now use this URL instead of the OpenAPI's URL in the setting form of the Plugin in RAD Studio:

http://localhost:11434/api/generate

You don't need an Accesskey, no need to change or even clear it, just leave it.

5- Tick the checkbox called Ollama(Offline) and add your model name in the text box in front of the checkbox, in my case, I use "codellama" as the model name.

6- Congratulations! you did it, now enjoy forever free AI assistance.

Note: depending on the hardware resources, the model size, and the parameter count of the model you can experience different speeds and performance, so do not open any issues about the Offline solution's speed or performance, there is nothing to do about that with the Plug-in itself, Plug-in is just a bridge between AI server and RAD Studio.

Good luck!


Demo videos

🟢 Short1(all features)
🟢 Short2(ChatGPT, Writesonic, and YouChat actions at the same time)
🟢 Long

Platforms

This Plugin Supports the following AI Services:

generate API Key here

generate API Key here

generate API Key here

NOTE: ChatGPT is working with Rad Studio 10.1 and above but Other(non-ChatGPT) AI Services are enabled in Rad Studio 10.2 and above!

Remarks

  • This plugin is free but some AI Services are not free forever.
  • It's compatible with Delphi 10.1 Berlin and later versions.
  • Uses the XSuperObject library which is included in the project files. you can also find the latest version here
  • Settings are stored in the registry which can be found here: Computer\HKEY_CURRENT_USER\Software\ChatGPTWizard

How to Install

1- Getit package manager

2- Delphinus package manager - you can install Delphinus package manager and install ChatGPTWizard there. (Delphinus-Support)

3- Direct installation - Open the project in Delphi, right-click on the project node in the project manager, build, and install.


How to Use

Plug-in's main form

You can use the ChatGPT menu from the IDE's main menu directly to ask questions and get the answer. Click on the newly added ChatGPT menu on the IDE(or press Ctrl+Shidt+Alt+C) to open the wizard, type the question, and press the Ask button(or Ctrl+Enter).


how-to-use1 how-to-use2

Two New Tabs has been added to get separate results for Writesonic and YouChat.

So now you can get multiple different answers based on any question, compare, merge, and get the best quality and accuracy for your code.


image


Settings

"Other AI Services" Tab is responsible for setting up Other AI service's tokens including Writesonic's credentials.


image


Inline Questions

If you need to use the ChatGPT inside the editor you need to type a question directly inside the code editor and surround it with cpt: at the beginning and :cpt at the end of the question then press Ctrl+Shift+Alt+A or simply select "Ask" from the editor's context menu by right-clicking on the selected text.

Usage Scenario for Inline Questions

Open a new vcl application project, add a new unit, and remove all the code from it! and type the following line, select all and press Ctrl+Shift+Alt+A.

cpt:Create a full unit in Delphi including a class to create an XML file.:cpt


Dockable Form


dockable-form1 dockable-form2

Use the "ChatGPT Dockable" menu from the main menu to show the dockable form and try to dock the form to the left or right side panel of the IDE, and enjoy with your new Google killer assistant!


Context Menu

Context Menu for Selected text or a block of code. The Result will be inserted after the selected text as a multi-line comment between two brackets {}

Options

  • Ask
  • Add Test - Will try to create a unit test for the selected text.
  • Find Bugs - Find fugs in the selected text.
  • Optimize - Will Optimize the selected text.
  • Add Comments - Will add necessary comments to the selected code.
  • Complete code - Will try to add any missing code to the selected code.
  • Explain code - will explain what the selected code does in Delphi.


image


image_2023-04-25_16-08-40


Class View

Using the class view you have your class list with some functionalities in a popup menu. It is also possible to use your custom command based on the selected class in the TreeView, in this case, @Class will represent the selected class in your custom command, if you don't use @Class the selected class' source will be attached to the end of your command, just pay attention there will be some limitations because at the moment it's not possible to send thousands of lines through the API request.

Please note that it is best to use this feature for small classes. due to API limitations, you cannot send a class with several thousand lines of code in a question.


image


History

History is available if you enable it in the setting form, it's using SQLite as a simple file-based database. You can find an empty database in Resource\DB that named "History.sdb", copy this file to any place in the disk and address it to the folder in the setting.


image


image


Search in History

Right-click on the History grid and check the search item in the search bar that appears, it's not visible by default to save some space, finally, type the keyword to search and filter, there are two checkboxes as extra options like case sensitive and fuzzy match string search.


image


image


image


Issues with SSL

This issue can be fixed if you put SSL libraries(can find them in the resource folder) alongside the bds.exe or in the Bpl folder(mine is C:\Users\Public\Documents\Embarcadero\Studio\22.0\Bpl) or you can use a build event on the project's properties to copy these two class libraries if they don't exist. Another thing is, You don't have to do that because it will work fine when you open any project in the IDE before using this plugin! I'm not sure that this behavior depends on the installed components or libraries or if the IDE loads SSL libraries at the moment you open even a new application. although using the plugin when you are working on a project seems more useful anyways.


Miscellaneous

Presentation: ChatGPT wizard.pptx


Contributors

Special Thanks to


Do not hesitate to star! if you like it take a leap of faith and hit that 'Star' button, also watch the repository to stay tuned with the latest updates, debugs, features, etc. All PRs, discussions, and issues are welcome but please read and check the closed issues before opening a new one to avoid duplicates!

Good luck!


Delphi

Made with ❤️ on Delphi

chatgptwizard's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chatgptwizard's Issues

D10.0 compatibility

D10.0 don't support flowing property:

  LvHttpClient := THTTPClient.Create;
  LvHttpClient.**ConnectionTimeout** := FTimeOut * 1000;
  LvHttpClient.**ResponseTimeout** := (FTimeOut * 1000) * 2;

Errors:

[dcc32 Error] UYouChatThread.pas(160): E2003 Undeclared identifier: 'ConnectionTimeout'
[dcc32 Error] UYouChatThread.pas(161): E2003 Undeclared identifier: 'ResponseTimeout'
[dcc32 Fatal Error] ChatGptWizard.dpk(59): F2063 Could not compile used unit 'UYouChatThread.pas'

ChatGptWizard through delphi application! Is it possible?

Hello Ali
I downloaded and installed your ChatGptWizard in my delphi 13.3 environment. Every thing is fine and I could make my chat very well.
However I have been I struggling very hard to implement this functionality within my delphi application. That will be very nice to combine the power of the ai engine and my application, My students are looking forward for that.
All I need is to be able to execute a function such as the following:
GtpAnswer:=GetGptAnswer(MyQuestion)

I am suscibed to ChatGtp 4.
Please I woukd highly appreciate your assistance with this issue.
Bishara Wakim

Chat Moderation

Hi. I have a question or comment regarding the use of the OpenAI API. In the code, the endpoint "https://api.openai.com/v1/chat/completions" is used. In this process, the prompts from the user are passed to the model unfiltered. Although this is unlikely to be the case often when programming, the user can send prompts to the model that violate OpenAI's rules. I could not find any moderation.

Is this assessment correct?

That would be problematic, as OpenAI is very strict about following the rules. They don't ask questions first, they just close the account. In a company with many people, this would not be so nice.

Canno't install on D10.0

Describe the bug
during compiling dpk got:
[dcc32 Fatal Error] XSuperJSON.pas(1): F2084 Internal Error: AV0D798E88-R00000014-0

Screenshots
obraz

History

D10.2.3
History does not work
Search chate
then go to history. Nothing.
when searching writesonic search goes to chategpt
How do you get to search predefined questions?

Furthermore when copying each line adds a line feed which is not needed
Also, copying did it twice !!!! may chat send it twice?

.

Support for gpt-3.5-turbo

OpenAI has a newer, faster, cheaper (1/10 the cost of the "text-DaVinci-003" model) chat API model called "gpt-3.5-turbo".

Would it be possible to add this as a drop-down option in the Wizard?

typo in predefined question

open ChatGPT menu
open Settings
choose PreDefined Questions tab
the caption for question "Create necessary interfaces for this class in Delphi:" says "Crreate Interface"

needs to say "Create Interface" instead (has double "r")

IsEmpty No answer, try again

When clicking the ASK button, I always get this answer: IsEmpty No answer, try again
Of course, the correct API key has been entered.
There is no verification feedback on the API key.

No history

I had to open new

Now history is bad again and stopped working
Although i am on chatGPT I get this msg

***** WriteSonic *****
Server Certificate Invalid or not present
so I closed writesonic it did not help.
I closed Delphi it was OK BUT
ONLY FOR ONE MSG !!!.
I deleted the history lines run chat NOTHIN NO HISTORY

Can ChatGptWizard be used by a delphi application?

Hello Ali
I downloaded and installed your ChatGptWizard in my delphi 11.3 environment. Every thing is fine and I could make my chat very well.
However I have been struggling very hard to implement this functionality within my delphi application. That will be very nice to combine the power of the ai engine and my application, My students are looking forward for that.
All I need is to be able to execute a function such as the following:
GtpAnswer:=GetGptAnswer(MyQuestion)

I am suscibed to ChatGtp 4.
Please I woukd highly appreciate your assistance with this issue.
Bishara Wakim

Invalid pointer operation

Describe the bug
"Invalid pointer operation" is written in the editor. No response in the Answer box in the ChatGPT dialog window.

To Reproduce

  1. write "cpt:Create a full unit in Delphi including a class to create an XML file.:cpt" in the editor window
  2. Press CTRL+ALT+SHIFT+A
  3. "Invalid pointer operation" is written in the editor.

In the ChatGPT dialog, there is no response in the Answer box when asking a question.

Expected behavior

Screenshots

Desktop (please complete the following information):

  • Windows 11 Pro Version 22H2
  • Chrome Version 111.0.5563.147
  • Delphi 11.2 Version 28.0.46141.0937

Smartphone (please complete the following information):

Additional context

Invalid Pointer Operation

After watching your demo videos, I couldn't wait to get ChatGPTWizard installed and working - it looks fantastic!
I installed it yesterday and asked my first test questions. Initially, I was getting the response "too many request".
But, today I am getting "Invalid pointer operation" (see below).

image

[3A236F67]{ChatGptWizard.bpl} Uchatgptlexer.TcpLexer.GetCurrentUnitPath + $47
[5BEEA5DF]{vcl280.bpl } Vcl.Styles.TCustomStyle.SourceLoaded (Line 3313, "Vcl.Styles.pas" + 1) + $F
[5BCC03CA]{vcl280.bpl } Vcl.Controls.TWinControl.CMInvalidate (Line 12737, "Vcl.Controls.pas" + 9) + $2
[3A236F5E]{ChatGptWizard.bpl} Uchatgptlexer.TcpLexer.GetCurrentUnitPath + $3E
[3A237E3F]{ChatGptWizard.bpl} Uchatgptlexer.TcpLexer.Reload + $1B
[3A23E8C4]{ChatGptWizard.bpl} Uchatgptqframe.TFram_Question.ReloadClassList + $B0
[3A23E640]{ChatGptWizard.bpl} Uchatgptqframe.TFram_Question.pgcMainChange + $20

Remove dependency on Indy

In order to reduce the dependencies on 3rd party libraries for this project and on OpenSSL DLLs it would be nice if the REST requests needed could be done using either System.Net.HttpClientComponent.TNetHTTPClient or System.Net.HttpClient.THTTPClient.

These wouldn't need OpenSSL DLLs for TLS as they'd use the Windows APIs and thus Windows built in TLS support.

Add support for local large language models, (Ollama)

I have a network computer running linux, that I've set up an https://ollama.ai service on.

The steps to start the ollama service are:

installing & running ollama which is a llm server
installing litellm which is an openai emulator
running it.

litellm -m ollama/mistral --port 9000 --drop_params&

Which means I now have an openai compatible port at 192.168.0.15:9000

Unfortunately when I tried using the ChatGPT wizard, it came back with an error "No answer, try again"
On the linux side the message said:
Docs: https://docs.litellm.ai/docs/proxy_server

Worker Initialized

INFO: Application startup complete.
INFO: Uvicorn running on http://0.0.0.0:9000 (Press CTRL+C to quit)
192.168.0.196:50629 - "POST / HTTP/1.1" 405 Method Not Allowed

google show others with this problem.
openai/chatgpt-retrieval-plugin#74

After last update it stops working

HTTP/1.1 404 Not Foun is answer for the Asking.

To Reproduce
Steps to reproduce the behavior:

  1. Setup settings for gpt-3.5-turbo
    image

Go to the Dockable form, set the question and press Ask
image

Could not load SSL library

When running ChatGPT on RadStudio 11.3 installed by GetManager within Delphi 11.3 i'm getting this response 'Could not load SSL library' when clicking on the Ask button.

What ssl libarary needs to be installed?

ChatGPT API key are set in steeings.

The Behavior:
Open ChatGPT on the Menu bar of Delphi
Select Ask ChatGPT
Write a question or just use the template 'Create a class to make a Zip file in Delphi.'
Click 'Ask'
Response : 'Could not load SSL library'

2023-03-30_18-56-42

2023-03-30_18-57-42

2023-03-30_18-58-30

Invalid pointer operation

I installed delphi 10.3 and delphi 11.2, inserted the key and made a request and received a response 404 Not Found.
then I clicked load default values, inserted the key again and clicked save.
depending on the choice of model, the message changes, for example, if you choose gpt-3.5-turbo, the response will already be HTTP/1.1 404 Not Found

Error Too Many Requests

Hi,
I'm receiving an error bellow when I try to ask for ChatGPT plugin on Delphi 11.3.
HTTP/1.1 429 Too Many Requests

I'm used the dll files onto /resources

Thanks

No response to Questiom

Describe the bug
No answer given when click Ask when inside project
Nb. If no project, u get 'Could not load ssl library'... known issue

To Reproduce

Steps to reproduce the behavior:

  1. A project is open
  2. Add new unit & clear
  3. Click ChatGPT Menu to launch Dialog
    Default Q. Create a class to make a Zip file in Delphi.
    Click Ask=NO RESPONSE in Answer

Expected behavior

Response to Q. Create a class to make a Zip file in Delphi.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser - N/A]
  • Version [e.g. 22] : Delphi CE 10.4

Change theme doesn't effect the dockable form.

Describe the bug
Change theme doesn't effect the dockable form and you have to close and open this form to get the new style.

To Reproduce
Just open dockable form, docked or not docked doesn't matter, then try to change the style of the IDE.

Expected behavior
Real time color change same as other IDE components.

Screenshots
image
image

  • OS: windows 11
  • IDE Alexandria 11.1

مشکل فعالسازی در کشور ایران

با سلام
ظاهرا شرکت OpenAI به کشور ایران (خط موبایل ایران )خدمات و کد فعالسازی نمی دهد ؟
برای این موضوع راهکاری دارید؟
با تشکر

History Database Does Not Exist

Click on the History tab In the Dockable window - produces this error:
image

Note: I have History.sdb in ...\Embarcadero\Studio\22.0\CatalogRepository\ChatGPTWizard-2.0\Resources\DB

Delphi 11.3
Windows 11

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.