Skip to content

Conversation

danny-avila
Copy link
Owner

Summary

I enhanced the parseParamFromPrompt function to support Anthropic's function format and added comprehensive unit tests to ensure reliability.

Closes #4652

  • Added support for Anthropic's parameter format: <parameter name="title">value</parameter>
  • Implemented null/undefined prompt handling with descriptive default messages
  • Created a new regex pattern to match both simple and parameter formats
  • Added comprehensive unit tests covering:
    • Simple format extraction
    • Parameter format extraction
    • Edge cases and error handling
    • Multiline content handling
    • Whitespace handling
    • Invalid format scenarios
  • Improved error messages for better debugging
  • Maintained backward compatibility with existing format: <title>value</title>

Testing

I thoroughly tested the changes through unit tests covering various scenarios:

Test Configuration:

  • Simple format extraction
  • Parameter format extraction
  • Edge cases (empty, null, malformed tags)
  • Multiline content
  • Whitespace handling
  • Invalid formats

To test these changes:

  1. Run npm test in the api directory
  2. Verify all test cases pass
  3. Test with both simple and parameter formats in the application
  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have written tests demonstrating that my changes are effective
  • Local unit tests pass with my changes

@danny-avila danny-avila merged commit 766643e into main Nov 6, 2024
2 checks passed
@danny-avila danny-avila deleted the refactor/haiku-3.5-function-format-title branch November 6, 2024 18:40
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.

[Bug]: Chat title not generated properly when using claude-3-5-haiku-20241022 as Anthropic title model
1 participant