-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat: implement knowledge retrieval events in Agent #2727
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
base: main
Are you sure you want to change the base?
Conversation
This commit introduces a series of knowledge retrieval events in the Agent class, enhancing its ability to handle knowledge queries. New events include KnowledgeRetrievalStartedEvent, KnowledgeRetrievalCompletedEvent, KnowledgeQueryGeneratedEvent, KnowledgeQueryFailedEvent, and KnowledgeSearchQueryCompletedEvent. The Agent now emits these events during knowledge retrieval processes, allowing for better tracking and handling of knowledge queries. Additionally, the console formatter has been updated to handle these new events, providing visual feedback during knowledge retrieval operations.
Disclaimer: This review was made by a crew of AI Agents. Code Review Comment: Knowledge Retrieval Events ImplementationOverviewThe changes introduced in this pull request enhance the knowledge retrieval event handling within the Positive Aspects
Issues and Suggested Improvements1. Code Duplication in Event HandlingIssue: The def _emit_knowledge_error(self, event_type, query: str, error: str):
crewai_event_bus.emit(
self,
event=event_type(
query=query,
agent=self,
error=str(error)
)
) 2. Complex Knowledge Query LogicIssue: The current logic in def _process_knowledge_query(self, task_prompt: str) -> str:
if not self.knowledge:
return task_prompt
crewai_event_bus.emit(self, event=KnowledgeRetrievalStartedEvent(agent=self))
try:
search_query = self._get_knowledge_search_query(task_prompt)
if not search_query:
return task_prompt
task_prompt = self._query_knowledge_sources(search_query, task_prompt)
crewai_event_bus.emit(
self,
event=KnowledgeRetrievalCompletedEvent(
query=search_query,
agent=self
)
)
except Exception as e:
self._emit_knowledge_error(KnowledgeSearchQueryFailedEvent,
self.knowledge_search_query or "",
str(e))
return task_prompt 3. Long Method in
|
Disclaimer: This review was made by a crew of AI Agents. Code Review for PR #2727: Implement Knowledge Retrieval Events in AgentSummary of Key Changes
Detailed Findings & Suggestions1.
|
@@ -185,7 +197,7 @@ def execute_task( | |||
self, | |||
task: Task, | |||
context: Optional[str] = None, | |||
tools: Optional[List[BaseTool]] = None | |||
tools: Optional[List[BaseTool]] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely need some rough standard roles for that haha each contribution has its own ‘preferences’
This commit introduces a series of knowledge retrieval events in the Agent class, enhancing its ability to handle knowledge queries. New events include KnowledgeRetrievalStartedEvent, KnowledgeRetrievalCompletedEvent, KnowledgeQueryGeneratedEvent, KnowledgeQueryFailedEvent, and KnowledgeSearchQueryCompletedEvent. The Agent now emits these events during knowledge retrieval processes, allowing for better tracking and handling of knowledge queries. Additionally, the console formatter has been updated to handle these new events, providing visual feedback during knowledge retrieval operations.
need todos: