Node JS API Errors -- RequiredError: Required parameter

Hello:

Having trouble with the following syntax in Node. One note here, the index I am calling does not have a namespace defined. From the documentation it looks like namespace is a required parameter. I’m not sure if the issue is because I am passing that parameter as an empty string (e.g. ‘’). Interestingly the python API does not require this param and works fine. Any suggestions would be much appreciated ~

const query_embedding = oai_config.createEmbedding({
model: “text-embedding-ada-002”,
input: query,
});

const query_embed = await query_embedding;

const queryResponse = await index.query({
query: {
vector: query_embed.data.data[0].embedding,
topK: 3,
includeValues: true,
},
namespace: “”,
});

//Returns:
PineconeError: PineconeClient: Error calling query: PineconeError: PineconeClient: Error calling queryRaw: RequiredError: Required parameter requestParameters.queryRequest was null or undefined when calling query.

Regards,
Noah

Hi. Same problem here - except that i do have namespace defined. I can fetch these vectors through the Pinecone console UI - but not from node.

    await pinecone.init({
        environment: config.pinecone.environment,
        apiKey: config.pinecone.apiKey,
    });

    //get the vector for this message
    const embeddings = new OpenAIEmbeddings({
        openAIApiKey: config.openai.apiKey
    });
    const embeddedQuery = await embeddings.embedQuery(msg);

    const index = pinecone.Index("npcchat");

    const queryRequest = {
        topK: 1,
        vector: embeddedQuery,
        includeMetadata: true,
        includeValues: true
    }

    //Query the index and store the response.
    const queryResponse = await index.query(queryRequest);
    
    return (queryResponse);

Where error is:

>  node:internal/process/promises:288
>              triggerUncaughtException(err, true /* fromPromise */);
>              ^
>  
>  [PineconeError: PineconeClient: Error calling query: PineconeError: PineconeClient: Error calling queryRaw: RequiredError: Required parameter requestParameters.queryRequest was null or undefined when calling query.]```

Heres a screenshot from a successful fetch using the same data via console (although not sure what that second array of empty matches is?)

Example query:

Example results:

Got it!
Needed brackets around the queryRequest

const queryRequest = {
        "topK": 1,
        "vector": embeddedQuery,
        "includeMetadata": true,
        "includeValues": true,
        "namespace": npc_id
    }

    //Query the index and store the response.
    const queryResponse = await index.query({queryRequest});
    
    return (queryResponse);

(note that i also didnt specify namespace in my screenshot above, but that wasn’t the issue - that was a screenshot from an inbetween experiment.

1 Like

@bigrig Wow… Thank you so much. I have been trying to debug this for four hours. Your solution worked! Woo!

1 Like