github.com/weaviate/weaviate@v1.24.6/usecases/modulecomponents/arguments/nearImage/graphql_argument.go (about) 1 // _ _ 2 // __ _____ __ ___ ___ __ _| |_ ___ 3 // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ 4 // \ V V / __/ (_| |\ V /| | (_| | || __/ 5 // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| 6 // 7 // Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. 8 // 9 // CONTACT: hello@weaviate.io 10 // 11 12 package nearImage 13 14 import ( 15 "fmt" 16 17 "github.com/tailor-inc/graphql" 18 "github.com/weaviate/weaviate/adapters/handlers/graphql/descriptions" 19 ) 20 21 func getNearImageArgumentFn(classname string) *graphql.ArgumentConfig { 22 return nearImageArgument("GetObjects", classname) 23 } 24 25 func exploreNearImageArgumentFn() *graphql.ArgumentConfig { 26 return nearImageArgument("Explore", "") 27 } 28 29 func aggregateNearImageArgumentFn(classname string) *graphql.ArgumentConfig { 30 return nearImageArgument("Aggregate", classname) 31 } 32 33 func nearImageArgument(prefix, className string) *graphql.ArgumentConfig { 34 prefixName := fmt.Sprintf("Img2VecImage%s%s", prefix, className) 35 return &graphql.ArgumentConfig{ 36 Type: graphql.NewInputObject( 37 graphql.InputObjectConfig{ 38 Name: fmt.Sprintf("%sNearImageInpObj", prefixName), 39 Fields: nearImageFields(prefixName), 40 Description: descriptions.GetWhereInpObj, 41 }, 42 ), 43 } 44 } 45 46 func nearImageFields(prefix string) graphql.InputObjectConfigFieldMap { 47 return graphql.InputObjectConfigFieldMap{ 48 "image": &graphql.InputObjectFieldConfig{ 49 Description: "Base64 encoded image", 50 Type: graphql.NewNonNull(graphql.String), 51 }, 52 "certainty": &graphql.InputObjectFieldConfig{ 53 Description: descriptions.Certainty, 54 Type: graphql.Float, 55 }, 56 "distance": &graphql.InputObjectFieldConfig{ 57 Description: descriptions.Distance, 58 Type: graphql.Float, 59 }, 60 "targetVectors": &graphql.InputObjectFieldConfig{ 61 Description: "Target vectors", 62 Type: graphql.NewList(graphql.String), 63 }, 64 } 65 }