mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-03 00:02:36 +00:00
Remove deprecated test files and examples for LiteAgent; add comprehensive tests for LiteAgent functionality, including tool usage and structured output handling.
This commit is contained in:
@@ -241,12 +241,21 @@ class LiteAgent(BaseModel):
|
||||
formatted_result: Optional[BaseModel] = None
|
||||
if self.response_format:
|
||||
try:
|
||||
# Cast to BaseModel to ensure type safety
|
||||
result = self.response_format.model_validate_json(
|
||||
agent_finish.output
|
||||
final_answer_match = re.search(
|
||||
r"Final Answer:\s*(.*?)(?:\n\n|$)",
|
||||
agent_finish.output,
|
||||
re.DOTALL,
|
||||
)
|
||||
if isinstance(result, BaseModel):
|
||||
formatted_result = result
|
||||
if final_answer_match:
|
||||
json_content = final_answer_match.group(1).strip()
|
||||
result = self.response_format.model_validate_json(json_content)
|
||||
if isinstance(result, BaseModel):
|
||||
formatted_result = result
|
||||
else:
|
||||
self._printer.print(
|
||||
content="Could not find Final Answer section in the output",
|
||||
color="yellow",
|
||||
)
|
||||
except Exception as e:
|
||||
self._printer.print(
|
||||
content=f"Failed to parse output into response format: {str(e)}",
|
||||
|
||||
@@ -26,7 +26,6 @@ from crewai.utilities.events.tool_usage_events import (
|
||||
ToolSelectionErrorEvent,
|
||||
ToolUsageErrorEvent,
|
||||
ToolUsageFinishedEvent,
|
||||
ToolUsageStartedEvent,
|
||||
ToolValidateInputErrorEvent,
|
||||
)
|
||||
|
||||
@@ -169,6 +168,7 @@ class ToolUsage:
|
||||
|
||||
started_at = time.time()
|
||||
from_cache = False
|
||||
result = None
|
||||
|
||||
if self.tools_handler and self.tools_handler.cache:
|
||||
result = self.tools_handler.cache.read(
|
||||
|
||||
Reference in New Issue
Block a user