ELin2025 commented on code in PR #5568:
URL: https://github.com/apache/texera/pull/5568#discussion_r3445100422
##########
frontend/src/app/workspace/component/property-editor/operator-property-edit-frame/operator-property-edit-frame.component.ts:
##########
@@ -541,6 +824,203 @@ export class OperatorPropertyEditFrameComponent
implements OnInit, OnChanges, On
mappedField.type = "inputautocomplete";
}
+ if (mappedField.key === "huggingFaceModel") {
+ mappedField.type = "huggingface";
+ }
+
+ if (mappedField.key === "modelId" &&
this.currentOperatorSchema?.operatorType === "HuggingFace") {
+ mappedField.type = "huggingface";
+ }
+
+ if (mappedField.key === "task" &&
this.currentOperatorSchema?.operatorType === "HuggingFace") {
+ mappedField.hide = true;
+ }
+
+ // ── Dynamic field visibility for HuggingFace based on selected task ──
+ if (this.currentOperatorSchema?.operatorType === "HuggingFace" && typeof
mappedField.key === "string") {
+ const hfKey = mappedField.key;
+ const imageOnlyTasks = ["image-classification", "object-detection",
"image-segmentation", "image-to-text"];
+ const imageInputTasks = [
+ ...imageOnlyTasks,
+ "visual-question-answering",
+ "document-question-answering",
+ "zero-shot-image-classification",
+ "image-text-to-text",
+ "image-to-image",
+ ];
+ const audioInputTasks = ["automatic-speech-recognition",
"audio-classification"];
+ const promptRequiredTasks = [
+ "text-generation",
+ "text-classification",
+ "token-classification",
+ "question-answering",
+ "table-question-answering",
+ "zero-shot-classification",
+ "translation",
+ "summarization",
+ "feature-extraction",
+ "fill-mask",
+ "sentence-similarity",
+ "text-ranking",
+ "visual-question-answering",
+ "document-question-answering",
+ "zero-shot-image-classification",
+ ];
+ const getSelectedTask = (field: FormlyFieldConfig): string | undefined
=> {
+ const fromForm = field.form?.get("task")?.value ??
field.formControl?.parent?.get("task")?.value;
+ if (typeof fromForm === "string" && fromForm.trim().length > 0) {
+ return fromForm;
+ }
+ const fromModel = field.model?.task;
+ if (typeof fromModel === "string" && fromModel.trim().length > 0) {
+ return fromModel;
+ }
+ return undefined;
+ };
+ if (hfKey === "imageInput") {
+ mappedField.type = "huggingface-image-upload";
+ mappedField.expressions = {
+ ...mappedField.expressions,
+ hide: (field: FormlyFieldConfig) => {
+ const t = getSelectedTask(field);
+ return t === undefined || !imageInputTasks.includes(t);
+ },
+ };
+ mappedField.validators = {
+ ...mappedField.validators,
+ requiredImageInput: {
+ expression: (_control: AbstractControl, field:
FormlyFieldConfig) => {
+ const t = getSelectedTask(field);
+ if (t === undefined || !imageInputTasks.includes(t)) {
+ return true;
+ }
+ const inputImageCol = field.model?.inputImageColumn;
+ if (typeof inputImageCol === "string" &&
inputImageCol.trim().length > 0) {
+ return true;
+ }
+ const value = field.formControl?.value ??
field.model?.imageInput;
+ return typeof value === "string" && value.trim().length > 0;
+ },
+ message: () => "Upload an image or select an Input Image Column
for this task.",
+ },
+ };
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]