Bengaluru
Account created on 25 September 2013, almost 11 years ago
  • Senior Consultant at Infosys 
#

Recent comments

🇮🇳India anup.sinha Bengaluru

Hi @wil2091, thanks for the patch. It is now included in the latest release.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @piyush1108, yes Drupal 10 has CKEditor 5 inbuilt into the Drupal core. So no need to install CKEditor again using composer.

Glad to know, you got it worked. Thanks.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @marcusvsouza,

Many thanks for reporting the warning message and creating the patch. However, the correct patch would be opposite of what you have attached. In the previous version of the branch the library was added as "ckeditor" which was causing the warning message. Now I have updated it to "core/ckeditor" in order to fix the problem. I have validated the fix from my end and it resolved the issue.

So below is the correct change, opposite of the attached patch. I am sure you also did the same fix, but maybe when you created the patch there was some mistake.

- - ckeditor
+ - core/ckeditor

Commit - https://git.drupalcode.org/project/chatgpt_plugin/-/commit/b922987fd5a77...

Please validate the latest dev version - https://www.drupal.org/project/chatgpt_plugin/releases/2.0.x-dev and confirm.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @bogdog400, I have done an update in the configuration page. Now you can choose content types for which you want to enable this AI assistance feature. Just go to the OpenAI configuration (/admin/config/chatgpt) page and select the content types and then save. This should fix your error.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Closing this ticket as I have received feedback from users of this module that they are able to save configuration form successfully without any issue.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Closing this issue as the request has been clarified.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @W01F, currently there is no free OpenAI models. Here you can check the pricing for API call - https://openai.com/pricing . Like for curie model the price is $0.0020 / 1K tokens (approx. 750 words).

When I registered at the start of January, OpenAI gave me free 20 dollars credit. So can you please check your account page if it's showing any such free credit, otherwise you have to recharge your account as the API calls are not free.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @ressa, can you please test if the admin config form is working for you or not in order to close this ticket.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @ressa, the problem is if we are giving title like "blockchain article" then the prompt my plugin is sending like "Translate the following text into "- [Language] - "blockchain article". But instead of simply translating "blockchain article" into dutch or french, GPT API is writing an entire article in Dutch or French. As a result the title translated title is exceeding the max length of the field data column value of 255 chars.

So it's a problem with GPT3 API that sometimes it's not able to understand if it should translate the text "blockchain article" or it should write an article in dutch. I have modified the translation prompt for better result. Please download the 2.0.x branch and validate. Please clear your cache as there are changes in routing file.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @Avanishyadav, thanks for working on it but your profile name is showing Avanishyadav but when I checked the commit it's showing "Luděk Kvapil". Sorry I am not going to merge it as your profile - https://www.drupal.org/u/avanishyadav looks like spam profile.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @ressa,

Please check the readme file 2.0.x branch. I already added a new section like this -

"**Act as a Content Assistance Tool:**
This will add a new tab called "OpenAI Content Assistance Tool" in the
content admin page (admin/content) and will give you give you different options
like creating images from texr, extracting SEO keyowrds from a content etc."

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @siva01 and @ressa,

I have refactored the code completely by introducing two new Drupal service - 1 for GPT model and another for DALL.E. Please download this version - https://www.drupal.org/project/chatgpt_plugin/releases/2.0.x-dev for the new refactored code or you can check this commit -
https://git.drupalcode.org/project/chatgpt_plugin/-/commit/1aa6c42f096f5... .

I have tested all the existing scenarios and can confirm the refactored code is working as expected. Request you guys also to validate and let me know please if there is any issue.

Also I am planning to incorporate the newly released GPT3.5 API by this weekend.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @siva01, now dev branch is showing in release. PFA the screenshot. It seems we have to tag at least one release after a creating a branch to show the dev branch.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @ressa, thanks for letting me know. I started this as my personal project with the support from my organisation. So I want to continue with the same objective to keep it as a light weight module and a very simple content assistance tool. I don't want to overwhelm our content editors with too many links and features in the content creation page.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @siva01, I totally agree with you that we should create a service for code reusability. I just created a new branch - 2.0.x from 1.0.x. Please create your merge request against 2.0.x.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @ressa, I will keep this in mind going forward. Also dev branch is in active development state, so apology for the issue. Now it has been fixed , please try again.

Also added two new features -

1. Content translation -> if you go to the content translate tab, you will see a chatgpt translation link for simple text content translation.
2. OpenAI assistance tool -> in admin section, you will see a link for OpenAI Assistance Tool where you will be able to generate images from text using DALL.E model.

Request you to validate this new feature and share your feedback.

Thanks,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @omkar_yewale, many thanks for the patch. Indeed it will be helpful to get the configuration link on the module listing page. It has been now added into the dev branch. Thanks again for the effort.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @siva01, your changes have been incorporated now into the dev branch by doing little bit of text changes. Thanks again for suggesting this change. Really appreciate your efforts.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @siva01, many thanks for this change request and working on it. I have found lot of scenarios where we don't need this chatgpt api call access to authenticated users. So you are absolutely right that we need custom permission to manage the access efficiently. So I will review your change request and will merge it.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @ressa , thanks I have merged it as the the changes look good to me.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @siva01, I already checked your merge request. As per your merge request, "use chatgpt search form" permission will allow users to use the ChatGPT search form. By default for all the custom permissions, it will be checked for the admin roles in permission page. So for your custom "use chatgpt search form" permission still admin users need to go to the permission page and need to check it for authenticated users. Otherwise authenticated users will not be able to access it and that is why I said that it will overcomplicate the configuration part.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @siva01, First of all many thanks for checking out my module.

I wanted to keep the configuration as simple as possible. Below are the explanation for my permission -

1. I would not want to give access to the API config page anyone except site administrator as it has the secret access token.
2. For a blog or forum site, authenticated users also need to have the access to the content creation page.

Now if we add custom permission, people also need to check permissions for different role like authenticated users from the permissions page to make this module work which will overcomplicate the configuration part as per my opinion.

So request you to provide more explanation or a scenario when we need a custom permission for this module. This will help me to analyse your requirement.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @ressa, thanks for the suggestion to increase the max length of the prompt text. I have merged your pull request. Also released another version 1.0.2 of the module with an important fix to to preserve the line breaks received from ChatGPT API as it is.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @d0t101101, many thanks for trying out my module and glad that you liked it. Also thanks for observing the formatting issue. I have investigated this issue further and found that ChatGPT API is actually sending the line breaks in the API response.

So I have fixed that issue and released a new version of the module 1.0.2. Please validate it and confirm.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Change record added for the new hook - hook_user_mail_language_alter().

🇮🇳India anup.sinha Bengaluru

Hi All,

As per my analysis, we have to modify the below test method.

File - \core\modules\user\tests\src\Unit\Plugin\Core\Entity\UserTest.php
Test Function Name - testUserGetRoles()

But the problem here is that the authenticated/anonymous role is being set through the createUserSession() method not testUserGetRoles() method. So we have to modify the parameters of the createUserSession() function like below and set the anonymous role only when it is set. But then I have to modify the arguments in the parent class UserSessionTest as well.

