Skip to content

Conversation

@Retribution98
Copy link
Contributor

@Retribution98 Retribution98 commented Dec 19, 2025

Description

This PR adds parsers to the JavaScript API.
The base parser can be a JavaScript object with parse methods. The user object is wrapped in a JSParser entity and uses TSFN.BlockingCall to execute it.
Child classes provide a wrapper that uses the core entity to parse the message. To boost performance, it doesn't use the JSParser and instead uses the native parser. If the user would like to extend it from the JavaScript side, it must be wrapped in a JSParser, just like the base parser.
The following child classes are supported:

  • ReasoningParser
  • DeepSeekR1ReasoningParser
  • Phi4ReasoningParser
  • Llama3PythonicToolParser
  • Llama3JsonToolParser.

The IncrementalParser is not supported now because it must be set up in the Streamer class, which the JS API does not support.

CVS-176151

Checklist:

  • Tests have been updated or added to cover the new code.
  • This patch fully addresses the ticket.
  • I have made corresponding changes to the documentation.

Copilot AI review requested due to automatic review settings December 19, 2025 16:06
@github-actions github-actions bot added the category: JS API GenAI JS API label Dec 19, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds parser support to the JavaScript API, enabling users to process and transform generated text content. It provides both a base parser interface for custom JavaScript implementations and native wrapper classes for better performance.

Key changes include:

  • Introduction of JSParser class that wraps JavaScript parser objects with thread-safe execution
  • Implementation of ReasoningParser wrapper for extracting reasoning content from generated text
  • Extension of GenerationConfig to accept an array of parsers that process content sequentially

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/js/tests/parsers.test.js Comprehensive test suite covering custom parsers, ReasoningParser functionality, and parser integration with LLMPipeline
src/js/src/parser.cpp Core implementation of JSParser (wraps JS parsers) and ReasoningParserWrapper (native parser wrapper)
src/js/src/llm_pipeline/llm_pipeline_wrapper.cpp Adds parsed results to decoded results output
src/js/src/helper.cpp Conversion utilities for parsers between JS and C++, including parser type detection and vector handling
src/js/src/addon.cpp Exports ReasoningParser class to JavaScript
src/js/lib/utils.ts Adds ParserGenerationConfig type definition
src/js/lib/pipelines/llmPipeline.ts Updates DecodedResults to include parsed property
src/js/lib/parsers.ts TypeScript type definitions for Parser interface and ReasoningParser options
src/js/lib/index.ts Exports parser types to public API
src/js/lib/addon.ts Adds ReasoningParser to addon exports
src/js/include/parser.hpp Header declarations for JSParser and ReasoningParserWrapper classes
src/js/include/helper.hpp Template declarations for parser conversion functions
src/js/include/addon.hpp Adds reasoning_parser reference to AddonData structure
src/js/eslint.config.cjs Adds reasoning_content to allowed snake_case identifiers

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings December 23, 2025 09:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings December 23, 2025 11:54
@github-actions github-actions bot added the category: LLM samples GenAI LLM samples label Dec 23, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Retribution98 Retribution98 marked this pull request as ready for review December 23, 2025 12:15
Copilot AI review requested due to automatic review settings December 23, 2025 12:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// Register the addon with Node.js
NODE_API_MODULE(openvino-genai-node, init_module)
NODE_API_MODULE(openvino - genai - node, init_module)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: JS API GenAI JS API category: LLM samples GenAI LLM samples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants