<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
assistant-engine / open-functions-trello example snippets
use AssistantEngine\OpenFunctions\Trello\TrelloOpenFunction;
use AssistantEngine\OpenFunctions\Trello\Models\Parameters;
use OpenAI;
// Set up parameters for Trello authentication
$parameters = new Parameters();
$parameters->token = env('TRELLO_API_KEY'); // Your Trello API key
$parameters->tokenSecret = env('TRELLO_TOKEN'); // Your Trello token
$parameters->boardId = env('TRELLO_BOARD_ID'); // The ID of the Trello board
// Initialize the Trello Open Function
$trelloFunction = new TrelloOpenFunction($parameters);
// Generate function definitions (for tool integration with an LLM)
$functionDefinitions = $trelloFunction->generateFunctionDefinitions();
$client = OpenAI::client(env('OPENAI_TOKEN'));
$result = $client->chat()->create([
'model' => 'gpt-4o',
'messages'=> [],
'tools' => $functionDefinitions
]);
$choice = $result->choices[0];
if ($choice->finishReason === 'tool_calls') {
$toolCalls = processToolCalls($choice->message->toolCalls, $trelloFunction);
}
function processToolCalls($toolCalls, $trelloFunction)
{
$result = [];
foreach ($toolCalls as $toolCall) {
// Extract the function name (already namespaced) and arguments
$functionName = $toolCall->function->name;
$functionArgs = json_decode($toolCall->function->arguments, true);
$response = $trelloFunction->callMethod($functionName, $functionArgs);
$result[] = $response;
}
return $result;
}
// inside config/filament-assistant.php
// Tools configuration: each tool is identified by a key.
'tools' => [
'trello' => [
'namespace' => 'trello',
'description' => 'This tool allows you to manage your Trello boards, lists, and cards.',
'tool' => function () {
$parameter = new \AssistantEngine\OpenFunctions\Trello\Models\Parameters();
$parameter->token = env('TRELLO_API_KEY');
$parameter->tokenSecret = env('TRELLO_TOKEN');
$parameter->boardId = env('TRELLO_BOARD_ID');
return new \AssistantEngine\OpenFunctions\Trello\TrelloOpenFunction($parameter);
},
]
]
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.