github.com/weaviate/weaviate@v1.24.6/modules/qna-transformers/ask/grapqhl_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 ask 13 14 func (g *GraphQLArgumentsProvider) extractAskFn(source map[string]interface{}) interface{} { 15 var args AskParams 16 17 question, ok := source["question"].(string) 18 if ok { 19 args.Question = question 20 } 21 22 // autocorrect is an optional arg, so it could be nil 23 autocorrect, ok := source["autocorrect"] 24 if ok { 25 args.Autocorrect = autocorrect.(bool) 26 } 27 28 // if there's text transformer present and autocorrect set to true 29 // perform text transformation operation 30 if args.Autocorrect && g.askTransformer != nil { 31 if transformedValues, err := g.askTransformer.Transform([]string{args.Question}); err == nil && len(transformedValues) == 1 { 32 args.Question = transformedValues[0] 33 } 34 } 35 36 certainty, ok := source["certainty"] 37 if ok { 38 args.Certainty = certainty.(float64) 39 } 40 41 distance, ok := source["distance"] 42 if ok { 43 args.Distance = distance.(float64) 44 args.WithDistance = true 45 } 46 47 properties, ok := source["properties"].([]interface{}) 48 if ok { 49 args.Properties = make([]string, len(properties)) 50 for i, value := range properties { 51 args.Properties[i] = value.(string) 52 } 53 } 54 55 // rerank is an optional arg, so it could be nil 56 rerank, ok := source["rerank"] 57 if ok { 58 args.Rerank = rerank.(bool) 59 } 60 61 return &args 62 }