Skip to content

Commit

Permalink
fix: All files pre commit (crewAIInc#1249)
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonbyte authored Aug 23, 2024
1 parent 782ce22 commit f777c1c
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/crewai/agents/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
from .executor import CrewAgentExecutor
from .parser import CrewAgentParser
from .tools_handler import ToolsHandler

__all__ = ["CacheHandler", "CrewAgentExecutor", "CrewAgentParser", "ToolsHandler"]
2 changes: 2 additions & 0 deletions src/crewai/agents/cache/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .cache_handler import CacheHandler

__all__ = ["CacheHandler"]
2 changes: 2 additions & 0 deletions src/crewai/crews/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .crew_output import CrewOutput

__all__ = ["CrewOutput"]
2 changes: 2 additions & 0 deletions src/crewai/memory/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from .entity.entity_memory import EntityMemory
from .long_term.long_term_memory import LongTermMemory
from .short_term.short_term_memory import ShortTermMemory

__all__ = ["EntityMemory", "LongTermMemory", "ShortTermMemory"]
9 changes: 5 additions & 4 deletions src/crewai/memory/storage/rag_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import shutil
from typing import Any, Dict, List, Optional

from crewai.memory.storage.interface import Storage
from crewai.utilities.paths import db_storage_path
from embedchain import App
from embedchain.llm.base import BaseLlm
from embedchain.models.data_type import DataType
from embedchain.vectordb.chroma import InvalidDimensionException

from crewai.memory.storage.interface import Storage
from crewai.utilities.paths import db_storage_path


@contextlib.contextmanager
def suppress_logging(
Expand Down Expand Up @@ -77,12 +78,12 @@ def __init__(self, type, allow_reset=True, embedder_config=None, crew=None):
self.app.llm = FakeLLM()
if allow_reset:
self.app.reset()

def _sanitize_role(self, role: str) -> str:
"""
Sanitizes agent roles to ensure valid directory names.
"""
return role.replace('\n', '').replace(' ', '_').replace('/', '_')
return role.replace("\n", "").replace(" ", "_").replace("/", "_")

def save(self, value: Any, metadata: Dict[str, Any]) -> None:
self._generate_embedding(value, metadata)
Expand Down
2 changes: 2 additions & 0 deletions src/crewai/pipeline/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from crewai.pipeline.pipeline import Pipeline
from crewai.pipeline.pipeline_kickoff_result import PipelineKickoffResult
from crewai.pipeline.pipeline_output import PipelineOutput

__all__ = ["Pipeline", "PipelineKickoffResult", "PipelineOutput"]
2 changes: 2 additions & 0 deletions src/crewai/routers/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from crewai.routers.router import Router

__all__ = ["Router"]
4 changes: 3 additions & 1 deletion src/crewai/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@ def _execute_core(
content = (
json_output
if json_output
else pydantic_output.model_dump_json() if pydantic_output else result
else pydantic_output.model_dump_json()
if pydantic_output
else result
)
self._save_file(content)

Expand Down
2 changes: 2 additions & 0 deletions src/crewai/telemetry/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .telemetry import Telemetry

__all__ = ["Telemetry"]
5 changes: 4 additions & 1 deletion src/crewai/utilities/parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re


class YamlParser:
@staticmethod
def parse(file):
Expand All @@ -16,7 +17,9 @@ def parse(file):

# Replace single { and } with doubled ones, while leaving already doubled ones intact and the other special characters {# and {%
modified_content = re.sub(r"(?<!\{){(?!\{)(?!\#)(?!\%)", "{{", content)
modified_content = re.sub(r"(?<!\})(?<!\%)(?<!\#)\}(?!})", "}}", modified_content)
modified_content = re.sub(
r"(?<!\})(?<!\%)(?<!\#)\}(?!})", "}}", modified_content
)

# Check for 'context:' not followed by '[' and raise an error
if re.search(r"context:(?!\s*\[)", modified_content):
Expand Down
4 changes: 3 additions & 1 deletion tests/pipeline/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ def __deepcopy__(self, memo):
(
"route1"
if x.get("score", 0) > 80
else "route2" if x.get("score", 0) > 50 else "default"
else "route2"
if x.get("score", 0) > 50
else "default"
),
)
)
Expand Down

0 comments on commit f777c1c

Please sign in to comment.