From acac5568209a45e4f1e13af5b582c4b0e2a35984 Mon Sep 17 00:00:00 2001 From: Riccardo Albero Date: Tue, 19 Dec 2023 15:44:17 +0900 Subject: [PATCH] add embedder get and put --- src/CCatClient.php | 23 +++++++++++++++++++++++ src/index.php | 13 ++++--------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/CCatClient.php b/src/CCatClient.php index fc6d012..1e723a9 100644 --- a/src/CCatClient.php +++ b/src/CCatClient.php @@ -277,6 +277,29 @@ public function putLLMSettings(string $llm, array $values): LLMSettingsOutput return $this->serializer->deserialize($response->getBody()->getContents(), LLMSettingsOutput::class, 'json', []); } + /** + * @param string $embedder + * @param array $values + * @return LLMSettingsOutput + */ + public function putEmbedderSettings(string $embedder, array $values): LLMSettingsOutput + { + $response = $this->httpClient->getHttpClient()->put(sprintf('/embedder/settings/%s', $embedder), [ + 'json' => $values + ]); + return $this->serializer->deserialize($response->getBody()->getContents(), LLMSettingsOutput::class, 'json', []); + } + + /** + * @param string $embedder + * @return LLMSettingsOutput + */ + public function getEmbedderSettings(string $embedder): LLMSettingsOutput + { + $response = $this->httpClient->getHttpClient()->get(sprintf('/embedder/settings/%s', $embedder)); + return $this->serializer->deserialize($response->getBody()->getContents(), LLMSettingsOutput::class, 'json', []); + } + /** * @param string $pluginId * @param array $values diff --git a/src/index.php b/src/index.php index 8827c50..64f755b 100644 --- a/src/index.php +++ b/src/index.php @@ -1,6 +1,6 @@ putLLMSettings("LLMOpenAIChatConfig", [ -// "open_api_key" => "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", -// "temperature" => 0.7, -// "model_name" => "gpt-3.5-turbo", -// "streaming" => true, -// ]); +// $response = $cCatClient->getEmbedderSettings("EmbedderOpenAIConfig"); // // // // "prompt_prefix" => "You are a supportive AI that help during hard time" , // // "episodic_memory_k" => 3, @@ -37,5 +32,5 @@ //} catch (Exception $exception) { // var_dump($exception->getMessage()); //} -////$response = $cCatClient->sendMessage(new \Albocode\CcatphpSdk\Model\Message("Ciao come stai?", "test"), fn($message) => var_dump($message)); -////var_dump($response); +//$response = $cCatClient->sendMessage(new \Albocode\CcatphpSdk\Model\Message("Ciao come stai?", "test"), fn($message) => var_dump($message)); +//var_dump($response);