mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-03 08:12:39 +00:00
Fix issue #2233: Add support for task-specific knowledge
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -207,6 +207,17 @@ class Agent(BaseAgent):
|
||||
if memory.strip() != "":
|
||||
task_prompt += self.i18n.slice("memory").format(memory=memory)
|
||||
|
||||
# Check if the task has knowledge first
|
||||
if hasattr(task, 'knowledge') and task.knowledge:
|
||||
task_knowledge_snippets = task.knowledge.query([task.prompt()])
|
||||
if task_knowledge_snippets:
|
||||
task_knowledge_context = extract_knowledge_context(
|
||||
task_knowledge_snippets
|
||||
)
|
||||
if task_knowledge_context:
|
||||
task_prompt += task_knowledge_context
|
||||
|
||||
# Then check agent's knowledge
|
||||
if self.knowledge:
|
||||
agent_knowledge_snippets = self.knowledge.query([task.prompt()])
|
||||
if agent_knowledge_snippets:
|
||||
@@ -216,6 +227,7 @@ class Agent(BaseAgent):
|
||||
if agent_knowledge_context:
|
||||
task_prompt += agent_knowledge_context
|
||||
|
||||
# Finally check crew's knowledge
|
||||
if self.crew:
|
||||
knowledge_snippets = self.crew.query_knowledge([task.prompt()])
|
||||
if knowledge_snippets:
|
||||
|
||||
Reference in New Issue
Block a user