ccatphp sdk
0.2.4
CCat PHP SDK(柴郡貓PHP SDK)是一個幫助在PHP計畫上實施柴郡貓的庫
要安裝 CCatPHP-SDK,您可以執行以下命令:
composer require albocode/ccatphp-sdk
初始化及使用:
use Albocode CcatphpSdk CCatClient ;
use Albocode CcatphpSdk Clients HttpClient ;
use Albocode CcatphpSdk Clients WSClient ;
$ cCatClient = new CCatClient (
new WSClient ( ' cheshire_cat_core ' , 1865 , null ),
new HttpClient ( ' cheshire_cat_core ' , 1865 , null )
);
向 websocket 發送訊息:
$ notificationClosure = function ( string $ message ) {
// handle websocket notification, like chat token stream
}
// result is the result of the message
$ result = $ cCatClient -> sendMessage (
new Message ( " Hello world! " , ' user ' , []), // message body
$ notificationClosure // websocket notification closure handle
);
將資料載入到兔子洞:
//file
$ promise = $ this -> client -> rabbitHole ( $ uploadedFile -> getPathname (), null , null );
$ promise -> wait ();
//url
$ promise = $ this -> client -> rabbitHoleWeb ( $ url , null , null );
$ promise -> wait ();
記憶體管理實用程式:
$ this -> client -> getMemoryCollection (); // get number of vectors in the working memory
$ this -> client -> getMemoryRecall ( " HELLO " ); // recall memories by text
//delete memory points by metadata, like this example delete by source
$ this -> client -> deleteDeclarativeMemoryByMetadata ([ " source " => $ url ]);