定制 mathsgod/sense-nova-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mathsgod/sense-nova-client

最新稳定版本:0.2.0

Composer 安装命令:

composer require mathsgod/sense-nova-client

包简介

README 文档

README

Authentication

use SenseNovo\Client;

$client = new Client('your_access_key', 'your_secret_key');

Chat completions

print_r($client->chatCompletions()->create([
    "model" => "SenseChat-5",
    "messages"=>[
        [
            "role"=>"user",
            "content"=>"Hello, how are you?"
        ]
    ]
]));

Chat completions tools call

Tool file

use SenseNova\ChatCompletions\Attributes\Parameter;
use SenseNova\ChatCompletions\Attributes\Tool;

class MyTool
{
    public $price = "$799";

    #[Tool(description: 'Get the price of iphone')]
    public function getIPhonePrice(#[Parameter("model of the phone")] string $model)
    {
        return ["price" => $this->price, "model" => $model];
    }

    #[Tool(description: 'Get the release date of iphone')]
    public function getIPhoneReleaseDate(#[Parameter("model of the phone")] string $model)
    {
        return ["date" => "2023-01-01", "model" => $model];
    }
}
$tool=new MyTool();
$cc = $client->chatCompletions();
$cc->setModel("SenseChat-5");
$cc->addTool(Closure::fromCallable([$tool, "getIPhonePrice"]));
$cc->addTool(Closure::fromCallable([$tool, "getIPhoneReleaseDate"]));

$cc->addMessage(["role" => "user", "content" => "get iphone 14 price and release date"]);

print_R($cc->run());

Models

print_R($client->models()->list());

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-02