https://github.com/mathsgod/sense-nova-client
https://github.com/mathsgod/sense-nova-client
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mathsgod/sense-nova-client
- Owner: mathsgod
- License: mit
- Created: 2024-06-28T08:39:46.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-14T03:26:21.000Z (almost 2 years ago)
- Last Synced: 2025-07-22T12:57:39.413Z (11 months ago)
- Language: PHP
- Size: 35.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## SenseNova php client
### Authentication
```php
use SenseNovo\Client;
$client = new Client('your_access_key', 'your_secret_key');
```
### Chat completions
```php
print_r($client->chatCompletions()->create([
"model" => "SenseChat-5",
"messages"=>[
[
"role"=>"user",
"content"=>"Hello, how are you?"
]
]
]));
```
#### Chat completions tools call
Tool file
```php
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];
}
}
```
```php
$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
```php
print_R($client->models()->list());
```