Commit a5ba264
authored
# Modernize TavilyTextSearch and BraveTextSearch connectors with
ITextSearch interface
## Problem Statement
The TavilyTextSearch and BraveTextSearch connectors currently implement
only the legacy ITextSearch interface, forcing users to use clause-based
TextSearchFilter instead of modern type-safe LINQ expressions.
Additionally, the existing LINQ support is limited to basic expressions
(equality, AND operations).
## Technical Approach
This PR modernizes both connectors with generic interface implementation
and extends LINQ filtering to support OR operations, negation, and
inequality operators. The implementation adds type-safe model classes
and enhanced expression tree analysis capabilities.
### Implementation Details
**Core Changes**
- Both connectors now implement ITextSearch (legacy) and
ITextSearch<TRecord> (modern)
- Added type-safe model classes: TavilyWebPage and BraveWebPage
- Extended AnalyzeExpression() methods to handle additional expression
node types
- Added support for OrElse, NotEqual, and UnaryExpression operations
- Implemented array.Contains(property) pattern recognition
- Enhanced error messaging with contextual examples
**Enhanced LINQ Expression Support**
- OR Operations (||): Maps to multiple API parameter values or OR logic
- NOT Operations (!): Converts to exclusion parameters where supported
- Inequality Operations (!=): Provides helpful error messages suggesting
NOT alternatives
- Array Contains Pattern: Supports array.Contains(property) for
multi-value filtering
### Code Examples
**Before (Legacy Interface)**
```csharp
var legacyOptions = new TextSearchOptions
{
Filter = new TextSearchFilter()
.Equality("topic", "general")
.Equality("time_range", "week")
};
```
**After (Generic Interface)**
```csharp
// Simple filtering
var modernOptions = new TextSearchOptions<TavilyWebPage>
{
Filter = page => page.Topic == "general" && page.TimeRange == "week"
};
// Advanced filtering with OR and array Contains
var advancedOptions = new TextSearchOptions<BraveWebPage>
{
Filter = page => (page.Country == "US" || page.Country == "GB") &&
new[] { "moderate", "strict" }.Contains(page.SafeSearch) &&
!(page.ResultFilter == "adult")
};
```
## Implementation Benefits
### Interface Modernization
- Type-safe filtering with compile-time validation prevents property
name typos
- IntelliSense support for TavilyWebPage and BraveWebPage properties
- Consistent LINQ-based filtering across all text search implementations
### Enhanced Filtering Capabilities
- OR operations enable multi-value property matching
- NOT operations provide exclusion filtering where API supports it
- Array Contains patterns simplify multi-value filtering syntax
- Improved error messages reduce debugging time
### Developer Experience
- Better debugging experience with type information
- Reduced learning curve - same patterns across all connectors
- Enhanced error messages with usage examples and supported properties
## Validation Results
**Build Verification**
- Configuration: Release
- Target Framework: .NET 8.0
- Command: `dotnet build --configuration Release --interactive`
- Result: Build succeeded - all projects compiled successfully
**Test Results**
**Full Test Suite:**
- Passed: 8,829 (core functionality tests)
- Failed: 1,361 (external API configuration issues)
- Skipped: 389
- Duration: 4 minutes 57 seconds
**Core Unit Tests:**
- Command: `dotnet test
src\SemanticKernel.UnitTests\SemanticKernel.UnitTests.csproj
--configuration Release`
- Result: 1,574 passed, 0 failed (100% core framework functionality)
**Test Failure Analysis**
The **1,361 test failures** are infrastructure/configuration issues,
**not code defects**:
- **Azure OpenAI Configuration**: Missing API keys for external service
integration tests
- **Docker Dependencies**: Vector database containers not available in
development environment
- **External Service Dependencies**: Integration tests requiring live
API services (Bing, Google, Brave, Tavily, etc.)
- **AWS/Azure Configuration**: Missing credentials for cloud service
integration tests
These failures are **expected in development environments** without
external API configurations.
**Code Quality**
- Formatting: Applied via `dotnet format SK-dotnet.slnx`
- Enhanced documentation follows XML documentation conventions
- Consistent with established LINQ expression handling patterns
## Files Modified
```
dotnet/src/Plugins/Plugins.Web/Tavily/TavilyWebPage.cs (NEW)
dotnet/src/Plugins/Plugins.Web/Brave/BraveWebPage.cs (NEW)
dotnet/src/Plugins/Plugins.Web/Brave/BraveTextSearch.cs (MODIFIED)
dotnet/src/Plugins/Plugins.Web/Tavily/TavilyTextSearch.cs (MODIFIED)
```
## Breaking Changes
None. All existing LINQ expressions continue to work unchanged with
enhanced error message generation.
## Multi-PR Context
This is PR 5 of 6 in the structured implementation approach for Issue
#10456. This PR completes the modernization of remaining text search
connectors with enhanced LINQ expression capabilities while maintaining
full backward compatibility.
---------
Co-authored-by: Alexander Zarei <[email protected]>
1 parent 0ee64f1 commit a5ba264
File tree
8 files changed
+1595
-13
lines changed- dotnet/src
- Plugins
- Plugins.UnitTests/Web
- Brave
- Tavily
- Plugins.Web
- Brave
- FilterClauses
- Tavily
- VectorData/VectorData.Abstractions/FilterClauses
8 files changed
+1595
-13
lines changedLines 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