| Server IP : 69.72.244.102 / Your IP : 216.73.216.164 Web Server : LiteSpeed System : Linux s3434.fra1.stableserver.net 4.18.0-513.24.1.lve.2.el8.x86_64 #1 SMP Fri May 24 12:42:50 UTC 2024 x86_64 User : konzalta ( 1271) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/konzalta/public_html/wp-content/plugins/ai-engine/classes/data/ |
Upload File : |
<?php
/**
* Value object representing a function call request from an AI model
*/
class Meow_MWAI_Data_FunctionCall {
public string $id;
public string $name;
public string $arguments;
public function __construct( string $id, string $name, string $arguments ) {
$this->id = $id;
$this->name = $name;
$this->arguments = $arguments;
}
/**
* Create from OpenAI tool call format
*/
public static function from_tool_call( array $toolCall ): self {
return new self(
$toolCall['id'],
$toolCall['function']['name'],
$toolCall['function']['arguments']
);
}
/**
* Create from Anthropic tool use format
*/
public static function from_tool_use( array $toolUse ): self {
return new self(
$toolUse['id'],
$toolUse['name'],
json_encode( $toolUse['input'] )
);
}
/**
* Get arguments as JSON string
*/
public function get_arguments_json(): string {
return $this->arguments;
}
/**
* Get arguments as array
*/
public function get_arguments_array(): array {
return json_decode( $this->arguments, true ) ?? [];
}
}