• Resolved buonqua11

    (@buonqua11)


    The script to change the “Error Calling OpenAI” requests is not working.

    Can you check it again and fix it. Thank you!

    • This topic was modified 1 year, 4 months ago by buonqua11.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Val Meow

    (@valwa)

    Hello @buonqua11 ,

    I’m assuming you are talking about mwai_ai_exception from “How can I remove or modify the error messages?” documentation ?

    Would you mind providing your custom code implementation for this function so that we can attempt to replicate it and determine if there are any issues that need to be addressed?

    We appreciate your cooperation. ??

    Thread Starter buonqua11

    (@buonqua11)

    add_filter( 'mwai_ai_exception', function ( $exception ) {
      try {
        if ( substr( $exception, 0, 26 ) === "Error while calling OpenAI" ) {
          error_log( $exception );
          return "There was an AI system error. Please contact us.";
        }
        return $exception;
      }
      catch ( Exception $e ) {
        error_log( $e->getMessage() );
      }
      return $exception;
    } );

    The above code does not work, OpenAI errors are still displayed without change. Can you help me?

    • This reply was modified 1 year, 4 months ago by buonqua11.
    Plugin Support Val Meow

    (@valwa)

    Based on your previous forum post, it seems that you are encountering the error “cURL error 28 (OpenAI)”. To address this issue, you will need to adjust the substr condition to specifically handle this error. The current condition you have provided will only work for “Error while calling OpenAI”.

    Thread Starter buonqua11

    (@buonqua11)

    Not this time I’m not talking about error 28. I’m talking about “Error while calling OpenAI” errors.

    Plugin Support Val Meow

    (@valwa)

    Could you attempt to utilize only the following code?

    add_filter( 'mwai_ai_exception', function ( $exception ) {
    	return "There was an AI system error. Please contact us.";
      } );

    By doing so, it should supersede any encountered errors. If this approach proves unsuccessful, please provide additional information regarding your implementation of the filter. However, if it does work, you can subsequently introduce a condition to solely apply the desired error.

    Thread Starter buonqua11

    (@buonqua11)

    Thank you very much! The code worked great. You have been very supportive.

    • This reply was modified 1 year, 4 months ago by buonqua11.
    Plugin Support Val Meow

    (@valwa)

    Glad you could resolve your issue. I have marked this issue as?resolved. If you believe your questions were not adequately answered, please feel free to reopen it. ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘The script to change the “Error Calling OpenAI” requests is not working.’ is closed to new replies.