Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create a new MAICI activity #6

Open
nadavkav opened this issue Apr 20, 2024 · 3 comments
Open

Unable to create a new MAICI activity #6

nadavkav opened this issue Apr 20, 2024 · 3 comments

Comments

@nadavkav
Copy link

nadavkav commented Apr 20, 2024

I was asked to input APIKEY although I saved one on the module admin settings.
and even when I input a proper key I got "invalid key missing"

I found out that the validation logic was looking for an assistant key. (which I did not use or selected)

if((!isset($data['defaultapikey']) && empty($data['apikey']))
            || (!isset($data['defaultapikey']) && !maici_fetch_assistants_array($data['apikey']))){
            $errors['apikey'] = get_string('apikeyerror', 'mod_maici',$maxtokens);
        }

I changed || to && , to workaround it
and then got another validation issue:
I was failing file attachment validation: $file_val
lib/formslib.php

$this->_validated = ($internal_val and $element_val and $moodle_val and $file_val);

so I upload a PDF (to workaround it, although I was not using the assistant)
and then, when all validation was "clear", I got DB insert error "assistant field can not be null"

<FIELD NAME="assistant" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" COMMENT="The name of the activity module instance"/>

I change it to "can be null" as I did not use any assistant.

Finally, I manage to create a new chat activity and use it :-)
which works very very nice!

@caiocarvalhofre
Copy link
Owner

Hello @nadavkav, please check if you provided correct OpenAI API key. Plugin checks if API key you provided in global settings is correct. If not you have to add API key in new module instance.
API key is checked by sending request with provided API key.

@nadavkav
Copy link
Author

@caiocarvalhofre , the OPENAI KEY was fine

@caiocarvalhofre
Copy link
Owner

Hi @nadavkav, can you please re-test it. We added addition apikey validation when creating new MAICI activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants