Install Edly AI_Coach_XBlock fail

I am not sure if this is the right place to ask for help. I tried to install AI_Coach_XBlock from https://github.com/edly-io/ai-coach-xblock and after setting advance module list, I do not see the “AI Coach” after pressing “Advanced component” of course unit. Here are my steps:

  1. pip install ai-coach-xblock
  2. Update Settings of LMS and CMS - Add the OPEN AI secret key in the lms and cms configuration files:
    2.1) \env\apps\openedx\config\cms.env.yml
    2.2) \env\apps\openedx\config\lms.env.yml

Add the following:
OPENAI_SECRET_KEY:‘my_openai_secret_key’
3) tutor local launch
4) Update course advanced settings by adding ai_coach
5) At course unit, click “Advanced component”, but AI Coach is not found.

I check the error log using the command suggested by @Mahendra.

tutor local logs --follow cms --tail=100 -f

And the attach is my log file.
cms log - 15 Oct 24.txt (36.6 KB)

There is error about item not found. I am not sure what is it about. And
I am quite new about plugin, is there anything I did incorrectly, please let me know. Thank you very much.

Hi @N_V,

  1. Could you please share the Tutor version you are currently using?
  2. Additionally, are you running Tutor in dev mode or local mode?

If you’re using tutor local, please follow these steps:

  • Add ai-coach-xblock to OPENEDX_EXTRA_PIP_REQUIREMENTS and run tutor config save.
  • Rebuild the openedx image using tutor images build openedx.

Also, make sure to add your OPENAI_SECRET_KEY in the following files:

  • env/apps/openedx/settings/lms/production.py
  • env/apps/openedx/settings/lms/development.py

Apply the same changes to the CMS settings as well.

If you’re using a plugin to update the settings, that will ensure the changes persist. Otherwise, these changes might be overwritten when running tutor config save.

Thanks for your advice.

My Tutor version is 18.1.3.
My OpenEdX version is Redwood.2

I follow your advice and it works. Thanks a lot.

@hinakhadim I tried to follow your solution but it still does not work… Please help.

Here is how I setup tutor

python -m pip install --upgrade tutor[full]
tutor local launch
tutor --version
tutor, version 19.0.0
python --version
Python 3.9.18

I tried to add the following line to the config

nano "$(tutor config printroot)/config.yml"
OPENEDX_EXTRA_PIP_REQUIREMENTS: ['ai-coach-xblock']
tutor config save
tutor images build openedx

I verified the installation

tutor local run cms bash
~/edx-platform$ pip show ai-coach-xblock
Name: ai-coach-xblock
Version: 1.0.7

I did get a warning during the build about a missing dependency “importlib_resources” but I don’t think this is related to the issue…

I tried to set the openai key


nano "$(tutor config printroot)/env/apps/openedx/settings/lms/production.py"
nano "$(tutor config printroot)/env/apps/openedx/settings/lms/development.py"
nano "$(tutor config printroot)/env/apps/openedx/settings/cms/production.py"
nano "$(tutor config printroot)/env/apps/openedx/settings/cms/development.py"

OPENAI_SECRET_KEY = "key"

I then tried to add “ai_coach” under a course advanced settings like this:


Advanced module list
[
    "edx_sga",
    "lti",
    "scorm",
    "library_content",
    "annotatable",
    "poll",
    "survey",
    "ai_coach"
]

and still when I go to unit->components->advanced I don’t see the ai_coach

So I also tried
tutor local restart

And I cleared the cache in the browser and in the build, yet still I don’t see the component.

I will really appreciate your help. Thanks.

In the logs I found this:

tutor local logs lms

lms-1  | Traceback (most recent call last):
[...]
lms-1  |   File "/openedx/venv/lib/python3.11/site-packages/ai_coach/__init__.py", line 1, in <module>
lms-1  |     from .ai_coach import AICoachXBlock
lms-1  |   File "/openedx/venv/lib/python3.11/site-packages/ai_coach/ai_coach.py", line 8, in <module>
lms-1  |     import importlib_resources
lms-1  | ModuleNotFoundError: No module named 'importlib_resources'

so here is what I did:

nano "$(tutor config printroot)/config.yml"
OPENEDX_EXTRA_PIP_REQUIREMENTS:
- importlib_resources
- ai-coach-xblock

tutor config save
tutor images build openedx

I verified the installation with

 tutor local run cms bash
~/edx-platform$ pip show importlib_resources
Name: importlib_resources
Version: 6.5.2

I checked both cms and lms logs and now I don’t see any errors

tutor local logs lms
tutor local logs cms

But still there is no option for ai_coach…
So I tried tutor local restart.

I also realized each time I was building I was overriding the openai key so I added it to the main config file

nano "$(tutor config printroot)/config.yml"
OPENAI_SECRET_KEY: key

but I noticed after the build it doesn’t add the key to the cms and lms config files so I manually added the key to each one again and then I did tutor local restart…

I am looking at the course through the studio UI with the user created with this command:
tutor local do createuser --superuser --staff super super@example.com -p super

I am fairly new to openedx and I am not familiar with plugins, I am still looking for a method to resolve this issue,
Thank you.

Hi @Terak,
Thanks for sharing detailed logs for the error. I verified that this is not working due to importlib_resources. The Fix PR has been created and will be merged after review.

Hi @hinakhadim

I’m also having issues with the openedx-cmi5-xblock. I assume it has the same issue in sumac since it also has that import.