From 4540cde808719ca6b574059fb081a4242e70e8d1 Mon Sep 17 00:00:00 2001 From: Pavel Buchnev Date: Sun, 8 Sep 2024 15:15:56 +0400 Subject: [PATCH] Adds an ability to set prompt context values --- src/LLM/Prompt/Context.php | 14 ++++++++++++++ src/LLM/PromptContextInterface.php | 7 ++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/LLM/Prompt/Context.php b/src/LLM/Prompt/Context.php index b4c2c60..027ae07 100644 --- a/src/LLM/Prompt/Context.php +++ b/src/LLM/Prompt/Context.php @@ -8,5 +8,19 @@ class Context implements PromptContextInterface { + private array $values = []; + public function __construct() {} + + public function addValues(array $values): static + { + $this->values = \array_merge($this->values, $values); + + return $this; + } + + public function getValues(): array + { + return $this->values; + } } diff --git a/src/LLM/PromptContextInterface.php b/src/LLM/PromptContextInterface.php index f0d0c1d..9a7d147 100644 --- a/src/LLM/PromptContextInterface.php +++ b/src/LLM/PromptContextInterface.php @@ -4,4 +4,9 @@ namespace LLM\Agents\LLM; -interface PromptContextInterface { } +interface PromptContextInterface +{ + public function addValues(array $values): static; + + public function getValues(): array; +}