OpenAI API failed with status: 400 in Golang

Hi,

I am receiving the error message

explorer: get class: vectorize params: vectorize params: vectorize params: vectorize keywords: remote client vectorize: connection to: OpenAI API failed with status: 400 error: ‘$.input’ is invalid. Please check the API reference: https://platform.openai.com/docs/api-reference.

For the following code segment

generativeSearchBuilder := graphql.NewGenerativeSearch().GroupedResult("What is the capital of France?")
nearTextArgumentBuilder := client.GraphQL().NearTextArgBuilder().WithConcepts([]string{"France", "capital"})

response, err := repo.client.GraphQL().
		Get().
		WithClassName("Myclass").
		WithNearText(nearTextArgumentBuilder).
		WithGenerativeSearch(generativeSearchBuilder).
		WithLimit(3).
		Do(ctx)

The python equivalent is working fine.

res = client.query.get(
    "Myclass"
).with_near_text({"concepts": ["France", "capital"]}).with_generate(
    grouped_task="What is the capital of France?"
).with_limit(3).do()

Any pointers on what might cause the Go code to fail?

Thanks,

Utsav

nearTextArgumentBullder was causing the problem. It contained a couple of empty strings in addition to the two shown here in the question.

1 Like

Hi @utsavgupta !! Welcome to our community :hugs:

Thanks for sharing!