I opened a Postman to test my token and it seems that it works ok:

POST https://api.openai.com/v1/completions

{
    "model": "text-davinci-003",
    "prompt": "What do you think about Scriabin?",
    "max_tokens": 1000
}

Response:

{
    "id": "cmpl-6wrGoxk2yBPIOsLhLFad2yhWbf6Pt",
    "object": "text_completion",
    "created": 1679485814,
    "model": "text-davinci-003",
    "choices": [
        {
            "text": "\n\nScriabin was a Russian composer and pianist known for his visionary approach to music, particularly his focus on the connection between sound, colors and the human soul. His music is often described as metaphysical and visionary and is still today highly coveted by classical music enthusiasts.",
            "index": 0,
            "logprobs": null,
            "finish_reason": "stop"
        }
    ],
    "usage": {
        "prompt_tokens": 9,
        "completion_tokens": 55,
        "total_tokens": 64
    }
}

I use the same API token for this extension but it doesn't work and there's no log about what is failing.

P.S. I notice that when I create a discussion and ask a question and press the post button, it takes some time, so apparently the API is generating a completion. However no answer appears following the initial post. It makes me wonder whether the extension actually uses the correct Flarum functionality for posting the completion? Maybe there's a Flarum error after all and not ChatGPT one?

    This looks really awesome. Was not able to get it to work, but I'm looking forward to an update.

    Got it working, amazing plugin. For those who have problems:

    • Check that your PHP version is 8.1 or higher
    • Make sure that you have a valid api key, and remaining credits/tokens in your openai account
    • run php flarum cache:clear and php flarum migrate after installing the plugin

    Some problem I noticed:

    • Script attempts to respond to any post being made, but by default only the admin user has permission. Hence the error message I think. Change permissions, or create he post as the admin user and there won't be an error.

    Feature requests:

    • Would be great to be able to choose which user the ai will reply as
    • Delayed responses, like luceos suggested, using the queue perhaps
    • Match rules, i.e only respond when the comment contains a specific query, like a question mark in the end or if the ai user is tagged.
    • Ability to chose tags, and respected permissions, i.e if regular users don't have permissions, it shouldn't try to respond, as the response generates a error message, even if the comment is posted.

    Last but not least, is there anything I can do to help? Is there any place I can donate to this project?

      First of all, thank you @datlechin for this amazing extension! It will populate a lot a half-empty forums with content :-)
      Magnus_Lind Did you have to install anything extra to make it work? OpenAI Client (openai-php) dependency is installed through composer automatically, right?

      For me doesn't work. I tried different settings in admin panel, but anything I do, it doesn't post anything from ChatGPT, also no logs, no errors (also no server side errors). I have all the required specs (PHP 8.1.15, Flarum 1.7.1), runned all above commands.
      I get normal response over Postman, I have paid account on OpenAI.

        datlechin ps: I think Luceos's Support Ai extension is better than mine and I and I no longer intend to maintain this extension. So try installing the Luceos utility instead.

        I have no intention to compete with your extension honestly. I merely shared the work I had so you could use whatever you needed for your own purposes. The Support Ai extension isn't done yet and it might take a while for it to get to an acceptable state. So please do reconsider.

        datlechin Thanks! It works now!

        P.S. I hope your extension is here to stay since is a really nice upgrade to any forum and it breaks boredom and waiting times until someone responds. Both extensions have a good perspective and the idea behind it is great! It`s your decision to make @luceos and @datlechin on which of both will continue depending on the spare time you have to invest.

        As a member of this great community, I want to communicate once more my appreciation for the time and work you invest in creating such nice pieces of software!

        Subarist I added it before but it hasn't been released yet, it was released with the previous fix. 😅

          How easy is it to make the bot respond when mentioned?

          Denys
          Should be set to absolute, put this in css

          @media (min-width:768px) {
          #app .UserPromo-badge {
              position: absolute;
              margin-left: -90px;
              margin-top: 55px;
          }
          }
            3 months later
            $ composer require datlechin/flarum-chatgpt:"*"
            Info from https://repo.packagist.org: #StandWithUkraine
            ./composer.json has been updated
            Running composer update datlechin/flarum-chatgpt
            Loading composer repositories with package information
            Updating dependencies
            Your requirements could not be resolved to an installable set of packages.
            
              Problem 1
                - laminas/laminas-diactoros 2.17.0 requires php ^7.4 || ~8.0.0 || ~8.1.0 -> your php version (8.2.5) does not satisfy that requir                     ement.
                - flarum/core v1.8.1 requires laminas/laminas-diactoros ^2.4.1 -> satisfiable by laminas/laminas-diactoros[2.17.0].
                - flarum/core is locked to version v1.8.1 and an update of this package was not requested.
            
            
            Installation failed, reverting ./composer.json and ./composer.lock to their original content.
            

              Redoslaw see if this works:

              composer require datlechin/flarum-chatgpt:"*" -W