Skip to content

Conversation

@Snuffy2
Copy link
Contributor

@Snuffy2 Snuffy2 commented Nov 23, 2025

This pull request refactors and improves the parser framework for handling model responses, focusing on code clarity, type safety, and robustness. It introduces comprehensive docstrings, modernizes type annotations, improves error handling, and reorganizes imports and registry definitions for maintainability. The changes affect the base parser classes, the parser factory, and the module initialization.

Parser base class improvements:

  • Added detailed docstrings and modern Python type annotations to BaseThinkingParser, BaseToolParser, and BaseMessageConverter for better readability and maintainability.
  • Improved error handling in tool parsing: unparsable tool call chunks are now logged and skipped instead of raising or printing errors, and the parser returns None for invalid chunks. [1] [2]
  • Enhanced streaming parsing logic for both thinking and tool parsers, including proper handling of pending text and state management for incremental parsing. [1] [2] [3] [4]
  • Updated method signatures to use Python 3.10+ union syntax and replaced legacy type hints for improved type safety. [1] [2] [3] [4]

Parser registry and factory refactor:

  • Refactored the parser registry in factory.py to use modern type annotations, TypedDict, and explicit parser constructor types, improving code clarity and extensibility.
  • Reorganized imports in both __init__.py and factory.py for consistency and to ensure all relevant parser classes and converters are properly exposed and registered. [1] [2]

Module initialization and exports:

  • Updated __init__.py to clean up imports and the __all__ list, ensuring all relevant parser classes and converters are correctly exported and available for use.

These changes collectively make the parser framework more robust, maintainable, and easier to extend for future model integrations.

@Snuffy2 Snuffy2 force-pushed the Linting/Formatting-of-parser-folder branch from 9f20abe to 847a044 Compare November 30, 2025 02:24
@Snuffy2 Snuffy2 force-pushed the Linting/Formatting-of-parser-folder branch from 847a044 to c85a556 Compare November 30, 2025 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant