Commit 4d8eec9
authored
refactor: enhance model validation and provider inference in LLM class (#3976)
* refactor: enhance model validation and provider inference in LLM class
- Updated the model validation logic to support pattern matching for new models and "latest" versions, improving flexibility for various providers.
- Refactored the `_validate_model_in_constants` method to first check hardcoded constants and then fall back to pattern matching.
- Introduced `_matches_provider_pattern` to streamline provider-specific model checks.
- Enhanced the `_infer_provider_from_model` method to utilize pattern matching for better provider inference.
This refactor aims to improve the extensibility of the LLM class, allowing it to accommodate new models without requiring constant updates to the hardcoded lists.
* feat: add new Anthropic model versions to constants
- Introduced "claude-opus-4-5-20251101" and "claude-opus-4-5" to the AnthropicModels and ANTHROPIC_MODELS lists for enhanced model support.
- Added "anthropic.claude-opus-4-5-20251101-v1:0" to BedrockModels and BEDROCK_MODELS to ensure compatibility with the latest model offerings.
- Updated test cases to ensure proper environment variable handling for model validation, improving robustness in testing scenarios.
* dont infer this way - dropped1 parent 2025a26 commit 4d8eec9
File tree
3 files changed
+128
-27
lines changed- lib/crewai
- src/crewai
- llms
- tests
3 files changed
+128
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
410 | | - | |
411 | | - | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
412 | 415 | | |
413 | 416 | | |
414 | | - | |
| 417 | + | |
415 | 418 | | |
416 | 419 | | |
417 | 420 | | |
418 | | - | |
| 421 | + | |
419 | 422 | | |
| 423 | + | |
| 424 | + | |
420 | 425 | | |
421 | | - | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
422 | 430 | | |
423 | 431 | | |
424 | | - | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
425 | 435 | | |
426 | | - | |
427 | | - | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
428 | 441 | | |
429 | 442 | | |
430 | | - | |
| 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 | + | |
431 | 481 | | |
432 | 482 | | |
433 | 483 | | |
434 | 484 | | |
435 | 485 | | |
436 | | - | |
| 486 | + | |
| 487 | + | |
437 | 488 | | |
438 | 489 | | |
439 | 490 | | |
440 | 491 | | |
441 | 492 | | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
442 | 497 | | |
443 | 498 | | |
444 | 499 | | |
445 | 500 | | |
446 | 501 | | |
447 | 502 | | |
448 | | - | |
449 | 503 | | |
450 | 504 | | |
451 | 505 | | |
| |||
1699 | 1753 | | |
1700 | 1754 | | |
1701 | 1755 | | |
1702 | | - | |
1703 | | - | |
1704 | | - | |
1705 | | - | |
1706 | | - | |
1707 | | - | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
| 1762 | + | |
| 1763 | + | |
1708 | 1764 | | |
1709 | 1765 | | |
1710 | 1766 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| 185 | + | |
| 186 | + | |
185 | 187 | | |
186 | 188 | | |
187 | 189 | | |
| |||
208 | 210 | | |
209 | 211 | | |
210 | 212 | | |
| 213 | + | |
| 214 | + | |
211 | 215 | | |
212 | 216 | | |
213 | 217 | | |
| |||
452 | 456 | | |
453 | 457 | | |
454 | 458 | | |
| 459 | + | |
455 | 460 | | |
456 | 461 | | |
457 | 462 | | |
| |||
524 | 529 | | |
525 | 530 | | |
526 | 531 | | |
| 532 | + | |
527 | 533 | | |
528 | 534 | | |
529 | 535 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
247 | 251 | | |
248 | 252 | | |
249 | 253 | | |
| |||
702 | 706 | | |
703 | 707 | | |
704 | 708 | | |
| 709 | + | |
705 | 710 | | |
706 | 711 | | |
707 | 712 | | |
708 | 713 | | |
709 | 714 | | |
710 | 715 | | |
711 | | - | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
712 | 719 | | |
713 | 720 | | |
714 | 721 | | |
| |||
751 | 758 | | |
752 | 759 | | |
753 | 760 | | |
754 | | - | |
| 761 | + | |
755 | 762 | | |
756 | 763 | | |
757 | 764 | | |
758 | 765 | | |
759 | 766 | | |
760 | | - | |
761 | | - | |
| 767 | + | |
| 768 | + | |
762 | 769 | | |
763 | | - | |
| 770 | + | |
764 | 771 | | |
765 | 772 | | |
766 | 773 | | |
767 | 774 | | |
768 | 775 | | |
769 | 776 | | |
770 | 777 | | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
771 | 793 | | |
772 | 794 | | |
773 | 795 | | |
| |||
821 | 843 | | |
822 | 844 | | |
823 | 845 | | |
824 | | - | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
825 | 849 | | |
826 | 850 | | |
827 | 851 | | |
828 | | - | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
829 | 857 | | |
830 | 858 | | |
831 | 859 | | |
832 | | - | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
833 | 863 | | |
834 | 864 | | |
835 | 865 | | |
836 | 866 | | |
837 | 867 | | |
838 | 868 | | |
839 | | - | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
0 commit comments