Skip to content

Lorenzejay/byoa#776

Merged
joaomdmoura merged 46 commits into
mainfrom
lorenzejay/byoa
Jun 27, 2024
Merged

Lorenzejay/byoa#776
joaomdmoura merged 46 commits into
mainfrom
lorenzejay/byoa

Conversation

@lorenzejay
Copy link
Copy Markdown
Collaborator

@lorenzejay lorenzejay commented Jun 16, 2024

this ticket aims to bring your own AI agent whether its a custom langchain one or one like llamaindex and still work with crew or any custom agent.

  • BaseAgent for defining agents that work together adhearing to the crew flow
  • third-party-agent ecosystem for bringing in prebuilt agent from others leveraging the BaseAgent as an abstraction to adhere to the crew flow.

@lorenzejay lorenzejay requested a review from gvieira June 17, 2024 18:45
Copy link
Copy Markdown
Collaborator

@gvieira gvieira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to go through the review, but I think we can connect to discuss the idea of a single Agent interface that would prevent us from doing if agent is this and if agent is that.

Comment thread src/crewai/agent.py Outdated
Comment thread src/crewai/crew.py Outdated
Comment thread src/crewai/crew.py Outdated
Comment thread src/crewai/agents/Third_Party_Agents/llama_index/agent.py Outdated
Comment thread src/crewai/agents/new_wrapper_agent.py Outdated
Comment thread src/crewai/crew.py Outdated
Comment thread src/crewai/crew.py
Comment thread src/crewai/crew.py
Comment thread src/crewai/crew.py Outdated
Comment thread src/crewai/crew.py
@lorenzejay lorenzejay requested a review from gvieira June 21, 2024 18:37
Comment thread src/crewai/agent.py
Comment thread src/crewai/agent.py
Comment thread src/crewai/agent.py
def __init__(__pydantic_self__, **data):
config = data.pop("config", {})
super().__init__(**config, **data)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we aren't going to make gpt-4o the default llm for everything. We need to add a model_validator that checks to make sure the agent has an LLM and isn't none.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. Other agents may not be supporting 4o yet. but I do think a validator for llm not being none is best.

Comment thread src/crewai/agent.py
# tentatively try to import from crewai_tools import BaseTool as CrewAITool
tools_list = []
try:
# tentatively try to import from crewai_tools import BaseTool as CrewAITool
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lorenzejay , drop this comment.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to me: from crewai_tools import BaseTool as CrewAITool

Comment thread src/crewai/agent.py
Comment thread src/crewai/agent.py
if not self._rpm_controller:
self._rpm_controller = rpm_controller
self.create_agent_executor()
def format_log_to_str(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lorenzejay should this be a ABC in BaseAgent?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done abstractmethod set

Comment thread src/crewai/agent.py
return tools

return copied_agent
def get_output_converter(self, llm, text, model, instructions):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a ABC in BaseAgent as well?

Comment thread src/crewai/agents/agent_builder/base_agent_executor_mixin.py Outdated
Comment thread src/crewai/agents/executor.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of these attributes exist on this class. You need to move these attributes over from executor.py and delete them over there.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to move over crew to this class instead of executor.py.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to move over crew_agent from executor.py.

Comment thread src/crewai/agents/agent_builder/base_agent_executor_mixin.py Outdated
Comment thread src/crewai/agents/agent_builder/base_agent_executor_mixin.py Outdated
Comment thread src/crewai/agents/agent_builder/utilities/base_agent_tool.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-06-26 at 11 59 52 PM

We need to add back in the clean up that's in this image to support weaker models.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

main does not have these changes. think we can this later ?

Comment thread src/crewai/crew.py
Comment thread src/crewai/crew.py Outdated
Comment thread src/crewai/crew.py Outdated

self._logger.log("debug", f"[{manager.role}] Task output: {task_output}")

if hasattr(task.agent, "_token_process"):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WHy do we have to do this check in hierarchical but not sequential?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attachment of an agent and task not required will give NoneTypes

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heirarchial does not need an agent in task

Comment thread src/crewai/crew.py Outdated
Comment thread src/crewai/task.py Outdated
Comment thread src/crewai/task.py Outdated
Comment thread src/crewai/task.py
# type: ignore # Item "None" of "Agent | None" has no attribute "function_calling_llm"
llm = self.agent.function_calling_llm or self.agent.llm

llm = getattr(self.agent, "function_calling_llm", None) or self.agent.llm
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To prevent us from making these checks. Maybe we could update the base_agent to have a function_calling_llm but it would be set to None.

Comment thread src/crewai/agents/agent_builder/base_agent.py
Comment thread src/crewai/tools/agent_tools.py
@joaomdmoura joaomdmoura merged commit 10997dd into main Jun 27, 2024
@joaomdmoura joaomdmoura deleted the lorenzejay/byoa branch June 27, 2024 17:56
bhancockio pushed a commit that referenced this pull request Jan 2, 2025
* better spacing

* works with llama index

* works on langchain custom just need delegation to work

* cleanup for custom_agent class

* works with different argument expectations for agent_executor

* cleanup for hierarchial process, better agent_executor args handler and added to the crew agent doc page

* removed code examples for langchain + llama index, added to docs instead

* added key output if return is not a str for and added some tests

* added hinting for CustomAgent class

* removed pass as it was not needed

* closer just need to figuire ou agentTools

* running agents - llamaindex and langchain with base agent

* some cleanup on baseAgent

* minimum for agent to run for base class and ensure it works with hierarchical process

* cleanup for original agent to take on BaseAgent class

* Agent takes on langchainagent and cleanup across

* token handling working for usage_metrics to continue working

* installed llama-index, updated docs and added better name

* fixed some type errors

* base agent holds token_process

* heirarchail process uses proper tools and no longer relies on hasattr for token_processes

* removal of test_custom_agent_executions

* this fixes copying agents

* leveraging an executor class for trigger llamaindex agent

* llama index now has ask_human

* executor mixins added

* added output converter base class

* type listed

* cleanup for output conversions and tokenprocess eliminated redundancy

* properly handling tokens

* simplified token calc handling

* original agent with base agent builder structure setup

* better docs

* no more llama-index dep

* cleaner docs

* test fixes

* poetry reverts and better docs

* base_agent_tools set for third party agents

* updated task and test fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants