robert Posted March 20, 2023 Share Posted March 20, 2023 I couldn’t resist the hype and created a simple module using the ChatGPT API to process field values. You can find it on GitHub here: https://github.com/robertweiss/ProcessChatGPT ProcessChatGPT is triggered upon saving, if you select it in the save dropdown. It processes the value of a page field, which can be set in the module config, using ChatGPT. The processed value can be saved back to the same field or to another field on the same page, which can also be set in the module configuration. You can add commands to the value that will be prefixed to the source field content. This way, you can give ChatGPT hints on what to do with the text. For example, you could add ›Write a summary with a maximum of 400 characters of the following text:‹. One of my clients is already using the module to summarise announcement texts for upcoming music events on their website (Let’s face it, nobody reads them anyway ?). If anyone finds it useful, I would be happy to submit it to the official module list. 14 Link to comment Share on other sites More sharing options...
gebeer Posted March 20, 2023 Share Posted March 20, 2023 Nice. Does the module offer a UI under the admin tree? I'm asking because there are naming conventions for PW modules. And the prefix "Process" is usually reserved for modules that have a page associated under the admin tree. Like ProcessPageLister etc. You might want to consider renaming your module before submitting it to the directory. 2 Link to comment Share on other sites More sharing options...
robert Posted March 20, 2023 Author Share Posted March 20, 2023 Valid point, I have to admit I never really noticed this was the reason for the ›Process‹ in the modules names. Thanks for the hint! Link to comment Share on other sites More sharing options...
gornycreative Posted March 20, 2023 Share Posted March 20, 2023 Might I suggest PromptChatGPT Link to comment Share on other sites More sharing options...
wbmnfktr Posted March 20, 2023 Share Posted March 20, 2023 Is it correct that I need to install dependencies via composer? If so... fine. Got that. Another thing: Is there some way to get debug infos if anything was posted or fetched from ChatGPT? Just tried it and can't figure out if it's just ChatGPT that over capacity right now or me/the setup. Link to comment Share on other sites More sharing options...
matjazp Posted March 20, 2023 Share Posted March 20, 2023 Hm, I can't make it work. curl_getinfo($curl, CURLINFO_HTTP_CODE) in OpenAi.php returns 0. I can manually curl just fine, so it's not GPT. Edit: aha, curl_error($curl) gives 'SSL certificate problem: unable to get local issuer certificate'. ok, not exactly recommended, but as a quick fix CURLOPT_SSL_VERIFYPEER => false, or download curl cert and add it to php.ini 1 Link to comment Share on other sites More sharing options...
wbmnfktr Posted March 20, 2023 Share Posted March 20, 2023 1 hour ago, matjazp said: CURLOPT_SSL_VERIFYPEER I can't find this in any of my files in the setup. On the other hand... ChatGPT is offline for me wherever I try. Link to comment Share on other sites More sharing options...
matjazp Posted March 21, 2023 Share Posted March 21, 2023 Sorry for not being clear. CURLOPT_SSL_VERIFYPEER is an option for curl that verify the peer's SSL certificate. When CURLOPT_SSL_VERIFYPEER is enabled, and the verification fails to prove that the certificate is authentic, the connection fails. When the option is zero, the peer certificate verification succeeds regardless. I added this in OpenAi.php, which is used to make HTTP requests to ChatGPT. We could use wireHttp class for that too. Disabling this option is not a way to go, so this was a quick fix to get the response from ChatGPT. Regarding "ChatGPT is offline" error, I couldn't log into my account from my work PC yesterday but could log in from my home PC. It happens from time to time. Try from another computer. Link to comment Share on other sites More sharing options...
robert Posted March 22, 2023 Author Share Posted March 22, 2023 Thanks for all of your comments and suggestions. I renamed the module to PromptChatGPT (thank you @gornycreative for the input!). The renamed repo can be found here: https://github.com/robertweiss/PromptChatGPT Additionally, I have included the composer vendor folder by default, which seems to be a better and easier way to distribute modules. Thanks to @wbmnfktr for bringing this to my attention. Regarding the curl/ssl errors, as you have already deduced, these seem to be linked to the external dependency https://github.com/orhanerday/open-ai. Therefore, if the issues you mentioned persist, we should consider creating a new Github issue there. For easier debugging, I have added a ›test settings‹ option to to verify if ChatGPT responds correctly. I have also included a new option to select templates that should include the dropdown option. 3 Link to comment Share on other sites More sharing options...
kongondo Posted March 22, 2023 Share Posted March 22, 2023 On 3/20/2023 at 1:36 PM, robert said: Valid point, I have to admit I never really noticed this was the reason for the ›Process‹ in the modules names. Thanks for the hint! For reference: https://processwire.com/docs/modules/types/ 1 Link to comment Share on other sites More sharing options...
wbmnfktr Posted March 22, 2023 Share Posted March 22, 2023 The new version looks good and while testing the settings worked out pretty well, I now get this error: I checked my account and quotas are fine. Even billing settings are enabled/set. Link to comment Share on other sites More sharing options...
robert Posted March 22, 2023 Author Share Posted March 22, 2023 Hmm, this is weird. Does the error message already show up on the module config page or while saving a ›real‹ page and choosing ›Save + send to ChatGPT‹? For reference, the attached screenshot shows my feedback which works without errors. 1 Link to comment Share on other sites More sharing options...
gornycreative Posted March 22, 2023 Share Posted March 22, 2023 I got that as well, though my credits were under a different account. 1 Link to comment Share on other sites More sharing options...
gornycreative Posted March 22, 2023 Share Posted March 22, 2023 59 minutes ago, wbmnfktr said: The new version looks good and while testing the settings worked out pretty well, I now get this error: I checked my account and quotas are fine. Even billing settings are enabled/set. I meant I got this result, not the developer's result.. 1 Link to comment Share on other sites More sharing options...
robert Posted March 22, 2023 Author Share Posted March 22, 2023 Ok, I created a new account at Open AI and generated a test API key, then I got the same error message as you. After adding a payment method, still no luck. But then I generated a new key AFTER adding the payment method, and now it works. Could you check if that works for you too? 1 Link to comment Share on other sites More sharing options...
gornycreative Posted March 22, 2023 Share Posted March 22, 2023 Okay, I got a proper answer once I switched to an account with credits. Awesome. { "request": { "model": "gpt-3.5-turbo", "messages": [ { "role": "user", "content": "This is a test for ChatGPT. Do you hear me?" } ] }, "response": { "id": "chatcmpl-...", "object": "chat.completion", "created": 1679504670, "model": "gpt-3.5-turbo-0301", "usage": { "prompt_tokens": 21, "completion_tokens": 18, "total_tokens": 39 }, "choices": [ { "message": { "role": "assistant", "content": "\n\nYes, I can hear you loud and clear! How can I assist you today?" }, "finish_reason": "stop", "index": 0 } ] } } 2 Link to comment Share on other sites More sharing options...
robert Posted March 22, 2023 Author Share Posted March 22, 2023 I think I should add some infos about generating a working API key in the readme ? 2 Link to comment Share on other sites More sharing options...
wbmnfktr Posted March 22, 2023 Share Posted March 22, 2023 Ok... now we are talking! Adding billing details is necessary and creating a new API key afterwards probably as well. Did both and everything is up and running. Just did a small test and generated a full article just by giving a topic and a predefined action in the settings. Love it! Additional note: just switched back to my primary account, created a new API key there and it works there as well. 1 Link to comment Share on other sites More sharing options...
wbmnfktr Posted March 23, 2023 Share Posted March 23, 2023 FYI So... this might be another hiccup or something but... after a few hours I tried to generate more content, yet... that was my feedback. Tried it a few few times. Like a warm-up for API, yet no success. The key I used (double checked), was my most recent key I created, which worked just a few hours ago in several tries successfully. Limits/Usage was all green (aka: totally fine). $120/month (with $0,00 in my account) - so that shouldn't be the problem, I guess. ¯\_(ツ)_/¯ I created another new API key... and tried again... and it worked out as planned. Can't say more about what this was or what might have happened here. Just as a feedback. Link to comment Share on other sites More sharing options...
gornycreative Posted April 8, 2023 Share Posted April 8, 2023 Can I throw another log onto this fire? Today I installed a local instance of oobabooga and vicuna. It looks like text-generation-webui has an API mode that can be set to listen for JSON prompt requests! It would be great to either fork PromptGPT or develop an option to select alternative API endpoints, etc. I used this tutorial to guide the install - with the exception I also needed to install NVIDIA CUDA toolkit to get access to CUDA cores from pytorch. 1 Link to comment Share on other sites More sharing options...
gebeer Posted April 9, 2023 Share Posted April 9, 2023 @gornycreative guess you meant to post this at ? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now