Skip to content

Add Phase 3 operations: detect_language, generate_tags, anonymize, and compare#3

Open
patrols wants to merge 9 commits intomainfrom
feature/phase-3-operations
Open

Add Phase 3 operations: detect_language, generate_tags, anonymize, and compare#3
patrols wants to merge 9 commits intomainfrom
feature/phase-3-operations

Conversation

@patrols
Copy link
Owner

@patrols patrols commented Feb 19, 2026

Summary

Adds 4 new text operations with input validation and comprehensive test coverage.

New Operations

  • detect_language - Identifies the language of input text
  • generate_tags - Extracts relevant tags/keywords from text
  • anonymize - Redacts PII (names, emails, phone numbers, etc.) from text
  • compare - Compares two texts and identifies similarities/differences

Changes

  • 4 new operation modules in lib/ruby_llm/text/
  • New Validation module for consistent input validation
  • String extension methods for the new operations
  • Comprehensive test suites for each operation
  • Updated manual test script with examples

patrols and others added 5 commits February 18, 2026 22:03
Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
- Add require statements and module methods to main Text module
- Add model configuration attributes for all new operations
- Add String extension methods with special handling for compare()

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
- Complete test suites for all 4 operations with 151 total tests
- Tests cover simple/structured responses, error handling, configuration
- Updated String extension tests for new methods
- All tests passing with established mocking patterns

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
- Create Validation module with ValidationError class
- Add validate_text!, validate_required!, validate_array!, validate_one_of! helpers
- All 13 operations now validate inputs before LLM calls
- Consistent error messages: "text cannot be nil", "schema is required", etc.
- Update manual-test binstub with Phase 3 operations
- Full test coverage for validation (186 tests, 516 assertions)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@patrols patrols changed the title Add 4 new operations: detect_language, generate_tags, anonymize, compare Add Phase 3 operations: detect_language, generate_tags, anonymize, and compare Feb 19, 2026
@patrols patrols marked this pull request as ready for review February 19, 2026 07:28
patrols and others added 2 commits February 19, 2026 14:32
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

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 pull request adds Phase 3 operations to the ruby_llm-text gem, introducing four new text processing methods with comprehensive validation and test coverage. The changes build upon the existing Phase 1 and Phase 2 operations by adding language detection, tag generation, PII anonymization, and text comparison capabilities.

Changes:

  • Four new text operations: detect_language, generate_tags, anonymize, and compare with configurable behavior and structured outputs
  • New Validation module providing consistent input validation across all operations (replacing ad-hoc ArgumentError usage)
  • Extended string monkey-patching support for all new operations
  • Version bump from 0.2.0 to 0.3.0 with comprehensive documentation updates

Reviewed changes

Copilot reviewed 30 out of 31 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/ruby_llm/text/validation.rb New validation module with ValidationError class and helper methods for consistent input validation
lib/ruby_llm/text/detect_language.rb Language detection with optional confidence scores and ISO language codes
lib/ruby_llm/text/generate_tags.rb Tag/keyword generation with multiple style options (keywords, topics, hashtags)
lib/ruby_llm/text/anonymize.rb PII anonymization supporting multiple entity types and replacement styles
lib/ruby_llm/text/compare.rb Text comparison with similarity scoring and multiple comparison modes
lib/ruby_llm/text/configuration.rb Added configuration attributes for the four new operations
lib/ruby_llm/text.rb Module-level API methods for new operations
lib/ruby_llm/text/string_ext.rb String extensions for new operations
lib/ruby_llm/text/{summarize,translate,extract,classify,rewrite,answer,sentiment,key_points,grammar}.rb Updated existing operations to use Validation module
test/ruby_llm/text/validation_test.rb Comprehensive validation module tests including integration tests
test/ruby_llm/text/{detect_language,generate_tags,anonymize,compare}_test.rb Full test suites for new operations
test/ruby_llm/text/string_ext_test.rb Tests for new string extensions
test/ruby_llm/text/{rewrite,extract,classify}_test.rb Updated tests to expect ValidationError instead of ArgumentError
README.md Documentation for all four new operations with examples
CHANGELOG.md Version 0.3.0 release notes
AI.md New AI assistant context document
bin/manual-test Manual testing script updated with Phase 3 examples

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

The else branch was recursively calling build_prompt, which returns a
complete prompt string. This caused the instruction to contain a nested
prompt instead of just the instruction text. Now uses the instruction
string directly, matching the pattern in generate_tags.rb.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

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 30 out of 31 changed files in this pull request and generated 2 comments.


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

- Add ALL_PII_TYPES constant with all 6 PII types
- Make :all shortcut expand to ALL_PII_TYPES (not just defaults)
- Add SSN and credit_cards handling to :numbered style
- Add SSN and credit_cards handling to :descriptive style

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

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 30 out of 31 changed files in this pull request and generated no new comments.


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

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.

2 participants