@@ -29,6 +29,9 @@ public struct TaskTypes: Codable {
2929}
3030
3131public struct TaskTypeData : Codable {
32+ public typealias TaskInputShape = [ String : Shape ]
33+ public typealias TaskOutputShape = [ String : Shape ]
34+
3235 public var id : String ?
3336 public let name : String ?
3437 public let description : String ?
@@ -42,21 +45,21 @@ public struct TaskTypeData: Codable {
4245 self . inputShape = inputShape
4346 self . outputShape = outputShape
4447 }
45- }
46-
47- public struct TaskInputShape : Codable {
48- public let input : Shape ?
4948
50- public init ( input : Shape ? ) {
51- self . input = input
49+ public func isChat ( ) -> Bool {
50+ id == " core:text2text:chat "
5251 }
53- }
5452
55- public struct TaskOutputShape : Codable {
56- public let output : Shape ?
53+ public func isTranslate( ) -> Bool {
54+ id? . contains ( " translate " ) == true
55+ }
5756
58- public init ( output: Shape ? ) {
59- self . output = output
57+ public func isSingleTextInputOutput( supportedTaskType: String = " Text " ) -> Bool {
58+ guard let inputShape, let outputShape else { return false }
59+ return inputShape. count == 1 &&
60+ outputShape. count == 1 &&
61+ inputShape. values. first? . type == supportedTaskType &&
62+ outputShape. values. first? . type == supportedTaskType
6063 }
6164}
6265
0 commit comments