Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix breakage when cloning agent/crew using knowledge_sources and enable custom knowledge_storage #1927

Merged
merged 40 commits into from
Jan 29, 2025
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f3004ff
fix breakage when cloning agent/crew using knowledge_sources
lorenzejay Jan 19, 2025
dc9d1d6
fixed typo
lorenzejay Jan 20, 2025
c67f75d
better
lorenzejay Jan 24, 2025
591c4a5
ensure use of other knowledge storage works
lorenzejay Jan 24, 2025
71246e9
fix copy and custom storage
lorenzejay Jan 24, 2025
f34f53f
added tests
lorenzejay Jan 24, 2025
e3e62c1
normalized name
lorenzejay Jan 24, 2025
65d3837
Merge branch 'main' of github.com:crewAIInc/crewAI into fix/clone_whe…
lorenzejay Jan 24, 2025
79aaab9
updated cassette
lorenzejay Jan 24, 2025
ab8d56d
fix test
lorenzejay Jan 24, 2025
849908c
remove fixture
lorenzejay Jan 24, 2025
c6d8c75
fixed test
lorenzejay Jan 24, 2025
b87c908
fix
lorenzejay Jan 24, 2025
27e4930
add fixture to this
lorenzejay Jan 24, 2025
e4b97e3
add fixture to this
lorenzejay Jan 24, 2025
24dbdd5
Merge branch 'main' of github.com:crewAIInc/crewAI into fix/clone_whe…
lorenzejay Jan 24, 2025
4008ba7
patch twice since
lorenzejay Jan 24, 2025
65b6ff1
fix again
lorenzejay Jan 24, 2025
079692d
with fixtures
lorenzejay Jan 24, 2025
4ff9d49
better mocks
lorenzejay Jan 24, 2025
d438f5a
fix
lorenzejay Jan 24, 2025
0675a2f
simple
lorenzejay Jan 24, 2025
6fb654c
try
lorenzejay Jan 25, 2025
319128c
another
lorenzejay Jan 27, 2025
d506bdb
hopefully fixes test
lorenzejay Jan 27, 2025
cb3865a
hopefully fixes test
lorenzejay Jan 27, 2025
adec089
this should fix it !
lorenzejay Jan 27, 2025
1cc9c98
WIP: test check with prints
lorenzejay Jan 27, 2025
f4b7cff
try this
lorenzejay Jan 27, 2025
1de204e
exclude knowledge
lorenzejay Jan 27, 2025
9b88bcd
fixes
lorenzejay Jan 27, 2025
ac28f7f
just drop clone for now
lorenzejay Jan 27, 2025
42769e8
rm print statements
lorenzejay Jan 27, 2025
b92253b
printing agent_copy
lorenzejay Jan 27, 2025
8570461
checker
lorenzejay Jan 27, 2025
b183aaf
linted
lorenzejay Jan 27, 2025
fd89c3b
cleanup
lorenzejay Jan 27, 2025
6617db7
better docs
lorenzejay Jan 27, 2025
c4da244
Merge branch 'main' of github.com:crewAIInc/crewAI into fix/clone_whe…
lorenzejay Jan 27, 2025
2816e97
Merge branch 'main' into fix/clone_when_using_knowledge
bhancockio Jan 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
exclude knowledge
  • Loading branch information
lorenzejay committed Jan 27, 2025
commit 1de204eff8fa83441382d7d55d0048c83febbc20
9 changes: 8 additions & 1 deletion src/crewai/agents/agent_builder/base_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from crewai.agents.agent_builder.utilities.base_token_process import TokenProcess
from crewai.agents.cache.cache_handler import CacheHandler
from crewai.agents.tools_handler import ToolsHandler
from crewai.knowledge.knowledge import Knowledge
from crewai.knowledge.source.base_knowledge_source import BaseKnowledgeSource
from crewai.tools import BaseTool
from crewai.tools.base_tool import Tool
Expand Down Expand Up @@ -131,6 +132,9 @@ class BaseAgent(ABC, BaseModel):
max_tokens: Optional[int] = Field(
default=None, description="Maximum number of tokens for the agent's execution."
)
knowledge: Optional[Knowledge] = Field(
default=None, description="Knowledge for the agent."
)
knowledge_sources: Optional[List[BaseKnowledgeSource]] = Field(
default=None,
description="Knowledge sources for the agent.",
Expand Down Expand Up @@ -266,12 +270,14 @@ def copy(self: T) -> T: # type: ignore # Signature of "copy" incompatible with
"cache_handler",
"llm",
"knowledge_sources",
"_knowledge",
"knowledge",
"formatting_errors",
}

# Copy llm
existing_llm = shallow_copy(self.llm)
copied_knowledge = shallow_copy(self.knowledge)

print("existing_llm", existing_llm)
# Properly copy knowledge sources if they exist
existing_knowledge_sources = None
Expand Down Expand Up @@ -301,6 +307,7 @@ def copy(self: T) -> T: # type: ignore # Signature of "copy" incompatible with
llm=existing_llm,
tools=self.tools,
knowledge_sources=existing_knowledge_sources,
knowledge=copied_knowledge,
)

return copied_agent
Expand Down
Loading