MCPcopy
hub / github.com/FlowiseAI/Flowise / createEvaluation

Function createEvaluation

packages/server/src/services/evaluations/index.ts:66–368  ·  view source on GitHub ↗
(body: ICommonObject, baseURL: string, orgId: string, workspaceId: string)

Source from the content-addressed store, hash-verified

64}
65
66const createEvaluation = async (body: ICommonObject, baseURL: string, orgId: string, workspaceId: string) => {
67 try {
68 const appServer = getRunningExpressApp()
69 const newEval = new Evaluation()
70 Object.assign(newEval, stripProtectedFields(body))
71 newEval.workspaceId = workspaceId
72 newEval.status = EvaluationStatus.PENDING
73
74 const row = appServer.AppDataSource.getRepository(Evaluation).create(newEval)
75 row.average_metrics = JSON.stringify({})
76
77 const chatflowTypes = body.chatflowType ? JSON.parse(body.chatflowType) : []
78 if (!Array.isArray(chatflowTypes)) {
79 throw new Error('chatflowType must be a valid array')
80 }
81
82 const simpleEvaluators =
83 body.selectedSimpleEvaluators && body.selectedSimpleEvaluators.length > 0 ? JSON.parse(body.selectedSimpleEvaluators) : []
84 if (!Array.isArray(simpleEvaluators)) {
85 throw new Error('selectedSimpleEvaluators must be a valid array')
86 }
87
88 const additionalConfig: ICommonObject = {
89 chatflowTypes: chatflowTypes,
90 datasetAsOneConversation: body.datasetAsOneConversation,
91 simpleEvaluators: simpleEvaluators
92 }
93
94 if (body.evaluationType === 'llm') {
95 const lLMEvaluators =
96 body.selectedLLMEvaluators && body.selectedLLMEvaluators.length > 0 ? JSON.parse(body.selectedLLMEvaluators) : []
97
98 if (!Array.isArray(lLMEvaluators)) {
99 throw new Error('selectedLLMEvaluators must be a valid array')
100 }
101
102 additionalConfig.lLMEvaluators = lLMEvaluators
103 additionalConfig.llmConfig = {
104 credentialId: body.credentialId,
105 llm: body.llm,
106 model: body.model
107 }
108 }
109 row.additionalConfig = JSON.stringify(additionalConfig)
110 const newEvaluation = await appServer.AppDataSource.getRepository(Evaluation).save(row)
111
112 await appServer.telemetry.sendTelemetry(
113 'evaluation_created',
114 {
115 version: await getAppVersion()
116 },
117 orgId
118 )
119
120 const dataset = await appServer.AppDataSource.getRepository(Dataset).findOneBy({
121 id: body.datasetId,
122 workspaceId: workspaceId
123 })

Callers 1

runAgainFunction · 0.70

Calls 15

runEvaluationsMethod · 0.95
runLLMEvaluatorsMethod · 0.95
getRunningExpressAppFunction · 0.90
stripProtectedFieldsFunction · 0.90
getAppVersionFunction · 0.90
formatCostFunction · 0.90
calculateCostFunction · 0.90
runAdditionalEvaluatorsFunction · 0.90
getErrorMessageFunction · 0.90
stringifyMethod · 0.80
sendTelemetryMethod · 0.80
getAllEvaluationsFunction · 0.70

Tested by

no test coverage detected