github.com/weaviate/weaviate@v1.24.6/usecases/modulecomponents/arguments/nearImage/graphql_extract.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  // extractNearImageFn arguments, such as "image" and "certainty"
    15  func extractNearImageFn(source map[string]interface{}) interface{} {
    16  	var args NearImageParams
    17  
    18  	image, ok := source["image"].(string)
    19  	if ok {
    20  		args.Image = image
    21  	}
    22  
    23  	certainty, ok := source["certainty"]
    24  	if ok {
    25  		args.Certainty = certainty.(float64)
    26  	}
    27  
    28  	distance, ok := source["distance"]
    29  	if ok {
    30  		args.Distance = distance.(float64)
    31  		args.WithDistance = true
    32  	}
    33  
    34  	// targetVectors is an optional argument, so it could be nil
    35  	targetVectors, ok := source["targetVectors"]
    36  	if ok {
    37  		targetVectorsArray := targetVectors.([]interface{})
    38  		args.TargetVectors = make([]string, len(targetVectorsArray))
    39  		for i, value := range targetVectorsArray {
    40  			args.TargetVectors[i] = value.(string)
    41  		}
    42  	}
    43  
    44  	return &args
    45  }