protected function createUserSession(array $rids = [], $authenticated = FALSE, $anonymous = FALSE) {
$id = '';
if ($authenticated) {
$id = 2;
}
elseif ($anonymous) {
$id = 0;
}

So just wanted to check if anyone has a better solution to add the test coverage for this change.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @All,

I have validated the latest patch and the newly created hook is not working. I have implemented the new hook in my custom module and getting the below error -

[03-Feb-2023 12:36:33 Asia/Kolkata] Uncaught PHP Exception Error: "Cannot use object of type Drupal\Core\StringTranslation\TranslatableMarkup as array" at C:\wamp64\www\drupal-10.0.0\modules\custom\content_view_alter\content_view_alter.module line 14

Line #14 - "if (isset($column['data']['#type']) && ($column['data']['#type'] === 'operations')) {"

Also please whenever a new hook is created, make sure we add a new test for it as the code added in api.php will have no impact until we are implementing it. So it's very important to have a test for any hook. Changing the ticket status to Needs work.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @hchonov, Can you please reply to Antoniya's question why a condition for a specific language.

Also I think this should be a high priority task as currently we don't have any option to alter the translate overview table. This is really a blocker if we want to add a button for any content translation service or do any modification into that table.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @ressa, thanks for the link. It's a great tool to count number of tokens. I have added the tool link on the help info section of Max Token setting.

Thanks,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @Prabu,

The automated test bot actually tried to test your merge request instead of the patch. As a a result it failed as there are no changes in that merge request. So request you to close that merge request if you are not planning to use it and put the issue status to needs review.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @Utilvideo,

Now I have found out why my earlier patch failed to apply for the automated test run here but working fine in local. I created the patch from 9.5.0 as this was the installed version in my local but here for the automated test run the version is 9.5.x. The dictionary.txt file is different in 9.5.x compare 9.5.0 and that is why the last patch failed to apply here.

So here is my updated patch created for 9.5.x version.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @Lee,

Thanks for the update. I have reverted all the unwanted changes and created a new patch which contains changes required for this fix only. PFA the updated patch.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @ressa,

I have added the help texts as suggested by you and also marked which fields are required. All the changes have been committed into the branch - 1.0.x.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @ressa,

Actually earlier the folder structure was chatgpt_plugin/chatgpt. Now in the 1.0.0 version I moved out all the code from chatgpt folder to direct chatgpt_plugin to remove the sub-folder but I forgot to rename the files and namespaces. Thanks for reporting the bug.

I have done all the changes and committed it into in the branch 1.0.x. Please test the chatgpt_plugin 1.0.x-dev version and let me know please if there is any more issue.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @Lee,

Please find below my response -

Comment #41 - 2. As you can see in my new patch #42, the new test function testNotificationEmailAddressNotSet has been deleted and the new testcases have been included in the existing testNotificationEmailAddress test itself.

Comment #41 -1. As I mentioned in my comment #42 - The changes which are out of scope are actually code review comments given by Jess in comment #18 for my new test. Like we should not use random function to generate username, in assertCount third message parameter is no longer used etc. As now both the tests are merged, so I believe those code review comments given by Jess are in-scope now.

Please let me know if I should revert these changes, then I will create a new patch.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hello Everyone,

All the code review comments have been addressed and committed into the branch - 1.0.x . Please validate the same and let me know please if there is any observation.

Git repo URL - https://git.drupalcode.org/project/chatgpt_plugin
Branch - 1.0.x

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @ressa,

Many thanks for the observation. I have merged your pull request.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @apaderno,

No, I don't have any other module or theme as I recently started contributing to Drupal org. This is the first ever project I have published on Drupal.org.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @apaderno,

Many thanks for your update. I have almost 10 years of experience working with Drupal CMS but I started contributing to Drupal org really late in my career. I started working on Drupal org core issues just 5 months back. Below are the three patches I have currently worked on, also here is my linkedin account - https://www.linkedin.com/in/anup-sinha-12650b72/. I have recently got my community role also in Drupal org for being an active users and frequent participation. PFA the screenshot for the same. I hope this helps you to evaluate my Drupal skill.

Drupal 10 patch:
1. https://www.drupal.org/project/drupal/issues/3266529 🐛 Password reset invalid mail notify language Needs work
2. https://www.drupal.org/project/drupal/issues/2926529 🐛 Route with space at the end does not work Needs work
3. https://www.drupal.org/project/drupal/issues/3201472 🐛 Clarify via the field description that the notification email address is used for the reply-to address, not the from address Needs work

Patch review:
1. https://www.drupal.org/project/drupal/issues/3331212 📌 Remove unused variable $result from MoveTest Fixed

Also this is the only ChatGPT Drupal plugin currently available in the Drupal org. So lot of people want to use it in their real live projects as ChatGPT is really hot in the market right now and it can be huge beneficial for the content team. This is why I wanted to opt this project into security advisory coverage.

Also all the code review comments are already addressed except #7 (httpClient method instead of cURL) on which I am already working on. Let me know please if there is any other info you need from me for this module.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi Lee,

Thanks for reviewing the code. I agree with you that we should alter the value only when notify email is set. Also merged the new test into existing one. Here is my updated patch.

Also the changes which are out of scope are actually code review comments given by Jess in comment #18 for my new test. Like we should not use random function to generate username, in assertCount third message parameter is no longer used etc. So at that time I thought if we are fixing these issues in new test then fix those problems in existing one as well. Currently both the tests are merged, so I think these are in-scope now.

@smustgrave, could you please retest? Both the scenarios are covered in our unit test - 1. when notify mail is set, from address should be notify mail 2. when notify email is not set, from address should be site email.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @bogdog400,

First of all, many thanks for trying it out. Looks like you are trying it out in your local Drupal setup where the base URL is not configured. I have provided relative path in the form href as Drupal will automatically append your base URL with the relative path. If you want to try it out in your local, you can set a local URL like "drupal10-local" to your site using virtual host config in Apache. Please follow the step below -

Link Broken Issue:
1. open this file - wamp3.2\bin\apache\apache2.4.51\conf\extra\httpd-vhosts.conf
2. Add a virtual host for your Drupal 10 site like this. I have the exact sub folder D10 setup which you are referring in my local.


ServerName drupal10-local
ServerAlias www.drupal10-local
DocumentRoot "${INSTALL_DIR}/www/drupal10dev/web"

Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local

3. Now your ChatGPT link will come as - http://drupal10-local/chatgpt/search_form and it will work. PFA the screenshot from my local setup.

I hope this answer your query as we should not use full URL in form href.

API Error:
PFA ChatGPT_API_Config.png to know how your API configuration should look like. Endpoint should be - https://api.openai.com/v1/completions. Also if you want to enable SSL for cURL call, please go through the "*** Important Info" part in the module description page - https://www.drupal.org/project/chatgpt_plugin . ChatGPT will not allow you make cURL call if it's not a secure connection.

I hope with these two explanations you are able to run the plugin in your local setup. Please send me your API config details if you are still having issues (remove the access token part while sending.)

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @Utilvideo, I was just thinking that it would be good if we can integrate the patch into Drupal core as the issue exists in Drupal 8, 9 and 10 versions. Please let me know your thoughts on this.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @smustgrave,

Can we now merge this patch into Drupal 10 branch if everything looks good to you.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi Lee and Jess,

Can you please now commit this patch into Drupal 10 branch if everything looks good to you.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @Utilvideo,

I am happy to hear that the solution is working as you expected. So can you please now merge it into 9.5 and 10 branches if everything looks good.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi Lee,

PFA the latest patch by altering the from address from hook_mail() in user.module. Also $params['from'] was not setting the from address, then by checking the doMail() function I found out that it's actually $message['from'] variable through which we can alter the "FROM:" address.

Request you to review this patch and let me know please if it looks good to you.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Hi @quietone,

Old code in 9.2.x branch:
// Copy the file over itself. Clone the object so we don't have to worry
// about the function changing our reference copy.
$result = file_move(clone $source, $source->uri, FILE_EXISTS_REPLACE);
$this->assertFalse($result, t('File move failed.'));
$this->assertEqual($contents, file_get_contents($source->uri), t('Contents of file were not altered.'));

The file was changed in 9.3.x release in this commit - https://git.drupalcode.org/project/drupal/-/commit/64074071d1c78274df253...
Issue link - https://www.drupal.org/project/drupal/issues/3223209

Here deprecated file_move() function was replaced with service method fileRepository->move(). Now earlier there was an assertFalse() as file_move() function returns TRUE/FALSE but the new service move() function either returns the File entity or throws exception in case of errors. So we cannot use the old assertFalse() check anymore.

So as per my analysis current patch is fine as no test coverage is removed. Request you to check the mentioned commit and let me know please if there is any observation.

Thanks & Regards,
Anup

🇮🇳India anup.sinha Bengaluru

Here is an updated patch by fixing the error from previous uploaded patch.

Thanks,
Anup

🇮🇳India anup.sinha Bengaluru

Hi Jess,

Here is my updated patch where the "From" email address has been passed from the user module - _user_mail_notify() function. The changes are as below, also attached the interdiff.

  1. Added a new parameter "$from" for mail() function. I thought if we have every parameters available in the function even the "reply-to" then why not $from param.
  2. Also initialized the param as NULL and added it as the last param so that it will not break any of our existing code.
  3. Now in the doMail() function, I have added the check if the $from param is available then use that as from address, otherwise our default site address.

Right now we don't have any option to set the from address while using Drupal mail() function, so this will allow us to use our custom from address as well. Let me know your thoughts please on this patch. Otherwise, I can just alter the $message['headers']['FROM'] value in user_mail() function as suggested by Lee and can create a new patch.

Thanks & Regards,
Anup

Production build 0.69.0 2024