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: examples/09-vapi.ts
+13-4Lines changed: 13 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -129,6 +129,12 @@ If you cannot help, offer to transfer to a human agent.`,
129
129
// The assistant's response (what Vapi's AI would say)
130
130
constassistantResponse="I'd be happy to help you reset your password! Let me look into why you didn't receive the reset email. Can you confirm the email address associated with your account?";
131
131
132
+
// IMPORTANT: outputData must be a structured object (not a bare string) so it
133
+
// survives the backend's JSONB serialization round-trip. The optimization pipeline
134
+
// extracts the answer from output_data.content — a plain string like
135
+
// outputData: assistantResponse will be lost during JSON parsing and cause
136
+
// "No valid examples to train on" errors.
137
+
132
138
// Build the zeroeval metadata object for span attributes
133
139
// This is what links the span to the prompt for feedback
134
140
constspanZeroEvalMetadata={
@@ -160,10 +166,13 @@ If you cannot help, offer to transfer to a human agent.`,
160
166
messages: conversationMessages,
161
167
streaming: false,
162
168
},
163
-
// Input should be the messages array (system + user messages)
164
-
inputData: JSON.stringify(conversationMessages),
165
-
// Output should be just the assistant's response
166
-
outputData: assistantResponse,
169
+
// Input: pass the messages array directly (SDK will JSON.stringify objects automatically)
170
+
inputData: conversationMessages,
171
+
// Output: MUST be a structured object, not a bare string.
172
+
// The backend extracts the answer via output_data.get("content").
0 commit comments