You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/core-concepts/text-generation.md
+5-3
Original file line number
Diff line number
Diff line change
@@ -49,18 +49,23 @@ $response = Prism::text()
49
49
You an also pass a View to the `withPrompt` method.
50
50
51
51
## 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.
52
55
53
56
For interactive conversations, use message chains to maintain context:
54
57
55
58
```php
56
59
use EchoLabs\Prism\Prism;
57
60
use EchoLabs\Prism\Enums\Provider;
61
+
use EchoLabs\Prism\ValueObjects\Messages\SystemMessage;
58
62
use EchoLabs\Prism\ValueObjects\Messages\UserMessage;
59
63
use EchoLabs\Prism\ValueObjects\Messages\AssistantMessage;
60
64
61
65
$response = Prism::text()
62
66
->using(Provider::Anthropic, 'claude-3-sonnet')
63
67
->withMessages([
68
+
new SystemMessage('You are a software engineer'),
64
69
new UserMessage('What is JSON?'),
65
70
new AssistantMessage('JSON is a lightweight data format...'),
66
71
new UserMessage('Can you show me an example?')
@@ -75,9 +80,6 @@ $response = Prism::text()
75
80
-`AssistantMessage`
76
81
-`ToolResultMessage`
77
82
78
-
> [!NOTE]
79
-
> Some providers, like Anthropic, do not support the `SystemMessage` type. In those cases we convert `SystemMessage` to `UserMessage`.
80
-
81
83
## Multi-modal Capabilities (Images)
82
84
83
85
Prism supports including images in your messages for visual analysis:
0 commit comments