promptgun 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -117,6 +117,32 @@ You can also avoid writing a file altogether and get the byte array directly:
|
|
|
117
117
|
const byteArray = await ai.image('A black hole')
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
+
## System and User Prompts
|
|
121
|
+
|
|
122
|
+
By default, `.chat()` with a string creates a user message. To add system instructions, pass message objects:
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
const response = await ai
|
|
126
|
+
.chat(
|
|
127
|
+
{system: 'You are a helpful assistant that speaks like a pirate'},
|
|
128
|
+
{user: 'Tell me about the weather'}
|
|
129
|
+
)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
This works with structured output too:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
const response = await ai
|
|
136
|
+
.chat(
|
|
137
|
+
{system: 'You are a JSON API that returns restaurant data'},
|
|
138
|
+
{user: 'I want Italian restaurants in Rome'}
|
|
139
|
+
)
|
|
140
|
+
.getObject(o => o
|
|
141
|
+
.hasString('name')
|
|
142
|
+
.hasString('address')
|
|
143
|
+
)
|
|
144
|
+
```
|
|
145
|
+
|
|
120
146
|
## Conversations
|
|
121
147
|
With `ai.createConversation()` you can create a dedicated client
|
|
122
148
|
for a single conversation. Every prompt you do gets appended
|