Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-85106

Explain text tokens not shown in AI usage report

XMLWordPrintable

    • MOODLE_500_STABLE
    • MOODLE_500_STABLE
    • MDL-85106-main
    • Hide

      Setup

      1. Log in as admin
      2. Go to Site admin -> General -> AI -> AI providers
      3. Click 'Create a new provider instance'
      4. Choose 'OpenAI API provider' and fill out all other required values (reach out if you need credentials)
      5. Ensure 'Explain text' action is enabled on the provider
      6. Ensure your new AI provider is enabled too
      7. Go to Site admin -> General -> AI -> AI placements
      8. Enable 'Course assistance placement'
      9. Create a course
      10. Add a 'Page' resource and add anything you like as the content.
      11. View the page and click 'Explain' from the AI features actions.
      12. Ensure it generates a response (we will need this for the next part).

      Test

      1. Go to Site admin -> Reports -> AI reports -> AI usage
      2. CONFIRM you see the 'Explain text' entry in the report table
      3. CONFIRM you see numeric values in the 'Prompt tokens' and 'Completion tokens' columns
      4. Click the 'Filters' button
      5. Set 'Prompt tokens' to 'Greater than' and enter 0
      6. Set 'Completion tokens' to 'Greater than' and enter 0
      7. CONFIRM you see the same record displayed for your 'Explain text' action
      Show
      Setup Log in as admin Go to  Site admin -> General -> AI -> AI providers Click 'Create a new provider instance' Choose 'OpenAI API provider' and fill out all other required values (reach out if you need credentials) Ensure 'Explain text' action is enabled on the provider Ensure your new AI provider is enabled too Go to Site admin -> General -> AI -> AI placements Enable 'Course assistance placement' Create a course Add a 'Page' resource and add anything you like as the content. View the page and click 'Explain' from the AI features actions. Ensure it generates a response (we will need this for the next part). Test Go to Site admin -> Reports -> AI reports -> AI usage CONFIRM you see the 'Explain text' entry in the report table CONFIRM you see numeric values in the 'Prompt tokens' and 'Completion tokens' columns Click the 'Filters' button Set 'Prompt tokens' to 'Greater than' and enter 0 Set 'Completion tokens' to 'Greater than' and enter 0 CONFIRM you see the same record displayed for your 'Explain text' action
    • Hide

      Code verified against automated checks.

      Checked MDL-85106 using repository: https://github.com/davewoloszyn/moodle.git

      More information about this report

      Built on: Fri Apr 4 04:36:21 UTC 2025

      Show
      Code verified against automated checks. Checked MDL-85106 using repository: https://github.com/davewoloszyn/moodle.git main (0 errors / 0 warnings) [branch: MDL-85106-main | CI Job ] More information about this report Built on: Fri Apr 4 04:36:21 UTC 2025
    • Show
      Launching automatic jobs for branch MDL-85106 -main https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/18927/ PHPUnit (sqlsrv) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64780/ Behat (NonJS - boost and classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64781/ Behat (Firefox - boost) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64782/ Behat (Firefox - classic) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64783/ App tests (stable app version) Built on: Fri Apr 4 12:25:15 UTC 2025
    • 1
    • Team Hedgehogs 2025 Sprint 1.4

      As noticed by marycooch and investigated by stronk7, the AI usage report doesn't show any tokens for Explain text actions.

      From Eloy:

      There must be some bug there, in explain action. I've tried here with both OpenAI and Ollama providers an get the same. 

      I did quick debug and see that, internally, both the prompt and the completion tokens are being counted ok and stored in the database ok for the explain action, but for some reason they don't show in the report.

      I'd bet that the report needs some update to get the info from the explain action.

      Yeah, it's the report. I just fixed it here. It's missing support for explain text.

      Attached is Eloy's patch to get the explain text counters working.

        1. behat-comparison.png
          behat-comparison.png
          156 kB
        2. explain_no_count_tokens.png
          explain_no_count_tokens.png
          144 kB
        3. MDL-85106.png
          MDL-85106.png
          327 kB
        4. report.patch
          3 kB

            david.woloszyn@moodle.com David Woloszyn
            tsala Helen Foster
            Raquel Ortega Raquel Ortega
            Huong Nguyen Huong Nguyen
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            1 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 1 hour, 54 minutes
                1d 1h 54m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.