Skip to content

Feature/response parser#56

Merged
lucaromagnoli merged 23 commits intomainfrom
feature/response-parser
Aug 10, 2025
Merged

Feature/response parser#56
lucaromagnoli merged 23 commits intomainfrom
feature/response-parser

Conversation

@lucaromagnoli
Copy link
Owner

No description provided.

…rsing

- Implements parseStructuredResponse() with provider detection
- Supports Anthropic XML function calls and OpenAI JSON responses
- Handles markdown-fenced JSON and partial JSON gracefully
- Includes comprehensive unit tests
- Version bumped to 1.2.0
- Add ResponseParser class for provider-agnostic response parsing
- Implement Anthropic XML function call parsing with tool support
- Add OpenAI JSON response parsing capabilities
- Create AnthropicSchemaBuilder for tool schema generation
- Add comprehensive unit tests for all parsing scenarios
- Support for markdown-fenced JSON and various response formats
- Generic parameter extraction for XML function calls
- All edge cases and unit tests now passing

This enables aideas to use a unified parsing API regardless of LLM provider.
- Add parseDirectFunctionTags() method to handle formats like <generate_musical_sequence>JSON</generate_musical_sequence>
- Update parseAnthropicXmlResponse() to try direct function tags as fallback after standard XML
- Make ResponseParser more generic to handle any function tag format, not just <function_calls> wrapper
- Support both real LLM responses and test formats for better compatibility
- Add regex patterns to match specific function names or any function dynamically
- Remove file containing real API response data to prevent information leakage
- This file should not have been committed to the repository
- Temporarily simplified parseDirectFunctionTags implementation
- Added missing nlohmann/json.hpp include
- Fixed namespace scope issues that were breaking compilation
- All other parsing methods remain functional
- Replaced complex regex implementation with simple string finding
- Handles <generate_musical_sequence> and other direct XML tags
- Avoids compilation issues while maintaining functionality
- All tests passing successfully
- Remove hardcoded 'generate_musical_sequence' dependency
- Make function truly generic by requiring functionName parameter
- Handle both closed tags </func> and unclosed tags <func>
- Extract JSON content using balanced bracket parsing
- Return empty if no functionName provided (proper generic behavior)
- Throw std::invalid_argument instead of silently returning empty
- Add proper error message for debugging
- Include required <stdexcept> header
- Previously only detected specific tags like <function_calls>
- Now detects any XML-like content including custom function tags
- Removes all debug code and cleans up implementation
- This ensures parseDirectFunctionTags gets called for custom function names
- Remove text wrapping from Anthropic MessagesResponse.toLLMResponse()
- Remove text wrapping from OpenAI ResponsesResponse.toLLMResponse()
- Now returns parsed JSON directly instead of wrapping in {'text': '...'}
- Simplifies response handling and follows principle of returning raw responses
- Add parsing for tool_use content fields (id, name, input) in MessagesResponse::fromJson()
- Previously only text content was parsed, causing tool calls to return empty name/input
- Now properly extracts structured JSON data from tool_use responses
- Enables Anthropic tool calling for enforcing JSON schemas via structured output
- Changed the default model from CLAUDE_SONNET_3_5_V2 to CLAUDE_SONNET_3_7
- Ensures the latest stable model is used for API interactions
- Change defaultModel from CLAUDE_SONNET_3_7 to CLAUDE_SONNET_4
- Corresponds to claude-sonnet-4-20250514 model
- Aligns with current usage in aideas-suite integration tests
- Changed anthropicVersion from "2023-06-01" to "2025-05-14"
- Ensures compatibility with the latest features and improvements in the API
- Replace try-catch JSON parsing with explicit expectStructuredOutput parameter
- Add expectStructuredOutput parameter to both OpenAI and Anthropic toLLMResponse methods
- Client automatically detects structured output when jsonSchema is set
- Handles free-form text (wrap in text field) vs structured JSON (parse directly)
- All tests passing: OpenAI (34 assertions) and Anthropic (111 assertions)
- No more inefficient try-catch guessing or JSON parsing exceptions
@lucaromagnoli lucaromagnoli merged commit 31555d7 into main Aug 10, 2025
7 checks passed
@lucaromagnoli lucaromagnoli deleted the feature/response-parser branch August 10, 2025 20:34
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