github.com/weaviate/weaviate@v1.24.6/modules/qna-transformers/ask/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 ask 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 (g *GraphQLArgumentsProvider) getAskArgumentFn(classname string) *graphql.ArgumentConfig { 22 return g.askArgument("GetObjects", classname) 23 } 24 25 func (g *GraphQLArgumentsProvider) exploreAskArgumentFn() *graphql.ArgumentConfig { 26 return g.askArgument("Explore", "") 27 } 28 29 func (g *GraphQLArgumentsProvider) aggregateAskArgumentFn(classname string) *graphql.ArgumentConfig { 30 return g.askArgument("Aggregate", classname) 31 } 32 33 func (g *GraphQLArgumentsProvider) askArgument(prefix, className string) *graphql.ArgumentConfig { 34 prefixName := fmt.Sprintf("QnATransformers%s%s", prefix, className) 35 return &graphql.ArgumentConfig{ 36 Type: graphql.NewInputObject( 37 graphql.InputObjectConfig{ 38 Name: fmt.Sprintf("%sAskInpObj", prefixName), 39 Fields: g.askFields(prefixName), 40 Description: descriptions.GetWhereInpObj, 41 }, 42 ), 43 } 44 } 45 46 func (g *GraphQLArgumentsProvider) askFields(prefix string) graphql.InputObjectConfigFieldMap { 47 askFields := graphql.InputObjectConfigFieldMap{ 48 "question": &graphql.InputObjectFieldConfig{ 49 Description: "Question to be answered", 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 "properties": &graphql.InputObjectFieldConfig{ 61 Description: "Properties which contains text", 62 Type: graphql.NewList(graphql.String), 63 }, 64 "rerank": &graphql.InputObjectFieldConfig{ 65 Description: "Arranges the results by certainty", 66 Type: graphql.Boolean, 67 }, 68 } 69 if g.askTransformer != nil { 70 askFields["autocorrect"] = &graphql.InputObjectFieldConfig{ 71 Description: "Autocorrect input text values", 72 Type: graphql.Boolean, 73 } 74 } 75 return askFields 76 }