Skip to content

Commit a6f43f4

Browse files
committed
fix: fix input and output for instill format
1 parent 550e76f commit a6f43f4

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

pkg/component/ai/instillmodel/v0/main.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -224,27 +224,3 @@ type triggerInfo struct {
224224
modelID string
225225
version string
226226
}
227-
228-
func getTriggerInfo(input *structpb.Struct) (*triggerInfo, error) {
229-
if input == nil {
230-
return nil, fmt.Errorf("input is nil")
231-
}
232-
data, ok := input.Fields["data"]
233-
if !ok {
234-
return nil, fmt.Errorf("data field not found")
235-
}
236-
model, ok := data.GetStructValue().Fields["model"]
237-
238-
if !ok {
239-
return nil, fmt.Errorf("model field not found")
240-
}
241-
modelNameSplits := strings.Split(model.GetStringValue(), "/")
242-
if len(modelNameSplits) != 3 {
243-
return nil, fmt.Errorf("model name should be in the format of <namespace>/<model>/<version>")
244-
}
245-
return &triggerInfo{
246-
nsID: modelNameSplits[0],
247-
modelID: modelNameSplits[1],
248-
version: modelNameSplits[2],
249-
}, nil
250-
}

pkg/component/ai/instillmodel/v0/trigger.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package instillmodel
33
import (
44
"context"
55
"fmt"
6+
"strings"
67
"time"
78

89
"google.golang.org/grpc/metadata"
@@ -51,3 +52,27 @@ func (e *execution) trigger(ctx context.Context, job *base.Job) error {
5152

5253
return job.Output.WriteData(ctx, res.TaskOutputs[0])
5354
}
55+
56+
func getTriggerInfo(input *structpb.Struct) (*triggerInfo, error) {
57+
if input == nil {
58+
return nil, fmt.Errorf("input is nil")
59+
}
60+
data, ok := input.Fields["data"]
61+
if !ok {
62+
return nil, fmt.Errorf("data field not found")
63+
}
64+
model, ok := data.GetStructValue().Fields["model"]
65+
66+
if !ok {
67+
return nil, fmt.Errorf("model field not found")
68+
}
69+
modelNameSplits := strings.Split(model.GetStringValue(), "/")
70+
if len(modelNameSplits) != 3 {
71+
return nil, fmt.Errorf("model name should be in the format of <namespace>/<model>/<version>")
72+
}
73+
return &triggerInfo{
74+
nsID: modelNameSplits[0],
75+
modelID: modelNameSplits[1],
76+
version: modelNameSplits[2],
77+
}, nil
78+
}

0 commit comments

Comments
 (0)