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
That's it. Every call to `ze.prompt()` is tracked, versioned, and linked to the completions it produces. You'll see production traces at [ZeroEval → Prompts](https://app.zeroeval.com).
39
39
40
40
<Note>
41
-
When you provide `content`, ZeroEval automatically uses the latest optimized version from your dashboard if one exists. The `content` parameter serves as a fallback for when no optimized versions are available yet.
41
+
When you provide `content`, ZeroEval automatically uses the latest optimized
42
+
version from your dashboard if one exists. The `content` parameter serves as a
43
+
fallback for when no optimized versions are available yet.
Copy file name to clipboardExpand all lines: autotune/sdks/typescript.mdx
+46-44Lines changed: 46 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,31 +14,33 @@ npm install zeroeval
14
14
Replace hardcoded prompt strings with `ze.prompt()`. Your existing text becomes the fallback content that's used until an optimized version is available.
15
15
16
16
```typescript
17
-
import*aszefrom'zeroeval';
18
-
import { OpenAI } from'openai';
17
+
import*aszefrom"zeroeval";
18
+
import { OpenAI } from"openai";
19
19
20
20
ze.init();
21
21
const client =ze.wrap(newOpenAI());
22
22
23
23
const systemPrompt =awaitze.prompt({
24
-
name: 'support-bot',
25
-
content: 'You are a helpful customer support agent for {{company}}.',
26
-
variables: { company: 'TechCorp' },
24
+
name: "support-bot",
25
+
content: "You are a helpful customer support agent for {{company}}.",
{ role: 'user', content: 'How do I reset my password?' },
32
+
{ role: "system", content: systemPrompt },
33
+
{ role: "user", content: "How do I reset my password?" },
34
34
],
35
35
});
36
36
```
37
37
38
38
Every call to `ze.prompt()` is tracked, versioned, and linked to the completions it produces. You'll see production traces at [ZeroEval → Prompts](https://app.zeroeval.com).
39
39
40
40
<Note>
41
-
When you provide `content`, ZeroEval automatically uses the latest optimized version from your dashboard if one exists. The `content` parameter serves as a fallback for when no optimized versions are available yet.
41
+
When you provide `content`, ZeroEval automatically uses the latest optimized
42
+
version from your dashboard if one exists. The `content` parameter serves as a
43
+
fallback for when no optimized versions are available yet.
42
44
</Note>
43
45
44
46
## Version Control
@@ -47,8 +49,8 @@ When you provide `content`, ZeroEval automatically uses the latest optimized ver
47
49
48
50
```typescript
49
51
const prompt =awaitze.prompt({
50
-
name: 'customer-support',
51
-
content: 'You are a helpful assistant.',
52
+
name: "customer-support",
53
+
content: "You are a helpful assistant.",
52
54
});
53
55
```
54
56
@@ -58,9 +60,9 @@ Uses the latest optimized version if one exists, otherwise falls back to the pro
58
60
59
61
```typescript
60
62
const prompt =awaitze.prompt({
61
-
name: 'customer-support',
62
-
from: 'explicit',
63
-
content: 'You are a helpful assistant.',
63
+
name: "customer-support",
64
+
from: "explicit",
65
+
content: "You are a helpful assistant.",
64
66
});
65
67
```
66
68
@@ -70,8 +72,8 @@ Always uses the provided content. Useful for debugging or A/B testing a specific
70
72
71
73
```typescript
72
74
const prompt =awaitze.prompt({
73
-
name: 'customer-support',
74
-
from: 'latest',
75
+
name: "customer-support",
76
+
from: "latest",
75
77
});
76
78
```
77
79
@@ -81,47 +83,47 @@ Requires an optimized version to exist. Fails with `PromptRequestError` if none
|`name`|`string`| Yes | — | Task name for this prompt|
96
+
|`content`|`string`| No |`undefined`| Prompt content (fallback or explicit)|
97
+
|`from`|`string`| No|`undefined`|`"latest"`, `"explicit"`, or a 64-char SHA-256 hash |
98
+
|`variables`|`Record<string, string>`| No |`undefined`| Template variables for `{{var}}` tokens|
97
99
98
100
### Return value
99
101
100
102
Returns `Promise<string>` -- a decorated prompt string with metadata that integrations use to link completions to prompt versions and auto-patch models.
101
103
102
104
### Errors
103
105
104
-
| Error | When |
105
-
| --- | --- |
106
-
|`Error`| Both `content` and `from` provided (except `from: "explicit"`), or neither |
107
-
|`PromptRequestError`|`from: "latest"` but no versions exist |
108
-
|`PromptNotFoundError`|`from` is a hash that doesn't exist |
0 commit comments