Skip to content

Commit b94e088

Browse files
committed
add note to docs
1 parent e677de2 commit b94e088

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Diff for: docs/core-concepts/text-generation.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,23 @@ $response = Prism::text()
4949
You an also pass a View to the `withPrompt` method.
5050

5151
## Message Chains and Conversations
52+
> [!NOTE]
53+
> You should avoid using `withSystemPrompt()` for message chains. Doing so will result in that SystemMessage being duplicated in all but the first generation.
54+
> Instead, include your system prompt as a `SystemMessage` at the top of your first `withMessages()` call.
5255
5356
For interactive conversations, use message chains to maintain context:
5457

5558
```php
5659
use EchoLabs\Prism\Prism;
5760
use EchoLabs\Prism\Enums\Provider;
61+
use EchoLabs\Prism\ValueObjects\Messages\SystemMessage;
5862
use EchoLabs\Prism\ValueObjects\Messages\UserMessage;
5963
use EchoLabs\Prism\ValueObjects\Messages\AssistantMessage;
6064

6165
$response = Prism::text()
6266
->using(Provider::Anthropic, 'claude-3-sonnet')
6367
->withMessages([
68+
new SystemMessage('You are a software engineer'),
6469
new UserMessage('What is JSON?'),
6570
new AssistantMessage('JSON is a lightweight data format...'),
6671
new UserMessage('Can you show me an example?')
@@ -75,9 +80,6 @@ $response = Prism::text()
7580
- `AssistantMessage`
7681
- `ToolResultMessage`
7782

78-
> [!NOTE]
79-
> Some providers, like Anthropic, do not support the `SystemMessage` type. In those cases we convert `SystemMessage` to `UserMessage`.
80-
8183
## Multi-modal Capabilities (Images)
8284

8385
Prism supports including images in your messages for visual analysis:

0 commit comments

Comments
 (0)