Compare commits

..

48 Commits

Author SHA1 Message Date
Lorenze Jay
007ea5e839 Merge branch 'main' into feat/individual-react-agent 2025-04-02 08:47:13 -07:00
Lorenze Jay
52aeac4b75 Remove redundant error handling for action and final answer in CrewAgentParser. Update tests to reflect this change by deleting the corresponding test case. 2025-04-01 14:10:37 -07:00
Lorenze Jay
e33532796b Merge branch 'feat/individual-react-agent' of github.com:crewAIInc/crewAI into feat/individual-react-agent 2025-04-01 12:38:32 -07:00
Lorenze Jay
7f0d80d427 Add Excalidraw diagram file for visual representation of input-output flow
Created a new Excalidraw file that includes a diagram illustrating the input box, database, and output box with connecting arrows. This visual aid enhances understanding of the data flow within the application.
2025-04-01 12:38:27 -07:00
Lorenze Jay
e4df956bea Merge branch 'main' into feat/individual-react-agent 2025-04-01 12:08:40 -07:00
Lorenze Jay
01ebf802e3 Refactor agent tests by removing outdated test cases and updating YAML cassettes to reflect changes in tool usage and response formats. Adjusted request and response headers, including user agent and content length, for improved accuracy in testing. Enhanced interaction formats for consistency across tests. 2025-03-31 17:00:54 -07:00
Lorenze Jay
4856c4a685 Update tool usage logging to store tool arguments as native types instead of strings, enhancing data integrity and usability. 2025-03-31 16:51:18 -07:00
Lorenze Jay
bfcc228bc3 Update YAML cassette for LLM tests to reflect changes in response structure and model version. Adjusted request and response headers, including updated content length and user agent. Enhanced token limits and request counts for improved testing accuracy. 2025-03-31 16:46:39 -07:00
Lorenze Jay
802a4d079f Update tool usage logging to ensure tool arguments are consistently formatted as strings. Adjust agent test cases to reflect changes in maximum iterations and expected outputs, enhancing clarity in assertions. Update YAML cassettes to align with new response formats and improve overall consistency across tests. 2025-03-31 16:42:51 -07:00
Lorenze Jay
570c7845fa Refactor agent tests to update model versions and improve response formatting in YAML cassettes. Changed model references from 'o1-preview' to 'o3-mini' and adjusted interaction formats for consistency. Enhanced error handling in context length tests and refined mock setups for better clarity. 2025-03-31 16:17:25 -07:00
Lorenze Jay
8f5d6f720d Update agent tests to reflect changes in expected call counts and improve response formatting in YAML cassette. Adjusted mock call count from 2 to 3 and refined interaction formats for clarity and consistency. 2025-03-31 15:34:13 -07:00
Lorenze Jay
99614f83e0 Enhance tests in crew_test.py by verifying cache behavior in test_tools_with_custom_caching and ensuring proper agent initialization with added commas in test_crew_kickoff_for_each_works_with_manager_agent_copy. 2025-03-31 15:29:07 -07:00
Lorenze Jay
288afba5fa Refactor agent_utils.py by removing unused event imports and adding missing commas in function definitions. Update test_events.py to reflect changes in expected event counts and adjust assertions accordingly. Modify test_tools_emits_error_events.yaml to include new headers and update response content for consistency with recent API changes. 2025-03-31 15:21:44 -07:00
Lorenze Jay
b8d871e795 Merge branch 'main' of github.com:crewAIInc/crewAI into feat/individual-react-agent 2025-03-31 12:21:41 -07:00
Lorenze Jay
4deff49b70 Add initialization for 'result' variable in ToolUsage class to resolve type-checker warnings 2025-03-31 12:20:16 -07:00
Lorenze Jay
08f0fc2285 Remove unused variable 'result' from ToolUsage class to clean up code. 2025-03-31 12:16:11 -07:00
Lorenze Jay
7107224fa9 Remove deprecated test files and examples for LiteAgent; add comprehensive tests for LiteAgent functionality, including tool usage and structured output handling. 2025-03-31 12:13:25 -07:00
Lorenze Jay
a00eaa4732 Remove unused parameters from ToolUsage instantiation in tests and clean up debug print statement in CrewAgentParser. 2025-03-31 11:52:20 -07:00
Lorenze Jay
347ff85180 Add optional agent parameter to CrewAgentParser and enhance action handling logic 2025-03-31 10:29:04 -07:00
Lorenze Jay
48b10600d3 Fix type-checker issue by adding type ignore comment for cache read in ToolUsage class 2025-03-31 10:01:02 -07:00
Lorenze Jay
a02f637155 fix type-checker 2025-03-31 09:50:42 -07:00
Lorenze Jay
996bbad0d3 fix fingerprinting issues 2025-03-31 09:36:30 -07:00
Lorenze Jay
859139016e Update LiteAgent documentation for clarity and consistency; replace WebsiteSearchTool with SerperDevTool, and improve formatting in examples. 2025-03-31 08:12:08 -07:00
Lorenze Jay
f99d374609 Merge branch 'main' into feat/individual-react-agent 2025-03-28 15:19:44 -07:00
Brandon Hancock
3c9058a45f More type checking fixes 2025-03-28 15:31:44 -04:00
Brandon Hancock
f8f9063d9e more type checker fixes 2025-03-28 13:59:16 -04:00
Brandon Hancock
a380bc076b Trying to fix CI issues 2025-03-28 13:03:37 -04:00
Brandon Hancock
f2927fc266 Fix errors 2025-03-28 12:58:23 -04:00
Brandon Hancock
594784473b Merge branch 'main' into feat/individual-react-agent 2025-03-28 12:52:40 -04:00
Brandon Hancock
4bfb71d749 Clean up 2025-03-28 10:55:31 -04:00
Brandon Hancock
1daeaa4a81 docs 2025-03-28 10:51:54 -04:00
Brandon Hancock
4857777a9c drop hard coded examples 2025-03-28 10:28:31 -04:00
Brandon Hancock
b8c8640f22 cleanup 2025-03-28 10:28:15 -04:00
Brandon Hancock
0ec3c37912 99% done. Need to make docs match new example 2025-03-27 17:18:33 -04:00
Brandon Hancock
30aa5cc3b9 Update logger 2025-03-27 16:21:31 -04:00
Brandon Hancock
0fca721b11 cleaning up 2025-03-27 13:30:37 -04:00
Brandon Hancock
e11c7d1fd8 WIP 2025-03-26 14:51:53 -04:00
Brandon Hancock
e6b90699a8 more testing 2025-03-26 10:54:00 -04:00
Brandon Hancock
fa62df7d18 Usage metrics fixed 2025-03-25 14:56:27 -04:00
Brandon Hancock
0785d596f0 output type works now 2025-03-25 14:42:50 -04:00
Brandon Hancock
06854fff86 Its working but needs a massive clean up 2025-03-25 13:38:52 -04:00
Brandon Hancock
998afcd498 More WIP 2025-03-25 10:50:53 -04:00
Brandon Hancock
fa15c5eb1d WIP 2025-03-25 10:36:59 -04:00
Brandon Hancock
defb0c55e6 wip 2025-03-20 08:00:32 -04:00
Brandon Hancock
e9fa9c5700 wip 2025-03-17 13:03:57 -04:00
Brandon Hancock
8e3af76252 WIP 2025-03-17 11:50:06 -04:00
Brandon Hancock
84716d4037 Merge branch 'main' into feat/individual-react-agent 2025-03-17 10:52:14 -04:00
Brandon Hancock
33192237a5 WIP 2025-03-13 09:16:18 -04:00
2 changed files with 12 additions and 137 deletions

