albocode/ccatphp-sdk

此包最新版本(0.2.1)没有可用的许可证信息。

Cheshire Cat PHP Sdk

0.2.1 2024-07-19 13:06 UTC

README

CCat PHP SDK(Cheshire cat PHP SDK) 是一个库,用于帮助在 PHP 项目中实现 Cheshire Cat

安装

要安装 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]);