Skip to content

Commit 3bfae04

Browse files
committed
Improves user prompt message. It provides an ability to replace prompt text
1 parent 6fc61d8 commit 3bfae04

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"license": "MIT",
55
"require": {
66
"php": "^8.3",
7-
"llm-agents/agents": "dev-feature/embeddings as 1.0",
7+
"llm-agents/agents": "^1.5",
88
"llm-agents/json-schema-mapper": "^1.0"
99
},
1010
"require-dev": {

src/Interceptors/UserPromptInjector.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44

55
namespace LLM\Agents\PromptGenerator\Interceptors;
66

7-
use LLM\Agents\LLM\Prompt\Chat\ChatMessage;
7+
use LLM\Agents\LLM\Prompt\Chat\MessagePrompt;
88
use LLM\Agents\LLM\Prompt\Chat\Prompt;
99
use LLM\Agents\LLM\Prompt\Chat\PromptInterface;
10-
use LLM\Agents\LLM\Prompt\Chat\Role;
1110
use LLM\Agents\PromptGenerator\InterceptorHandler;
1211
use LLM\Agents\PromptGenerator\PromptGeneratorInput;
1312
use LLM\Agents\PromptGenerator\PromptInterceptorInterface;
@@ -23,10 +22,10 @@ public function generate(
2322
return $next(
2423
input: $input->withPrompt(
2524
$input->prompt->withAddedMessage(
26-
new ChatMessage(
27-
content: (string) $input->userPrompt,
28-
role: Role::User,
29-
),
25+
MessagePrompt::user('{user_prompt}')
26+
->withValues([
27+
'user_prompt' => (string) $input->userPrompt,
28+
]),
3029
),
3130
),
3231
);

0 commit comments

Comments
 (0)