View File

@@ -956,42 +956,22 @@ class LLM(BaseLLM):
self.context_window_size = int(value * CONTEXT_WINDOW_USAGE_RATIO)
return self.context_window_size
def set_callbacks(self, callbacks: List[Any]) -> None:
def set_callbacks(self, callbacks: List[Any]):
"""
Attempt to keep a single set of callbacks in litellm by removing old
duplicates and adding new ones.
This method safely updates the litellm callback lists by:
1. Identifying the types of new callbacks
2. Filtering out existing callbacks of the same types
3. Setting the new callbacks
Args:
callbacks: List of callback objects to set in litellm
Returns:
None
Note:
Uses list comprehension to avoid "list.remove(x): x not in list" errors
that can occur with direct removal during iteration.
"""
try:
with suppress_warnings():
callback_types = [type(callback) for callback in callbacks]
litellm.success_callback = [
cb for cb in litellm.success_callback if type(cb) not in callback_types
]
litellm._async_success_callback = [
cb for cb in litellm._async_success_callback if type(cb) not in callback_types
]
litellm.callbacks = callbacks
except Exception as e:
logging.error(f"Error setting callbacks: {str(e)}")
raise
with suppress_warnings():
callback_types = [type(callback) for callback in callbacks]
for callback in litellm.success_callback[:]:
if type(callback) in callback_types:
litellm.success_callback.remove(callback)
for callback in litellm._async_success_callback[:]:
if type(callback) in callback_types:
litellm._async_success_callback.remove(callback)
litellm.callbacks = callbacks
def set_env_callbacks(self):
"""

View File

@@ -1,105 +0,0 @@
from typing import Any, List
import litellm
import pytest
from crewai.llm import LLM
class CustomCallback:
"""A simple callback class for testing."""
pass
class DifferentCallback:
"""A different callback class for testing type differentiation."""
pass
@pytest.fixture
def reset_litellm_callbacks():
"""Fixture to reset litellm callbacks after each test."""
original_success_callback = litellm.success_callback
original_async_success_callback = litellm._async_success_callback
yield
litellm.success_callback = original_success_callback
litellm._async_success_callback = original_async_success_callback
def test_set_callbacks_handles_removed_callbacks(reset_litellm_callbacks):
"""Test that set_callbacks handles the case where callbacks are removed during iteration."""
litellm.success_callback = []
litellm._async_success_callback = []
llm = LLM(model="test-model")
callback1 = CustomCallback()
callback2 = CustomCallback()
litellm.success_callback.append(callback1)
litellm.success_callback.append(callback2)
new_callback = CustomCallback()
litellm.success_callback.remove(callback1)
llm.set_callbacks([new_callback])
assert litellm.callbacks == [new_callback]
assert len([cb for cb in litellm.success_callback if isinstance(cb, CustomCallback)]) == 0
@pytest.mark.parametrize("callback_count", [1, 3, 5])
def test_set_callbacks_with_different_sizes(callback_count, reset_litellm_callbacks):
"""Test with various numbers of callbacks."""
litellm.success_callback = []
litellm._async_success_callback = []
llm = LLM(model="test-model")
callbacks = [CustomCallback() for _ in range(callback_count)]
for callback in callbacks:
litellm.success_callback.append(callback)
new_callback = CustomCallback()
llm.set_callbacks([new_callback])
assert litellm.callbacks == [new_callback]
assert len([cb for cb in litellm.success_callback if isinstance(cb, CustomCallback)]) == 0
def test_set_callbacks_with_different_types(reset_litellm_callbacks):
"""Test that callbacks of different types are handled correctly."""
litellm.success_callback = []
litellm._async_success_callback = []
llm = LLM(model="test-model")
custom_callback = CustomCallback()
different_callback = DifferentCallback()
litellm.success_callback.append(custom_callback)
litellm.success_callback.append(different_callback)
llm.set_callbacks([CustomCallback()])
assert any(isinstance(cb, DifferentCallback) for cb in litellm.success_callback)
assert not any(isinstance(cb, CustomCallback) for cb in litellm.success_callback)
def test_set_callbacks_with_empty_list(reset_litellm_callbacks):
"""Test setting callbacks with an empty list."""
litellm.success_callback = []
litellm._async_success_callback = []
llm = LLM(model="test-model")
custom_callback = CustomCallback()
litellm.success_callback.append(custom_callback)
llm.set_callbacks([])
assert litellm.callbacks == []
assert custom_callback in litellm.success_callback