/** Datei: plugins/openai/library/ARUNOX/API/OpenAI/Threads/Runs.php **/ * @copyright 2023 Sparky@ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ namespace ARUNOX\API\OpenAI\Threads; use ARUNOX\API; class Runs { /* ### VARIABLES ################################################ # */ protected static $HEADER = [ "OpenAI-Beta" => "assistants=v2" ], $URL = "/threads"; /* ### PUBLIC FUNCTIONS ######################################### # */ public static function list( string $thread_id ) { return API\OpenAI::get( static::$URL . "/{$thread_id}/runs", [], static::$HEADER ); } public static function create( string $thread_id, array $args ) { return API\OpenAI::post( static::$URL . "/{$thread_id}/runs", $args, static::$HEADER ); } public static function get( string $thread_id, string $run_id ) { return API\OpenAI::get( static::$URL . "/{$thread_id}/runs/{$run_id}", [], static::$HEADER ); } public static function modify( string $thread_id, string $run_id, ?array $args = [] ) { return API\OpenAI::post( static::$URL . "/{$thread_id}/runs/{$run_id}", $args, static::$HEADER ); } public static function cancel( string $thread_id, string $run_id ) { return API\OpenAI::post( static::$URL . "/{$thread_id}/runs/{$run_id}/cancel", [], static::$HEADER ); } public static function cancelAll( string $thread_id ) { $response = static::list( $thread_id ); if( isset( $response->data ) ) { foreach( $response->data as &$item ) { if( $item->status == "requires_action" ) { $item = static::cancel( $thread_id, $item->id ); } } } return $response; } /* ### PROTECTED FUNCTIONS ###################################### # */ /* ### PRIVATE FUNCTIONS ######################################## # */ /* ### MAGIC FUNCTIONS ########################################## # */ } /** Datei: plugins/openai/library/ARUNOX/API/OpenAI/Threads/Outputs.php **/ * @copyright 2023 Sparky@ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ namespace ARUNOX\API\OpenAI\Threads; use ARUNOX\API; class Outputs { /* ### VARIABLES ################################################ # */ protected static $HEADER = [ "OpenAI-Beta" => "assistants=v2" ], $URL = "/threads"; /* ### PUBLIC FUNCTIONS ######################################### # */ public static function create( string $thread_id, string $run_id, ?array $args = [] ) { return API\OpenAI::post( static::$URL . "/{$thread_id}/runs/{$run_id}/submit_tool_outputs", [ "tool_outputs" => $args ], static::$HEADER ); } /* ### PROTECTED FUNCTIONS ###################################### # */ /* ### PRIVATE FUNCTIONS ######################################## # */ /* ### MAGIC FUNCTIONS ########################################## # */ } /** Datei: plugins/openai/library/ARUNOX/API/OpenAI/Threads/Messages.php **/ * @copyright 2023 Sparky@ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ namespace ARUNOX\API\OpenAI\Threads; use ARUNOX\API; class Messages { /* ### VARIABLES ################################################ # */ protected static $HEADER = [ "OpenAI-Beta" => "assistants=v2" ], $URL = "/threads"; /* ### PUBLIC FUNCTIONS ######################################### # */ public static function list( string $thread_id, array $args = [] ) { return API\OpenAI::get( static::$URL . "/{$thread_id}/messages", $args, static::$HEADER ); } public static function create( string $thread_id, array $args ) { return API\OpenAI::post( static::$URL . "/{$thread_id}/messages", $args, static::$HEADER ); } public static function get( string $thread_id, string $message_id ) { return API\OpenAI::get( static::$URL . "/{$thread_id}/messages/{$message_id}", [], static::$HEADER ); } public static function modify( string $thread_id, string $message_id, ?array $args = [] ) { return API\OpenAI::post( static::$URL . "/{$thread_id}/messages/{$message_id}", $args, static::$HEADER ); } public static function delete( string $thread_id, string $message_id ) { return API\OpenAI::delete( static::$URL . "/{$thread_id}/messages/{$message_id}", [], static::$HEADER ); } /* ### PROTECTED FUNCTIONS ###################################### # */ /* ### PRIVATE FUNCTIONS ######################################## # */ /* ### MAGIC FUNCTIONS ########################################## # */ } /** Datei: plugins/openai/library/ARUNOX/API/OpenAI/Threads/Threads.php **/ * @copyright 2023 Sparky@ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ namespace ARUNOX\API\OpenAI; use ARUNOX\API; class Threads { /* ### VARIABLES ################################################ # */ protected static $HEADER = [ "OpenAI-Beta" => "assistants=v2" ], $URL = "/threads"; /* ### PUBLIC FUNCTIONS ######################################### # */ public static function create( array $args ) { return API\OpenAI::post( static::$URL, $args, static::$HEADER ); } public static function get( string $thread_id ) { return API\OpenAI::get( static::$URL . "/{$thread_id}", [], static::$HEADER ); } public static function modify( string $thread_id, ?array $args = [] ) { return API\OpenAI::post( static::$URL . "/{$thread_id}", $args, static::$HEADER ); } public static function delete( string $thread_id ) { return API\OpenAI::delete( static::$URL . "/{$thread_id}", [], static::$HEADER ); } /* ### PROTECTED FUNCTIONS ###################################### # */ /* ### PRIVATE FUNCTIONS ######################################## # */ /* ### MAGIC FUNCTIONS ########################################## # */ }