Closed pidaback closed 6 months ago
@pidaback Thanks for the note - we are taking a look at this bug.
Hi @pidaback, can you please provide more info about your plugin instance settings, are you using chat or assistant, etc. Thank you for your feedback.
Thank you so much for looking into this so quickly!
It depends on the language model:
Apparently $10 or $15 need to be available to use assistants with GPT-4. Possibly such a restriction also applies to the chat type.
I will get back to you on this soon. For now, I think the only problem here is a misleading error message.
Yeah, I just tested it and it works fine with ChatGPT 4 in both the regular chat and in with the Assistants. So I think this is just an issue with what the account will allow.
But you said you got a werid 404 error? Can you explain the circumstances that created it? Not enough money in the account and you had chosen GPT4 as the model? Is that right?
The 404 occurs whenever I use a GPT-4 model. I can only speculate there’s a minimum balance required to use GPT-4 (see the link in my previous reply).
This is from the JavaScript console in Chrome DevTools:
first.js:3274
POST http://localhost:8080/mod/maici/api/completion.php 404 (Not Found)
createCompletion @ first.js:3274
(anonymous) @ first.js:3274
tryCatch @ polyfill.js:4
invoke @ polyfill.js:22
(anonymous) @ polyfill.js:9
asyncGeneratorStep @ first.js:3274
_next @ first.js:3274
Promise.then (async)
asyncGeneratorStep @ first.js:3274
_next @ first.js:3274
(anonymous) @ first.js:3274
(anonymous) @ first.js:3274
(anonymous) @ first.js:3274
This is from the network tab:
Request URL: http://localhost:8080/mod/maici/api/completion.php
Request Method: POST
Status Code: 404 Not Found
Remote Address: [::1]:8080
Referrer Policy: strict-origin-when-cross-origin
In DevTools, I don't see any response. In Postman, I get the following response (but status 404 as well):
<div class='alert-danger'>Exception - Attempt to assign property "prompt_tokens" on null</div>
<div class='alert-danger'>Coding error detected, it must be fixed by a programmer: The course you passed to
$PAGE->set_cm does not correspond to the $cm.</div>
The first message is related to your code, the second probably not. There may be a more general problem that makes moodle return this error page with a 404 status.
Hmm. Okay, we'll take a look and see if wte can get a better handling of this error condition. thanks!
Hi @pidaback please check latest changes. We added additional response error info directly in chat.
Thank you! Since our account on openai.com is charged now, I can't check if your commit fixes the bug I originally reported.
However, I was able to create a similar situation by setting up a MAICI activity with an assistant that I later removed from our OpenAI account.
With both the old and new versions of your plugin, I get error 404 for requests to completion.php and "Error..." appears in the text input. I have to open DevTools to get information about the cause of the error: The response for the request to completion.php contains "No assistant found with id 'id>'". Your new code does not catch this because in this case, $response is never created in completion.php.
I don't think this problem will occur often, but I wanted to let you know that your approach will not catch all errors where a request to completion.php fails.
I have installed the main branch both locally and on a test server. Installation and creating an activity in moodle went flawlessly.
However, when I try to send a message, completion.php is not found. The server responds with 404 to requests sent to http://localhost:8080/mod/maici/api/completion.php (on my development machine using Docker) or https://example.com/mod/maici/api/completion.php (where example.com stands for my test server). This is about the request in the createCompletion() function in the JavaScript file.
When I copy the request as cURL from Chrome DevTools and send it via Terminal or Postman, I get a response.
We are very excited about the development of this plug-in. The possibility to work with different system prompts within a moodle instance and to set limits per user or time period - this is exactly what we are currently looking for!