Commit 90e16b1
committed
Uncheck this commit when reviewing PR6 please.
temp: Borrow PR5 changes temporarily for CI/CD validation
This commit contains all changes from PR5 (feature-text-search-linq-pr5).
These changes are being temporarily included in PR6 because:
- PR5 has not been merged yet
- PR6 depends on PR5 to pass CI/CD validation
- After PR5 is merged, PR6 will be rebased to remove this commit
- The final PR6 will show only PR6-specific changes without the extra diff
- Uncheck this commit when reviewing PR6 please.
Original PR5 summary:
feat: Modernize TavilyTextSearch and BraveTextSearch with ITextSearch<TRecord> interface
- Add TavilyWebPage and BraveWebPage model classes for type-safe LINQ filtering
- Implement dual interface support (ITextSearch + ITextSearch<TRecord>) in both connectors
- Add LINQ-to-API conversion logic for Tavily and Brave search parameters
- Maintain 100% backward compatibility with existing ITextSearch usage
- Enable compile-time type safety and IntelliSense support for web search filters
Addresses #10456
Enhance text search LINQ support with OR/NOT operators and improved error messages
- Added support for OrElse (||) operators in LINQ expressions
- Added NotEqual (!=) operator support with appropriate error handling
- Added UnaryExpression (NOT) support with proper limitations
- Enhanced Contains method support for array.Contains(property) patterns
- Improved error messages with usage examples
- Added constants for API parameter names for better maintainability
- Added TODO comments for potential code sharing opportunities
Changes apply to both BraveTextSearch and TavilyTextSearch implementations.
fix: Resolve CA1056 code analysis violations in web search connectors
- Changed Url property from string? to Uri? in TavilyWebPage
- Changed Url property from string? to Uri? in BraveWebPage
- Updated constructors to accept Uri? parameters
- Added null-safe string-to-Uri conversions in factory methods
- Fixed image URL handling in TavilyTextSearch
Resolves all 31 CA1056 violations (URI properties should not be strings).
feat: Add C# 14 MemoryExtensions.Contains compatibility to text search connectors
- Implement IsMemoryExtensionsContains() detection in TavilyTextSearch and BraveTextSearch
- Handle C# 14+ MemoryExtensions.Contains method resolution (static calls with 2-3 parameters)
- Provide clear error messages explaining API limitations and suggesting alternatives
- Maintain backward compatibility with C# 13- Enumerable.Contains patterns
Validation: Build (0 warnings), Tests (1574 passed), AOT compatible
Fixes #10456
feat: add generic interface tests and fix collection Contains exception handling
- Added comprehensive generic interface tests for both Tavily and Brave connectors
- TavilyTextSearchTests: 3 new tests for ITextSearch<TavilyWebPage> interface
- BraveTextSearchTests: 3 new tests for ITextSearch<BraveWebPage> interface
- Tests cover SearchAsync, GetSearchResultsAsync, and GetTextSearchResultsAsync methods
- Added proper mocking with MultipleHttpMessageHandlerStub and test data
- Fixed collection Contains exception handling to prevent graceful degradation
- Modified ConvertToLegacyOptions in both connectors to re-throw critical exceptions
- Collection Contains patterns now properly throw NotSupportedException instead of degrading
- Maintains graceful degradation for other unsupported LINQ patterns
- Fixed previously failing CollectionContainsFilterThrowsNotSupportedExceptionAsync test
- Enhanced C# 14 MemoryExtensions.Contains compatibility
- Improved error messages to cover both C# 13- (Enumerable.Contains) and C# 14+ (MemoryExtensions.Contains)
- All collection Contains patterns now properly handled regardless of C# language version
Test Results:
- Tavily: 30 tests passed (including 3 new generic interface tests)
- Brave: 24 tests passed (including 3 new generic interface tests)
- All collection Contains exception tests now pass correctly
Fix API type changes to return TRecord instead of object
- Update BraveTextSearch and TavilyTextSearch to properly implement ITextSearch<TRecord>
- Fix unit tests to use strongly-typed generic interfaces
- Ensure backward compatibility with legacy ITextSearch interface
- All 105 text search tests passing, full validation completed
Resolves API type safety issues described in How-to-Fix-API-Type-Change-to-TRecord-PR5.md
Correct approach: Revert unnecessary non-generic test changes and rename Generic→Linq
- Revert GetSearchResultsReturnsSuccessfullyAsync to use non-generic interface (var textSearch, KernelSearchResults<object>)
- This test should test backward compatibility with legacy ITextSearch interface
- Only generic interface tests should use ITextSearch<TRecord> and KernelSearchResults<TRecord>
- Rename 'Generic' test methods to 'Linq' to match naming convention from other PRs:
- GenericSearchAsyncReturnsResultsSuccessfullyAsync → LinqSearchAsyncReturnsResultsSuccessfullyAsync
- GenericGetSearchResultsAsyncReturnsResultsSuccessfullyAsync → LinqGetSearchResultsAsyncReturnsResultsSuccessfullyAsync
- GenericGetTextSearchResultsAsyncReturnsResultsSuccessfullyAsync → LinqGetTextSearchResultsAsyncReturnsResultsSuccessfullyAsync
- Applied to both BraveTextSearchTests.cs and TavilyTextSearchTests.cs
- All 105 text search tests still passing
Fix maintains proper test separation:
- Non-generic tests: Test legacy ITextSearch interface compatibility
- LINQ tests: Test new ITextSearch<TRecord> strongly-typed interface
feat: Implement Title.Contains() support for Brave and Tavily text search
- Add SearchQueryFilterClause for query enhancement pattern
- Implement Title.Contains() → query modification for Brave and Tavily APIs
- Support LINQ expressions: results.Where(r => r.Title.Contains('AI'))
- Query enhancement: 'base query' + ' AI' for improved relevance
- Maintains backward compatibility with legacy ITextSearch interface
- All 130 web plugin tests passing
Technical approach:
- SearchQueryFilterClause: New filter clause type for search term addition
- ConvertToLegacyOptionsWithQuery: Extract and append search terms to query
- Different from Bing (direct operators) and Google (API parameters)
- Optimized for APIs without field-specific search capabilities
fix: Remove trailing whitespace from SearchQueryFilterClause.cs
- Fix RCS1037 trailing whitespace errors on lines 12, 16, 18
- Add missing final newline to prevent FINALNEWLINE error
- Fix file encoding issues (BOM removal)
- Addresses GitHub CI/CD build failures for net8.0, net462, netstandard2.0 targets
All formatting issues resolved to match GitHub Actions requirements.1 parent 0ee64f1 commit 90e16b1
7 files changed
Lines changed: 1589 additions & 12 deletions
File tree
- dotnet/src
- Plugins
- Plugins.UnitTests/Web
- Brave
- Tavily
- Plugins.Web
- Brave
- Tavily
- VectorData/VectorData.Abstractions/FilterClauses
Lines changed: 149 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
113 | | - | |
| 114 | + | |
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
| |||
195 | 196 | | |
196 | 197 | | |
197 | 198 | | |
198 | | - | |
| 199 | + | |
199 | 200 | | |
200 | 201 | | |
201 | 202 | | |
| |||
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
246 | 392 | | |
247 | 393 | | |
248 | 394 | | |
| |||
273 | 419 | | |
274 | 420 | | |
275 | 421 | | |
276 | | - | |
| 422 | + | |
277 | 423 | | |
278 | 424 | | |
279 | 425 | | |
| |||
Lines changed: 151 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
346 | 347 | | |
347 | 348 | | |
348 | 349 | | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
349 | 500 | | |
350 | 501 | | |
351 | 502 | | |
| |||
0 commit comments