Spaces:
Running
Running
fix (validator): Fix input file validator for 'chat' task.
Browse files- src/validators.ts +18 -13
src/validators.ts
CHANGED
@@ -106,7 +106,7 @@ function isValidTask(task): boolean {
|
|
106 |
return false;
|
107 |
}
|
108 |
|
109 |
-
if (!task.hasOwnProperty('contexts')) {
|
110 |
return false;
|
111 |
}
|
112 |
|
@@ -151,33 +151,38 @@ export function validateInputData(data): { valid: boolean; reasons: string[] } {
|
|
151 |
);
|
152 |
}
|
153 |
|
154 |
-
// Step : Validate
|
155 |
-
if (!data.hasOwnProperty('
|
156 |
valid = false;
|
157 |
-
reasons.push("Missing mandatory '
|
158 |
}
|
159 |
if (
|
160 |
-
data.hasOwnProperty('
|
161 |
-
!data.
|
162 |
) {
|
163 |
valid = false;
|
164 |
reasons.push(
|
165 |
-
"One or more
|
166 |
);
|
167 |
}
|
168 |
|
169 |
-
// Step : Validate
|
170 |
-
if (
|
|
|
|
|
|
|
171 |
valid = false;
|
172 |
-
reasons.push(
|
|
|
|
|
173 |
}
|
174 |
if (
|
175 |
-
data.hasOwnProperty('
|
176 |
-
!data.
|
177 |
) {
|
178 |
valid = false;
|
179 |
reasons.push(
|
180 |
-
"One or more
|
181 |
);
|
182 |
}
|
183 |
|
|
|
106 |
return false;
|
107 |
}
|
108 |
|
109 |
+
if (task.taskType === 'rag' && !task.hasOwnProperty('contexts')) {
|
110 |
return false;
|
111 |
}
|
112 |
|
|
|
151 |
);
|
152 |
}
|
153 |
|
154 |
+
// Step : Validate tasks releated requirements
|
155 |
+
if (!data.hasOwnProperty('tasks')) {
|
156 |
valid = false;
|
157 |
+
reasons.push("Missing mandatory 'tasks' information.");
|
158 |
}
|
159 |
if (
|
160 |
+
data.hasOwnProperty('tasks') &&
|
161 |
+
!data.tasks.every((task) => isValidTask(task))
|
162 |
) {
|
163 |
valid = false;
|
164 |
reasons.push(
|
165 |
+
"One or more tasks are incorrectly specified. Please refer to 'sample.json' on the format for a task.",
|
166 |
);
|
167 |
}
|
168 |
|
169 |
+
// Step : Validate documents releated requirements
|
170 |
+
if (
|
171 |
+
data.tasks.some((task) => task.taskType === 'rag') &&
|
172 |
+
!data.hasOwnProperty('documents')
|
173 |
+
) {
|
174 |
valid = false;
|
175 |
+
reasons.push(
|
176 |
+
"Missing mandatory 'documents' information when `rag` type tasks are included.",
|
177 |
+
);
|
178 |
}
|
179 |
if (
|
180 |
+
data.hasOwnProperty('documents') &&
|
181 |
+
!data.documents.every((document) => isValidDocument(document))
|
182 |
) {
|
183 |
valid = false;
|
184 |
reasons.push(
|
185 |
+
"One or more documents are incorrectly specified. Please refer to 'sample.json' on the format for a document.",
|
186 |
);
|
187 |
}
|
188 |
|