github.com/weaviate/weaviate@v1.24.6/modules/qna-openai/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 "properties": &graphql.InputObjectFieldConfig{ 53 Description: "Properties which contains text", 54 Type: graphql.NewList(graphql.String), 55 }, 56 } 57 if g.askTransformer != nil { 58 askFields["autocorrect"] = &graphql.InputObjectFieldConfig{ 59 Description: "Autocorrect input text values", 60 Type: graphql.Boolean, 61 } 62 } 63 return askFields 64 }