Skip to content

Commit bffbfd1

Browse files
committed
add llm api
1 parent ba1e313 commit bffbfd1

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

src/CCatClient.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Albocode\CcatphpSdk\Clients\HttpClient;
66
use Albocode\CcatphpSdk\Clients\WSClient;
7+
use Albocode\CcatphpSdk\Model\Api\LLMSetting\LLMSettingsOutput;
78
use Albocode\CcatphpSdk\Model\Api\Plugin\PluginCollectionOutput;
89
use Albocode\CcatphpSdk\Model\Api\Plugin\Settings\PluginSettingsOutput;
910
use Albocode\CcatphpSdk\Model\Api\RabbitHole\AllowedMimeTypesOutput;
@@ -257,6 +258,24 @@ public function getPluginSettings(string $pluginId): PluginSettingsOutput
257258

258259
}
259260

261+
public function getLLMSettings(string $llm): LLMSettingsOutput
262+
{
263+
$response = $this->httpClient->getHttpClient()->get(sprintf('/llm/settings/%s', $llm), []);
264+
return $this->serializer->deserialize($response->getBody()->getContents(), LLMSettingsOutput::class, 'json', []);
265+
}
266+
267+
/**
268+
* @param string $llm
269+
* @param array<string, mixed> $values
270+
* @return LLMSettingsOutput
271+
*/
272+
public function putLLMSettings(string $llm, array $values): LLMSettingsOutput {
273+
$response = $this->httpClient->getHttpClient()->put(sprintf('/llm/settings/%s', $llm), [
274+
'json' => $values
275+
]);
276+
return $this->serializer->deserialize($response->getBody()->getContents(), LLMSettingsOutput::class, 'json', []);
277+
}
278+
260279
/**
261280
* @param string $pluginId
262281
* @param array<string, mixed> $values
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Albocode\CcatphpSdk\Model\Api\LLMSetting;
4+
5+
class LLMSettingsOutput
6+
{
7+
public string $name;
8+
9+
/**
10+
* @var array<string, mixed>
11+
*/
12+
public array $value;
13+
}

src/index.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
2+
//
33
//
44
//require dirname(__DIR__).'/vendor/autoload.php';
55
//
@@ -10,7 +10,12 @@
1010
//$cCatClient = new CCatClient(new WSClient('cheshire_cat_core'), new HttpClient('cheshire_cat_core', null, 'meow'));
1111
//
1212
//try {
13-
// // $response = $cCatClient->putPluginSettings("cat_advanced_tools", [
13+
// $response = $cCatClient->putLLMSettings("LLMOpenAIChatConfig", [
14+
// "open_api_key" => "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",
15+
// "temperature" => 0.7,
16+
// "model_name" => "gpt-3.5-turbo",
17+
// "streaming" => true,
18+
// ]);
1419
// //
1520
// // "prompt_prefix" => "You are a supportive AI that help during hard time" ,
1621
// // "episodic_memory_k" => 3,
@@ -25,7 +30,7 @@
2530
// // ]);
2631
// // $response = $cCatClient->deleteConversationHistory();
2732
// echo "<pre>";
28-
// // var_dump($response);
33+
// var_dump($response);
2934
// echo "</pre>";
3035
//
3136
//} catch (Exception $exception) {

0 commit comments

Comments
 (0)