Limekiller / moodle-block_openai_chat

An AI chat block for Moodle, powered by GPT
https://moodle.org/plugins/block_openai_chat
GNU General Public License v3.0
27 stars 15 forks source link

Empty Response on 2.0.0 with GPT4 #39

Closed WolfgangWeigl closed 5 months ago

WolfgangWeigl commented 5 months ago

Hi there,

I use this Moodle plugin (2.0.0) on Moodle 4.2 with the GPT4 model in the chat settings.

If I make some requests, there are only empty responses:

BlockChatBug

Is this a bug only on my Moodle system, or is it a general bug?

Thanks!

Limekiller commented 5 months ago

Thanks for the report -- I haven't seen this issue before. If you look in the network tab of your browser's developer console, you should see a POST request to "/blocks/openai_chat/api/completion.php" for each chat request. Could you please let me know the value of the response for one of these requests when the message is empty?

Additionally, please provide as much information as you can about your environment. What browser + version, what Moodle version, and what specific plugin and block settings are you using?

OkorrDev commented 5 months ago

I have the same issue as WolfgangWeig. I am in Moodle 4.1.1. The plugin was working perfectly until the latest update.

Limekiller commented 5 months ago

I've done some testing and discovered that this issue can appear when passing invalid arguments to OpenAI when using the chat API. In the first example I found, this issue could be triggered by setting the "max tokens" setting to 0 (max tokens must be at least 1). Similar behavior can be triggered by using invalid values for other settings in the advanced section.

@OkorrDev , since you didn't provide the documentation I asked for in my previous comment, I can't know specifically what issue you're running into, but I pushed a new branch that will detect these types of errors and print them in the chat window when they're encountered. Please try switching to the release-2.0.1 branch and let me know if you see an error in the chat window, and if so, what it says. I'd also recommend auditing your setting values in the advanced section and making sure they are valid (assuming you're using the chat API).

WolfgangWeigl commented 5 months ago

Thanks for the report -- I haven't seen this issue before. If you look in the network tab of your browser's developer console, you should see a POST request to "/blocks/openai_chat/api/completion.php" for each chat request. Could you please let me know the value of the response for one of these requests when the message is empty?

Additionally, please provide as much information as you can about your environment. What browser + version, what Moodle version, and what specific plugin and block settings are you using?

I wanted to reproduce the error to check the status code, but now the plugin works.

The browser I am using is Firefox 121.0.1 (64 bit), the Moodle version is 4.2.1 (Build: 20230612), the plugin is version 2.0.0 (Build: 2024010300).

The plugin settings are all set to default:

And the block settings are:

Maybe it works now because a credit card is now stored in the OpenAI account.

If this is the case, it would be helpful if you could check whether the API key is linked to a paid OpenAI account. And if not, an error message would be great.

Thanks for your quick efforts!

OkorrDev commented 5 months ago

Thanks @WolfgangWeigl. I had the same issue. I will do credit card registration too and see if it works.

OkorrDev commented 5 months ago

"If this is the case, it would be helpful if you could check whether the API key is linked to a paid OpenAI account. And if not, an error message would be great."

I agree with this.

Limekiller commented 5 months ago

Awesome, thanks for the details! Good to know about the credit card. It sounds like your API requests were triggering errors (due to the billing issue) which was causing the empty messages -- so the same bug that I had identified, just triggered under different circumstances. The latest 2.0.1 update will identify these types of errors and print them in chat so that admins aren't stuck with no feedback as to why it isn't working. Thanks again for the report!

OkorrDev commented 5 months ago

Thanks Bryce. This is a very good plugin. There is one bug that I have experienced since I started playing around with the app on mobile devices. Will create a new thread tomorrow.

On Tue, 23 Jan 2024, 18:51 Bryce Yoder, @.***> wrote:

Awesome, thanks for the details! Good to know about the credit card. It sounds like your API requests were triggering errors (due to the billing issue) which was causing the empty messages -- so the same bug that I had identified, just triggered under different circumstances. The latest 2.0.1 update will identify these types of errors and print them in chat so that admins aren't stuck with no feedback as to why it isn't working. Thanks again for the report!

— Reply to this email directly, view it on GitHub https://github.com/Limekiller/moodle-block_openai_chat/issues/39#issuecomment-1906494177, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6QIJYS2BC6WUSXWAN77TVLYP7TCFAVCNFSM6AAAAABCBTZACWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMBWGQ4TIMJXG4 . You are receiving this because you were mentioned.Message ID: @.***>