mirror of
https://github.com/crewAIInc/crewAI.git
synced 2025-12-31 03:38:30 +00:00
Compare commits
2 Commits
bugfix-pyt
...
devin/1744
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
709b8077dd | ||
|
|
2b058a9a54 |
8
.github/workflows/tests.yml
vendored
8
.github/workflows/tests.yml
vendored
@@ -12,9 +12,6 @@ jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ['3.10', '3.11', '3.12']
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
@@ -24,8 +21,9 @@ jobs:
|
||||
with:
|
||||
enable-cache: true
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
run: uv python install ${{ matrix.python-version }}
|
||||
|
||||
- name: Set up Python
|
||||
run: uv python install 3.12.8
|
||||
|
||||
- name: Install the project
|
||||
run: uv sync --dev --all-extras
|
||||
|
||||
@@ -13,6 +13,7 @@ dependencies = [
|
||||
"openai>=1.13.3",
|
||||
"litellm==1.60.2",
|
||||
"instructor>=1.3.3",
|
||||
"typing_extensions>=4.0.0",
|
||||
# Text Processing
|
||||
"pdfplumber>=0.11.4",
|
||||
"regex>=2024.9.11",
|
||||
|
||||
@@ -60,7 +60,7 @@ def test():
|
||||
"current_year": str(datetime.now().year)
|
||||
}
|
||||
try:
|
||||
{{crew_name}}().crew().test(n_iterations=int(sys.argv[1]), eval_llm=sys.argv[2], inputs=inputs)
|
||||
{{crew_name}}().crew().test(n_iterations=int(sys.argv[1]), openai_model_name=sys.argv[2], inputs=inputs)
|
||||
|
||||
except Exception as e:
|
||||
raise Exception(f"An error occurred while testing the crew: {e}")
|
||||
|
||||
@@ -1043,7 +1043,6 @@ class Flow(Generic[T], metaclass=FlowMeta):
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
raise
|
||||
|
||||
def _log_flow_event(
|
||||
self, message: str, color: str = "yellow", level: str = "info"
|
||||
|
||||
11
src/crewai/memory/external/external_memory.py
vendored
11
src/crewai/memory/external/external_memory.py
vendored
@@ -1,9 +1,16 @@
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
import sys
|
||||
|
||||
from crewai.memory.external.external_memory_item import ExternalMemoryItem
|
||||
from crewai.memory.memory import Memory
|
||||
from crewai.memory.storage.interface import Storage
|
||||
|
||||
if sys.version_info < (3, 11):
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional
|
||||
|
||||
from typing_extensions import Self
|
||||
else:
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Self
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from crewai.memory.storage.mem0_storage import Mem0Storage
|
||||
|
||||
@@ -52,7 +59,7 @@ class ExternalMemory(Memory):
|
||||
def reset(self) -> None:
|
||||
self.storage.reset()
|
||||
|
||||
def set_crew(self, crew: Any) -> "ExternalMemory":
|
||||
def set_crew(self, crew: Any) -> Self:
|
||||
super().set_crew(crew)
|
||||
|
||||
if not self.storage:
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
from typing import Any, Dict, List, Optional
|
||||
import sys
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
if sys.version_info < (3, 11):
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from typing_extensions import Self
|
||||
else:
|
||||
from typing import Any, Dict, List, Optional, Self
|
||||
|
||||
|
||||
class Memory(BaseModel):
|
||||
"""
|
||||
@@ -38,6 +45,6 @@ class Memory(BaseModel):
|
||||
query=query, limit=limit, score_threshold=score_threshold
|
||||
)
|
||||
|
||||
def set_crew(self, crew: Any) -> "Memory":
|
||||
def set_crew(self, crew: Any) -> Self:
|
||||
self.crew = crew
|
||||
return self
|
||||
|
||||
@@ -244,13 +244,9 @@ def to_langchain(
|
||||
return [t.to_structured_tool() if isinstance(t, BaseTool) else t for t in tools]
|
||||
|
||||
|
||||
def tool(*args, result_as_answer=False):
|
||||
def tool(*args):
|
||||
"""
|
||||
Decorator to create a tool from a function.
|
||||
|
||||
Args:
|
||||
*args: Positional arguments, either the function to decorate or the tool name.
|
||||
result_as_answer: Flag to indicate if the tool result should be used as the final agent answer.
|
||||
"""
|
||||
|
||||
def _make_with_name(tool_name: str) -> Callable:
|
||||
@@ -276,7 +272,6 @@ def tool(*args, result_as_answer=False):
|
||||
description=f.__doc__,
|
||||
func=f,
|
||||
args_schema=args_schema,
|
||||
result_as_answer=result_as_answer,
|
||||
)
|
||||
|
||||
return _make_tool
|
||||
|
||||
@@ -13,3 +13,14 @@ def test_crew_output_import():
|
||||
from crewai import CrewOutput
|
||||
|
||||
assert CrewOutput is not None
|
||||
|
||||
|
||||
def test_memory_imports():
|
||||
"""Test that memory imports work correctly across Python versions."""
|
||||
import importlib
|
||||
importlib.import_module("crewai.memory.memory")
|
||||
importlib.import_module("crewai.memory.external.external_memory")
|
||||
|
||||
from crewai.memory.memory import Memory
|
||||
|
||||
assert hasattr(Memory, "set_crew")
|
||||
|
||||
@@ -100,25 +100,3 @@ def test_default_cache_function_is_true():
|
||||
my_tool = MyCustomTool()
|
||||
# Assert all the right attributes were defined
|
||||
assert my_tool.cache_function()
|
||||
|
||||
|
||||
def test_result_as_answer_in_tool_decorator():
|
||||
@tool("Tool with result as answer", result_as_answer=True)
|
||||
def my_tool_with_result_as_answer(question: str) -> str:
|
||||
"""This tool will return its result as the final answer."""
|
||||
return question
|
||||
|
||||
assert my_tool_with_result_as_answer.result_as_answer is True
|
||||
|
||||
converted_tool = my_tool_with_result_as_answer.to_structured_tool()
|
||||
assert converted_tool.result_as_answer is True
|
||||
|
||||
@tool("Tool with default result_as_answer")
|
||||
def my_tool_with_default(question: str) -> str:
|
||||
"""This tool uses the default result_as_answer value."""
|
||||
return question
|
||||
|
||||
assert my_tool_with_default.result_as_answer is False
|
||||
|
||||
converted_tool = my_tool_with_default.to_structured_tool()
|
||||
assert converted_tool.result_as_answer is False
|
||||
|
||||
Reference in New Issue
Block a user