feat(developer-knowledge): add Developer Knowledge API samples - #4424
Conversation
Add standalone code samples and test suites for Developer Knowledge API: - searchDocumentChunks - getDocument - batchGetDocuments - answerQuery
|
Here is the summary of changes. You are about to add 4 region tags.
This comment is generated by snippet-bot.
|
There was a problem hiding this comment.
Code Review
This pull request introduces Node.js code samples and tests for the Google Developer Knowledge API, including scripts for answering queries, retrieving documents, batch-fetching documents, and searching document chunks. The review feedback highlights potential TypeError issues across several files (answerQuery.js, getDocument.js, and searchDocumentChunks.js) where properties or methods are accessed on potentially undefined or null fields (such as response.answer, document.content, and chunk.content). It is recommended to use optional chaining or fallback values to ensure robust error handling.
|
Hi, Could one of the maintainers please review this PR, cheers :) |
Description
Adds Node.js code samples for the Developer Knowledge API using the
@google/developer-knowledgeclient library:answerQuery.js(developerknowledge_answer_query) - Answers queries against a developer knowledge corpus.getDocument.js(developerknowledge_get_document) - Retrieves a document by resource name.batchGetDocuments.js(developerknowledge_batch_get_documents) - Retrieves multiple documents in a single request.searchDocumentChunks.js(developerknowledge_search_document_chunks) - Searches document chunks with pagination limit.Includes comprehensive Mocha unit tests (
test/samples.test.js), ESLint/Prettier configuration with license headers, package metadata, README documentation, and addeddeveloper-knowledgetoCODEOWNERS.Checklist
npm test(see Testing)npm run lint(see Style)developerknowledge.googleapis.com)GoogleCloudPlatform/nodejs-docs-samples. Not a fork.