Skip to content

add_function parameters are strings and not arrays #3

@epareja2

Description

@epareja2

Hello, thank you for this library and I'm new to this ChatGPT API.
I'm trying to create a class for defining funtions like this

class myFunctionsClass {
protected ChatGPT $chatGPT; // This is your class

/**

  • This function do something very cool
  • @param $test : string having the result from chatgpt
    */
    public function doSomething(string $test) {
    // do something with $test
    }
    }

In that same class I'm defining a constructor to add the defined functions like this

public function __construct()
{
$api_key = env('OPENAI_API_KEY');
$this->chatGPT = new ChatGPT($api_key);
$this->chatGPT->add_function('doSomething');
}

The line that assigns a function throws an error

App\Libraries\ChatGPT::add_function(): Argument #1 ($function) must be of type callable|array, string given,

What am I doing wrong here?

Thank you and hopefully you can check this.

Regards

Ernesto Pareja

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions