mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-01 07:13:00 +00:00
Merge branch 'main' into gl/fix/crewai-tools-mypy
This commit is contained in:
35
.github/workflows/type-checker.yml
vendored
35
.github/workflows/type-checker.yml
vendored
@@ -17,8 +17,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
fetch-depth: 0 # Fetch all history for proper diff
|
|
||||||
|
|
||||||
- name: Restore global uv cache
|
- name: Restore global uv cache
|
||||||
id: cache-restore
|
id: cache-restore
|
||||||
@@ -42,37 +40,8 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: uv sync --all-groups --all-extras
|
run: uv sync --all-groups --all-extras
|
||||||
|
|
||||||
- name: Get changed Python files
|
- name: Run type checks
|
||||||
id: changed-files
|
run: uv run mypy lib/crewai/src/crewai/
|
||||||
run: |
|
|
||||||
# Get the list of changed Python files compared to the base branch
|
|
||||||
echo "Fetching changed files..."
|
|
||||||
git diff --name-only --diff-filter=ACMRT origin/${{ github.base_ref }}...HEAD -- '*.py' > changed_files.txt
|
|
||||||
|
|
||||||
# Filter for files in src/ directory only (excluding tests/)
|
|
||||||
grep -E "^src/" changed_files.txt > filtered_changed_files.txt || true
|
|
||||||
|
|
||||||
# Check if there are any changed files
|
|
||||||
if [ -s filtered_changed_files.txt ]; then
|
|
||||||
echo "Changed Python files in src/:"
|
|
||||||
cat filtered_changed_files.txt
|
|
||||||
echo "has_changes=true" >> $GITHUB_OUTPUT
|
|
||||||
# Convert newlines to spaces for mypy command
|
|
||||||
echo "files=$(cat filtered_changed_files.txt | tr '\n' ' ')" >> $GITHUB_OUTPUT
|
|
||||||
else
|
|
||||||
echo "No Python files changed in src/"
|
|
||||||
echo "has_changes=false" >> $GITHUB_OUTPUT
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Run type checks on changed files
|
|
||||||
if: steps.changed-files.outputs.has_changes == 'true'
|
|
||||||
run: |
|
|
||||||
echo "Running mypy on changed files with Python ${{ matrix.python-version }}..."
|
|
||||||
uv run mypy ${{ steps.changed-files.outputs.files }}
|
|
||||||
|
|
||||||
- name: No files to check
|
|
||||||
if: steps.changed-files.outputs.has_changes == 'false'
|
|
||||||
run: echo "No Python files in src/ were modified - skipping type checks"
|
|
||||||
|
|
||||||
- name: Save uv caches
|
- name: Save uv caches
|
||||||
if: steps.cache-restore.outputs.cache-hit != 'true'
|
if: steps.cache-restore.outputs.cache-hit != 'true'
|
||||||
|
|||||||
@@ -240,10 +240,9 @@ class BraveSearchToolBase(BaseTool, ABC):
|
|||||||
# (e.g., 422 Unprocessable Entity, 400 Bad Request (OPTION_NOT_IN_PLAN))
|
# (e.g., 422 Unprocessable Entity, 400 Bad Request (OPTION_NOT_IN_PLAN))
|
||||||
_raise_for_error(resp)
|
_raise_for_error(resp)
|
||||||
|
|
||||||
# All retries exhausted
|
# All retries exhausted — last_resp is always set when we reach here
|
||||||
if last_resp is not None:
|
_raise_for_error(last_resp or resp)
|
||||||
_raise_for_error(last_resp)
|
return {} # unreachable; satisfies return type
|
||||||
return {}
|
|
||||||
|
|
||||||
def _run(self, q: str | None = None, **params: Any) -> Any:
|
def _run(self, q: str | None = None, **params: Any) -> Any:
|
||||||
# Allow positional usage: tool.run("latest Brave browser features")
|
# Allow positional usage: tool.run("latest Brave browser features")
|
||||||
|
|||||||
@@ -374,10 +374,8 @@ def human_feedback(
|
|||||||
) -> Any:
|
) -> Any:
|
||||||
"""Recall past HITL lessons and use LLM to pre-review the output."""
|
"""Recall past HITL lessons and use LLM to pre-review the output."""
|
||||||
try:
|
try:
|
||||||
from crewai.memory.unified_memory import Memory
|
|
||||||
|
|
||||||
mem = flow_instance.memory
|
mem = flow_instance.memory
|
||||||
if not isinstance(mem, Memory):
|
if mem is None:
|
||||||
return method_output
|
return method_output
|
||||||
query = f"human feedback lessons for {func.__name__}: {method_output!s}"
|
query = f"human feedback lessons for {func.__name__}: {method_output!s}"
|
||||||
matches = mem.recall(query, source=learn_source)
|
matches = mem.recall(query, source=learn_source)
|
||||||
@@ -412,10 +410,8 @@ def human_feedback(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Extract generalizable lessons from output + feedback, store in memory."""
|
"""Extract generalizable lessons from output + feedback, store in memory."""
|
||||||
try:
|
try:
|
||||||
from crewai.memory.unified_memory import Memory
|
|
||||||
|
|
||||||
mem = flow_instance.memory
|
mem = flow_instance.memory
|
||||||
if not isinstance(mem, Memory):
|
if mem is None:
|
||||||
return
|
return
|
||||||
llm_inst = _resolve_llm_instance()
|
llm_inst = _resolve_llm_instance()
|
||||||
prompt = _get_hitl_prompt("hitl_distill_user").format(
|
prompt = _get_hitl_prompt("hitl_distill_user").format(
|
||||||
@@ -448,7 +444,7 @@ def human_feedback(
|
|||||||
]
|
]
|
||||||
|
|
||||||
if lessons:
|
if lessons:
|
||||||
mem.remember_many(lessons, source=learn_source)
|
mem.remember_many(lessons, source=learn_source) # type: ignore[union-attr]
|
||||||
except Exception: # noqa: S110
|
except Exception: # noqa: S110
|
||||||
pass # non-critical: don't fail the flow because lesson storage failed
|
pass # non-critical: don't fail the flow because lesson storage failed
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user