@@ -19,41 +19,45 @@ import { wrapAISDK } from "./ai-sdk/ai-sdk";
1919
2020configureNode ( ) ;
2121
22+ const questions = {
23+ category : {
24+ type : "choice" ,
25+ instructions : "Which team should handle this request?" ,
26+ criteria : { billing : null , technical : null } ,
27+ } ,
28+ urgency : {
29+ type : "score" ,
30+ instructions : "How urgent is this request?" ,
31+ criteria : [ "Low" , "High" ] ,
32+ } ,
33+ duplicate : {
34+ type : "boolean" ,
35+ instructions : "Was there a duplicate charge?" ,
36+ } ,
37+ } ;
38+
39+ const answers = {
40+ category : {
41+ type : "choice" ,
42+ choice : "billing" ,
43+ probabilities : { billing : 0.9 , technical : 0.1 } ,
44+ } ,
45+ urgency : {
46+ type : "score" ,
47+ score : 0.75 ,
48+ probabilities : { 0 : 0.25 , 1 : 0.75 } ,
49+ } ,
50+ duplicate : { type : "boolean" , probability : 0.95 } ,
51+ } ;
52+
2253const params : AISDKEvaluateParams = {
2354 model : "typesafe-ai/jev" ,
2455 state : { message : "Charged twice" } ,
25- questions : {
26- category : {
27- type : "choice" ,
28- instructions : "Which team should handle this request?" ,
29- criteria : { billing : null , technical : null } ,
30- } ,
31- urgency : {
32- type : "score" ,
33- instructions : "How urgent is this request?" ,
34- criteria : [ "Low" , "High" ] ,
35- } ,
36- duplicate : {
37- type : "boolean" ,
38- instructions : "Was there a duplicate charge?" ,
39- } ,
40- } ,
56+ questions,
4157} ;
4258
4359const result : AISDKEvaluationResult = {
44- answers : {
45- category : {
46- type : "choice" ,
47- choice : "billing" ,
48- probabilities : { billing : 0.9 , technical : 0.1 } ,
49- } ,
50- urgency : {
51- type : "score" ,
52- score : 0.75 ,
53- probabilities : { 0 : 0.25 , 1 : 0.75 } ,
54- } ,
55- duplicate : { type : "boolean" , probability : 0.95 } ,
56- } ,
60+ answers,
5761 usage : { inputTokens : 20 , outputTokens : 5 , totalTokens : 25 } ,
5862 response : { modelId : "typesafe-ai/jev-1.13.0" } ,
5963 providerMetadata : {
@@ -120,24 +124,24 @@ describe("AI SDK evaluate instrumentation", () => {
120124 input : {
121125 state : params . state ,
122126 questions : [
123- { ...params . questions . category , id : "category" } ,
124- { ...params . questions . urgency , id : "urgency" } ,
125- { ...params . questions . duplicate , id : "duplicate" } ,
127+ { ...questions . category , id : "category" } ,
128+ { ...questions . urgency , id : "urgency" } ,
129+ { ...questions . duplicate , id : "duplicate" } ,
126130 ] ,
127131 } ,
128132 output : {
129133 answers : [
130134 {
131- ...result . answers . category ,
135+ ...answers . category ,
132136 confidence : 0.9 ,
133137 id : "category" ,
134138 } ,
135139 {
136- ...result . answers . urgency ,
140+ ...answers . urgency ,
137141 confidence : 0.8 ,
138142 id : "urgency" ,
139143 } ,
140- { ...result . answers . duplicate , id : "duplicate" } ,
144+ { ...answers . duplicate , id : "duplicate" } ,
141145 ] ,
142146 } ,
143147 metadata : {
@@ -187,7 +191,7 @@ describe("AI SDK evaluate instrumentation", () => {
187191 } ) ,
188192 ] ) ,
189193 ) ;
190- expect ( result . answers . category ) . toHaveProperty ( "probabilities" , {
194+ expect ( answers . category ) . toHaveProperty ( "probabilities" , {
191195 billing : 0.9 ,
192196 technical : 0.1 ,
193197 } ) ;
0 commit comments